From eadb76b3f8e0e9b82da762bd29e53895bf9e6351 Mon Sep 17 00:00:00 2001 From: David Nusinow Date: Sun, 24 Sep 2006 21:11:46 +0000 Subject: Bump to latest mesa in Debian --- progs/beos/GLInfo.cpp | 151 + progs/beos/Makefile | 33 + progs/beos/demo.cpp | 147 + progs/beos/sample.cpp | 225 ++ progs/demos/.cvsignore | 48 + progs/demos/Makefile | 119 + progs/demos/Makefile.cygnus | 87 + progs/demos/Makefile.win | 118 + progs/demos/README | 230 ++ progs/demos/Windows/all.dsp | 101 + progs/demos/Windows/bounce.dsp | 112 + progs/demos/Windows/clearspd.dsp | 112 + progs/demos/Windows/cubemap.dsp | 112 + progs/demos/Windows/demos.dsw | 782 ++++ progs/demos/Windows/drawpix.dsp | 112 + progs/demos/Windows/fire.dsp | 112 + progs/demos/Windows/gears.dsp | 112 + progs/demos/Windows/geartrain.dsp | 112 + progs/demos/Windows/glinfo.dsp | 112 + progs/demos/Windows/gloss.dsp | 112 + progs/demos/Windows/gltestperf.dsp | 112 + progs/demos/Windows/glutfx.dsp | 112 + progs/demos/Windows/ipers.dsp | 112 + progs/demos/Windows/isosurf.dsp | 112 + progs/demos/Windows/loadbias.dsp | 112 + progs/demos/Windows/morph3d.dsp | 112 + progs/demos/Windows/multiarb.dsp | 112 + progs/demos/Windows/occlude.dsp | 112 + progs/demos/Windows/osdemo.dsp | 112 + progs/demos/Windows/paltex.dsp | 112 + progs/demos/Windows/pixeltex.dsp | 112 + progs/demos/Windows/pointblast.dsp | 112 + progs/demos/Windows/rain.dsp | 112 + progs/demos/Windows/ray.dsp | 112 + progs/demos/Windows/readpix.dsp | 112 + progs/demos/Windows/reflect.dsp | 112 + progs/demos/Windows/renormal.dsp | 112 + progs/demos/Windows/shadowtex.dsp | 112 + progs/demos/Windows/spectex.dsp | 112 + progs/demos/Windows/spriteblast.dsp | 112 + progs/demos/Windows/stex3d.dsp | 112 + progs/demos/Windows/teapot.dsp | 112 + progs/demos/Windows/terrain.dsp | 112 + progs/demos/Windows/tessdemo.dsp | 112 + progs/demos/Windows/texcyl.dsp | 112 + progs/demos/Windows/texdown.dsp | 112 + progs/demos/Windows/texenv.dsp | 112 + progs/demos/Windows/texobj.dsp | 112 + progs/demos/Windows/trispd.dsp | 112 + progs/demos/Windows/tunnel.dsp | 112 + progs/demos/Windows/tunnel2.dsp | 112 + progs/demos/Windows/winpos.dsp | 112 + progs/demos/arbfplight.c | 395 ++ progs/demos/arbfslight.c | 289 ++ progs/demos/arbocclude.c | 283 ++ progs/demos/bounce.c | 226 ++ progs/demos/clearspd.c | 218 ++ progs/demos/cubemap.c | 475 +++ progs/demos/descrip.mms | 90 + progs/demos/drawpix.c | 358 ++ progs/demos/fire.c | 777 ++++ progs/demos/fogcoord.c | 420 ++ progs/demos/fplight.c | 285 ++ progs/demos/gamma.c | 162 + progs/demos/gearbox.c | 485 +++ progs/demos/gears.c | 381 ++ progs/demos/geartrain.c | 1073 ++++++ progs/demos/geartrain.dat | 119 + progs/demos/glinfo.c | 32 + progs/demos/gloss.c | 483 +++ progs/demos/glslnoise.c | 185 + progs/demos/gltestperf.c | 580 +++ progs/demos/glutfx.c | 189 + progs/demos/ipers.c | 712 ++++ progs/demos/isosurf.c | 1125 ++++++ progs/demos/isosurf.dat | 7179 +++++++++++++++++++++++++++++++++++ progs/demos/lodbias.c | 282 ++ progs/demos/morph3d.c | 896 +++++ progs/demos/multiarb.c | 345 ++ progs/demos/occlude.c | 234 ++ progs/demos/paltex.c | 270 ++ progs/demos/particles.cxx | 219 ++ progs/demos/particles.h | 81 + progs/demos/pointblast.c | 498 +++ progs/demos/rain.cxx | 394 ++ progs/demos/ray.c | 904 +++++ progs/demos/readpix.c | 344 ++ progs/demos/reflect.c | 590 +++ progs/demos/renormal.c | 139 + progs/demos/shadowtex.c | 766 ++++ progs/demos/singlebuffer.c | 269 ++ progs/demos/spectex.c | 272 ++ progs/demos/spriteblast.c | 554 +++ progs/demos/stex3d.c | 678 ++++ progs/demos/teapot.c | 675 ++++ progs/demos/terrain.c | 656 ++++ progs/demos/terrain.dat | 1 + progs/demos/tessdemo.c | 524 +++ progs/demos/texcyl.c | 288 ++ progs/demos/texdown.c | 403 ++ progs/demos/texenv.c | 815 ++++ progs/demos/texobj.c | 284 ++ progs/demos/trispd.c | 253 ++ progs/demos/tunnel.c | 535 +++ progs/demos/tunnel2.c | 605 +++ progs/demos/tunneldat.h | 395 ++ progs/demos/winpos.c | 118 + progs/egl/Makefile | 65 + progs/egl/demo1.c | 145 + progs/egl/demo2.c | 190 + progs/egl/demo3.c | 636 ++++ progs/egl/eglgears.c | 475 +++ progs/egl/eglinfo.c | 166 + progs/fbdev/Makefile | 53 + progs/fbdev/glfbdevtest.c | 524 +++ progs/fp/Makefile | 127 + progs/fp/tri-abs.c | 107 + progs/fp/tri-add.c | 110 + progs/fp/tri-cmp.c | 110 + progs/fp/tri-cos.c | 113 + progs/fp/tri-depth.c | 111 + progs/fp/tri-depth2.c | 116 + progs/fp/tri-depthwrite.c | 107 + progs/fp/tri-depthwrite2.c | 107 + progs/fp/tri-dp3.c | 109 + progs/fp/tri-dp4.c | 109 + progs/fp/tri-dph.c | 109 + progs/fp/tri-dst.c | 109 + progs/fp/tri-ex2.c | 110 + progs/fp/tri-flr.c | 110 + progs/fp/tri-fp.c | 109 + progs/fp/tri-frc.c | 111 + progs/fp/tri-inv.c | 109 + progs/fp/tri-kil.c | 111 + progs/fp/tri-lg2.c | 110 + progs/fp/tri-lit.c | 111 + progs/fp/tri-lrp.c | 109 + progs/fp/tri-mad.c | 109 + progs/fp/tri-max.c | 109 + progs/fp/tri-min.c | 109 + progs/fp/tri-mov.c | 102 + progs/fp/tri-mul.c | 109 + progs/fp/tri-param.c | 114 + progs/fp/tri-position.c | 109 + progs/fp/tri-pow.c | 109 + progs/fp/tri-rcp.c | 110 + progs/fp/tri-rsq.c | 110 + progs/fp/tri-scs.c | 111 + progs/fp/tri-sge.c | 109 + progs/fp/tri-sge2.c | 114 + progs/fp/tri-sin.c | 114 + progs/fp/tri-slt.c | 109 + progs/fp/tri-sub.c | 109 + progs/fp/tri-swz.c | 109 + progs/fp/tri-swz2.c | 109 + progs/fp/tri-tex.c | 130 + progs/fp/tri-xpd.c | 108 + progs/ggi/asc-view.c | 377 ++ progs/ggi/blah | 2 + progs/ggi/blat | 7 + progs/ggi/box.asc | 66 + progs/ggi/cone.asc | 198 + progs/ggi/gears.c | 340 ++ progs/ggi/gears2.c | 390 ++ progs/ggi/sphere.asc | 132 + progs/ggi/torus.asc | 264 ++ progs/ggi/tube.asc | 396 ++ progs/images/arch.rgb | Bin 0 -> 793398 bytes progs/images/bw.rgb | Bin 0 -> 206452 bytes progs/images/girl.rgb | Bin 0 -> 117075 bytes progs/images/girl2.rgb | Bin 0 -> 117139 bytes progs/images/reflect.rgb | Bin 0 -> 39632 bytes progs/images/s128.rgb | Bin 0 -> 54258 bytes progs/images/tile.rgb | Bin 0 -> 206534 bytes progs/images/tree2.rgba | Bin 0 -> 66048 bytes progs/images/tree3.rgb | Bin 0 -> 24816 bytes progs/images/wrs_logo.rgb | Bin 0 -> 37574 bytes progs/miniglx/Makefile | 58 + progs/miniglx/glfbdevtest.c | 478 +++ progs/miniglx/manytex.c | 382 ++ progs/miniglx/miniglxsample.c | 128 + progs/miniglx/miniglxtest.c | 195 + progs/miniglx/sample_server.c | 112 + progs/miniglx/sample_server2.c | 229 ++ progs/miniglx/texline.c | 268 ++ progs/osdemos/Makefile | 78 + progs/osdemos/osdemo.c | 274 ++ progs/osdemos/osdemo16.c | 291 ++ progs/osdemos/osdemo32.c | 308 ++ progs/osdemos/ostest1.c | 344 ++ progs/redbook/.cvsignore | 64 + progs/redbook/Imakefile | 221 ++ progs/redbook/Makefile | 39 + progs/redbook/Makefile.win | 78 + progs/redbook/README | 41 + progs/redbook/Windows/redbook.dsw | 29 + progs/redbook/Windows/teapots.dsp | 112 + progs/redbook/aaindex.c | 153 + progs/redbook/aapoly.c | 172 + progs/redbook/aargb.c | 149 + progs/redbook/accanti.c | 182 + progs/redbook/accpersp.c | 240 ++ progs/redbook/alpha.c | 143 + progs/redbook/alpha3D.c | 185 + progs/redbook/anti.c | 124 + progs/redbook/bezcurve.c | 114 + progs/redbook/bezmesh.c | 162 + progs/redbook/checker.c | 140 + progs/redbook/clip.c | 108 + progs/redbook/colormat.c | 153 + progs/redbook/cube.c | 97 + progs/redbook/depthcue.c | 115 + progs/redbook/dof.c | 251 ++ progs/redbook/double.c | 146 + progs/redbook/drawf.c | 103 + progs/redbook/feedback.c | 173 + progs/redbook/fog.c | 200 + progs/redbook/fogindex.c | 152 + progs/redbook/font.c | 167 + progs/redbook/hello.c | 110 + progs/redbook/image.c | 159 + progs/redbook/jitter.h | 222 ++ progs/redbook/light.c | 113 + progs/redbook/lines.c | 138 + progs/redbook/list.c | 125 + progs/redbook/material.c | 306 ++ progs/redbook/mipmap.c | 178 + progs/redbook/model.c | 126 + progs/redbook/movelight.c | 148 + progs/redbook/nurbs.c | 190 + progs/redbook/pickdepth.c | 217 ++ progs/redbook/picksquare.c | 197 + progs/redbook/plane.c | 171 + progs/redbook/planet.c | 123 + progs/redbook/polyoff.c | 333 ++ progs/redbook/polys.c | 138 + progs/redbook/quadric.c | 189 + progs/redbook/robot.c | 132 + progs/redbook/sccolorlight.c | 141 + progs/redbook/scene.c | 141 + progs/redbook/scenebamb.c | 140 + progs/redbook/sceneflat.c | 140 + progs/redbook/select.c | 222 ++ progs/redbook/smooth.c | 106 + progs/redbook/stencil.c | 193 + progs/redbook/stroke.c | 195 + progs/redbook/surface.c | 232 ++ progs/redbook/teaambient.c | 162 + progs/redbook/teapots.c | 220 ++ progs/redbook/tess.c | 241 ++ progs/redbook/tesswind.c | 290 ++ progs/redbook/texbind.c | 171 + progs/redbook/texgen.c | 207 + progs/redbook/texprox.c | 120 + progs/redbook/texsub.c | 187 + progs/redbook/texturesurf.c | 155 + progs/redbook/torus.c | 152 + progs/redbook/trim.c | 187 + progs/redbook/unproject.c | 126 + progs/redbook/varray.c | 195 + progs/redbook/wrap.c | 180 + progs/samples/.cvsignore | 45 + progs/samples/Imakefile | 101 + progs/samples/Makefile | 48 + progs/samples/Makefile.DJ | 85 + progs/samples/Makefile.dja | 25 + progs/samples/Makefile.mgw | 68 + progs/samples/Makefile.win | 41 + progs/samples/README | 520 +++ progs/samples/accum.c | 157 + progs/samples/bitmap1.c | 250 ++ progs/samples/bitmap2.c | 787 ++++ progs/samples/blendeq.c | 319 ++ progs/samples/blendxor.c | 206 + progs/samples/copy.c | 193 + progs/samples/cursor.c | 150 + progs/samples/depth.c | 209 + progs/samples/eval.c | 472 +++ progs/samples/fog.c | 311 ++ progs/samples/font.c | 273 ++ progs/samples/line.c | 219 ++ progs/samples/loadppm.c | 72 + progs/samples/logo.c | 1635 ++++++++ progs/samples/nurb.c | 357 ++ progs/samples/oglinfo.c | 218 ++ progs/samples/olympic.c | 389 ++ progs/samples/overlay.c | 378 ++ progs/samples/point.c | 234 ++ progs/samples/prim.c | 546 +++ progs/samples/quad.c | 457 +++ progs/samples/rgbtoppm.c | 285 ++ progs/samples/select.c | 456 +++ progs/samples/shape.c | 345 ++ progs/samples/sphere.c | 1014 +++++ progs/samples/star.c | 345 ++ progs/samples/stencil.c | 143 + progs/samples/stretch.c | 390 ++ progs/samples/texture.c | 474 +++ progs/samples/tkmap.c | 71 + progs/samples/tri.c | 403 ++ progs/samples/wave.c | 619 +++ progs/tests/.cvsignore | 54 + progs/tests/Makefile | 154 + progs/tests/Makefile.win | 44 + progs/tests/afsmultiarb.c | 469 +++ progs/tests/antialias.c | 229 ++ progs/tests/api_speed.c | 146 + progs/tests/api_speed.py | 143 + progs/tests/arbfpspec.c | 192 + progs/tests/arbfptest1.c | 210 + progs/tests/arbfptexture.c | 153 + progs/tests/arbfptrig.c | 156 + progs/tests/arbnpot.c | 174 + progs/tests/arbvptest1.c | 164 + progs/tests/arbvptest3.c | 127 + progs/tests/arbvptorus.c | 191 + progs/tests/arbvpwarpmesh.c | 246 ++ progs/tests/auxbuffer.c | 499 +++ progs/tests/blendminmax.c | 209 + progs/tests/blendsquare.c | 178 + progs/tests/bufferobj.c | 359 ++ progs/tests/bug_3050.c | 162 + progs/tests/bug_3101.c | 128 + progs/tests/bug_3195.c | 275 ++ progs/tests/copypixrate.c | 259 ++ progs/tests/crossbar.c | 235 ++ progs/tests/cva.c | 164 + progs/tests/debugger.c | 733 ++++ progs/tests/descrip.mms | 84 + progs/tests/dinoshade.c | 914 +++++ progs/tests/ext422square.c | 258 ++ progs/tests/fbotest1.c | 204 + progs/tests/fbotest2.c | 199 + progs/tests/fbotexture.c | 404 ++ progs/tests/floattex.c | 169 + progs/tests/fog.c | 199 + progs/tests/fogcoord.c | 102 + progs/tests/fptest1.c | 225 ++ progs/tests/fptexture.c | 151 + progs/tests/getprocaddress.c | 438 +++ progs/tests/getprocaddress.py | 93 + progs/tests/interleave.c | 406 ++ progs/tests/invert.c | 195 + progs/tests/jkrahntest.c | 181 + progs/tests/manytex.c | 382 ++ progs/tests/mipmap_limits.c | 233 ++ progs/tests/multipal.c | 377 ++ progs/tests/multitexarray.c | 238 ++ progs/tests/multiwindow.c | 169 + progs/tests/no_s3tc.c | 97 + progs/tests/packedpixels.c | 342 ++ progs/tests/pbo.c | 296 ++ progs/tests/projtex.c | 1028 +++++ progs/tests/readrate.c | 285 ++ progs/tests/seccolor.c | 145 + progs/tests/sharedtex.c | 438 +++ progs/tests/stencil_wrap.c | 257 ++ progs/tests/stencilwrap.c | 281 ++ progs/tests/subtexrate.c | 350 ++ progs/tests/tex1d.c | 139 + progs/tests/texcmp.c | 414 ++ progs/tests/texcompress2.c | 273 ++ progs/tests/texfilt.c | 398 ++ progs/tests/texgenmix.c | 640 ++++ progs/tests/texline.c | 269 ++ progs/tests/texobjshare.c | 219 ++ progs/tests/texrect.c | 360 ++ progs/tests/texwrap.c | 304 ++ progs/tests/vparray.c | 294 ++ progs/tests/vpeval.c | 231 ++ progs/tests/vptest1.c | 170 + progs/tests/vptest2.c | 151 + progs/tests/vptest3.c | 120 + progs/tests/vptorus.c | 174 + progs/tests/vpwarpmesh.c | 236 ++ progs/tests/yuvrect.c | 193 + progs/tests/yuvsquare.c | 232 ++ progs/tests/zreaddraw.c | 116 + progs/util/README | 2 +- progs/util/descrip.mms | 42 + progs/util/glstate.c | 4 +- progs/util/glstate.h | 4 +- progs/util/glutskel.c | 4 +- progs/util/imagesgi.cpp | 369 ++ progs/util/sampleMakefile | 4 +- progs/vp/Makefile | 53 + progs/vp/abs.txt | 7 + progs/vp/add.txt | 6 + progs/vp/arl.txt | 9 + progs/vp/dp3.txt | 5 + progs/vp/dp4.txt | 5 + progs/vp/dph.txt | 5 + progs/vp/dst.txt | 5 + progs/vp/ex2.txt | 6 + progs/vp/flr.txt | 6 + progs/vp/frc.txt | 6 + progs/vp/lg2.txt | 6 + progs/vp/lit.txt | 6 + progs/vp/mad.txt | 5 + progs/vp/max.txt | 5 + progs/vp/min.txt | 5 + progs/vp/mov.txt | 5 + progs/vp/mul.txt | 5 + progs/vp/pow.txt | 5 + progs/vp/rcp.txt | 7 + progs/vp/rsq.txt | 7 + progs/vp/sge.txt | 5 + progs/vp/slt.txt | 5 + progs/vp/sub.txt | 5 + progs/vp/swz.txt | 5 + progs/vp/swz2.txt | 5 + progs/vp/vp-tris.c | 216 ++ progs/vp/xpd.txt | 5 + progs/windml/Makefile.ugl | 68 + progs/windml/readtex.c | 365 ++ progs/windml/uglaccum.c | 250 ++ progs/windml/uglalldemos.c | 198 + progs/windml/uglbounce.c | 272 ++ progs/windml/uglcube.c | 257 ++ progs/windml/ugldrawpix.c | 438 +++ progs/windml/uglflip.c | 224 ++ progs/windml/uglgears.c | 428 +++ progs/windml/uglicotorus.c | 315 ++ progs/windml/uglline.c | 274 ++ progs/windml/uglolympic.c | 479 +++ progs/windml/uglpoint.c | 277 ++ progs/windml/uglstencil.c | 242 ++ progs/windml/uglteapot.c | 295 ++ progs/windml/ugltexcube.c | 379 ++ progs/windml/ugltexcyl.c | 407 ++ progs/windml/wrs_logo.bmp | Bin 0 -> 196662 bytes progs/xdemos/.cvsignore | 16 + progs/xdemos/Makefile | 83 + progs/xdemos/descrip.mms | 83 + progs/xdemos/glthreads.c | 544 +++ progs/xdemos/glxcontexts.c | 609 +++ progs/xdemos/glxdemo.c | 127 + progs/xdemos/glxgears.c | 621 +++ progs/xdemos/glxgears_fbconfig.c | 602 +++ progs/xdemos/glxheads.c | 286 ++ progs/xdemos/glxinfo.c | 956 +++++ progs/xdemos/glxpbdemo.c | 430 +++ progs/xdemos/glxpixmap.c | 186 + progs/xdemos/glxswapcontrol.c | 824 ++++ progs/xdemos/manywin.c | 393 ++ progs/xdemos/offset.c | 323 ++ progs/xdemos/opencloseopen.c | 189 + progs/xdemos/overlay.c | 245 ++ progs/xdemos/pbdemo.c | 478 +++ progs/xdemos/pbinfo.c | 106 + progs/xdemos/pbutil.c | 426 +++ progs/xdemos/pbutil.h | 66 + progs/xdemos/shape.c | 394 ++ progs/xdemos/vgears.c | 282 ++ progs/xdemos/vindex.c | 65 + progs/xdemos/vtest.c | 82 + progs/xdemos/wincopy.c | 329 ++ progs/xdemos/xdemo.c | 334 ++ progs/xdemos/xfont.c | 206 + progs/xdemos/xrotfontdemo.c | 220 ++ progs/xdemos/xuserotfont.c | 399 ++ progs/xdemos/xuserotfont.h | 12 + progs/xdemos/yuvrect_client.c | 326 ++ 463 files changed, 109770 insertions(+), 9 deletions(-) create mode 100644 progs/beos/GLInfo.cpp create mode 100644 progs/beos/Makefile create mode 100644 progs/beos/demo.cpp create mode 100644 progs/beos/sample.cpp create mode 100644 progs/demos/.cvsignore create mode 100644 progs/demos/Makefile create mode 100644 progs/demos/Makefile.cygnus create mode 100644 progs/demos/Makefile.win create mode 100644 progs/demos/README create mode 100644 progs/demos/Windows/all.dsp create mode 100644 progs/demos/Windows/bounce.dsp create mode 100644 progs/demos/Windows/clearspd.dsp create mode 100644 progs/demos/Windows/cubemap.dsp create mode 100644 progs/demos/Windows/demos.dsw create mode 100644 progs/demos/Windows/drawpix.dsp create mode 100644 progs/demos/Windows/fire.dsp create mode 100644 progs/demos/Windows/gears.dsp create mode 100644 progs/demos/Windows/geartrain.dsp create mode 100644 progs/demos/Windows/glinfo.dsp create mode 100644 progs/demos/Windows/gloss.dsp create mode 100644 progs/demos/Windows/gltestperf.dsp create mode 100644 progs/demos/Windows/glutfx.dsp create mode 100644 progs/demos/Windows/ipers.dsp create mode 100644 progs/demos/Windows/isosurf.dsp create mode 100644 progs/demos/Windows/loadbias.dsp create mode 100644 progs/demos/Windows/morph3d.dsp create mode 100644 progs/demos/Windows/multiarb.dsp create mode 100644 progs/demos/Windows/occlude.dsp create mode 100644 progs/demos/Windows/osdemo.dsp create mode 100644 progs/demos/Windows/paltex.dsp create mode 100644 progs/demos/Windows/pixeltex.dsp create mode 100644 progs/demos/Windows/pointblast.dsp create mode 100644 progs/demos/Windows/rain.dsp create mode 100644 progs/demos/Windows/ray.dsp create mode 100644 progs/demos/Windows/readpix.dsp create mode 100644 progs/demos/Windows/reflect.dsp create mode 100644 progs/demos/Windows/renormal.dsp create mode 100644 progs/demos/Windows/shadowtex.dsp create mode 100644 progs/demos/Windows/spectex.dsp create mode 100644 progs/demos/Windows/spriteblast.dsp create mode 100644 progs/demos/Windows/stex3d.dsp create mode 100644 progs/demos/Windows/teapot.dsp create mode 100644 progs/demos/Windows/terrain.dsp create mode 100644 progs/demos/Windows/tessdemo.dsp create mode 100644 progs/demos/Windows/texcyl.dsp create mode 100644 progs/demos/Windows/texdown.dsp create mode 100644 progs/demos/Windows/texenv.dsp create mode 100644 progs/demos/Windows/texobj.dsp create mode 100644 progs/demos/Windows/trispd.dsp create mode 100644 progs/demos/Windows/tunnel.dsp create mode 100644 progs/demos/Windows/tunnel2.dsp create mode 100644 progs/demos/Windows/winpos.dsp create mode 100644 progs/demos/arbfplight.c create mode 100644 progs/demos/arbfslight.c create mode 100644 progs/demos/arbocclude.c create mode 100644 progs/demos/bounce.c create mode 100644 progs/demos/clearspd.c create mode 100644 progs/demos/cubemap.c create mode 100644 progs/demos/descrip.mms create mode 100644 progs/demos/drawpix.c create mode 100644 progs/demos/fire.c create mode 100644 progs/demos/fogcoord.c create mode 100644 progs/demos/fplight.c create mode 100644 progs/demos/gamma.c create mode 100644 progs/demos/gearbox.c create mode 100644 progs/demos/gears.c create mode 100644 progs/demos/geartrain.c create mode 100644 progs/demos/geartrain.dat create mode 100644 progs/demos/glinfo.c create mode 100644 progs/demos/gloss.c create mode 100755 progs/demos/glslnoise.c create mode 100644 progs/demos/gltestperf.c create mode 100644 progs/demos/glutfx.c create mode 100644 progs/demos/ipers.c create mode 100644 progs/demos/isosurf.c create mode 100644 progs/demos/isosurf.dat create mode 100644 progs/demos/lodbias.c create mode 100644 progs/demos/morph3d.c create mode 100644 progs/demos/multiarb.c create mode 100644 progs/demos/occlude.c create mode 100644 progs/demos/paltex.c create mode 100644 progs/demos/particles.cxx create mode 100644 progs/demos/particles.h create mode 100644 progs/demos/pointblast.c create mode 100644 progs/demos/rain.cxx create mode 100644 progs/demos/ray.c create mode 100644 progs/demos/readpix.c create mode 100644 progs/demos/reflect.c create mode 100644 progs/demos/renormal.c create mode 100644 progs/demos/shadowtex.c create mode 100644 progs/demos/singlebuffer.c create mode 100644 progs/demos/spectex.c create mode 100644 progs/demos/spriteblast.c create mode 100644 progs/demos/stex3d.c create mode 100644 progs/demos/teapot.c create mode 100644 progs/demos/terrain.c create mode 100644 progs/demos/terrain.dat create mode 100644 progs/demos/tessdemo.c create mode 100644 progs/demos/texcyl.c create mode 100644 progs/demos/texdown.c create mode 100644 progs/demos/texenv.c create mode 100644 progs/demos/texobj.c create mode 100644 progs/demos/trispd.c create mode 100644 progs/demos/tunnel.c create mode 100644 progs/demos/tunnel2.c create mode 100644 progs/demos/tunneldat.h create mode 100644 progs/demos/winpos.c create mode 100644 progs/egl/Makefile create mode 100644 progs/egl/demo1.c create mode 100644 progs/egl/demo2.c create mode 100644 progs/egl/demo3.c create mode 100644 progs/egl/eglgears.c create mode 100644 progs/egl/eglinfo.c create mode 100644 progs/fbdev/Makefile create mode 100644 progs/fbdev/glfbdevtest.c create mode 100644 progs/fp/Makefile create mode 100644 progs/fp/tri-abs.c create mode 100644 progs/fp/tri-add.c create mode 100644 progs/fp/tri-cmp.c create mode 100644 progs/fp/tri-cos.c create mode 100644 progs/fp/tri-depth.c create mode 100644 progs/fp/tri-depth2.c create mode 100644 progs/fp/tri-depthwrite.c create mode 100644 progs/fp/tri-depthwrite2.c create mode 100644 progs/fp/tri-dp3.c create mode 100644 progs/fp/tri-dp4.c create mode 100644 progs/fp/tri-dph.c create mode 100644 progs/fp/tri-dst.c create mode 100644 progs/fp/tri-ex2.c create mode 100644 progs/fp/tri-flr.c create mode 100644 progs/fp/tri-fp.c create mode 100644 progs/fp/tri-frc.c create mode 100644 progs/fp/tri-inv.c create mode 100644 progs/fp/tri-kil.c create mode 100644 progs/fp/tri-lg2.c create mode 100644 progs/fp/tri-lit.c create mode 100644 progs/fp/tri-lrp.c create mode 100644 progs/fp/tri-mad.c create mode 100644 progs/fp/tri-max.c create mode 100644 progs/fp/tri-min.c create mode 100644 progs/fp/tri-mov.c create mode 100644 progs/fp/tri-mul.c create mode 100644 progs/fp/tri-param.c create mode 100644 progs/fp/tri-position.c create mode 100644 progs/fp/tri-pow.c create mode 100644 progs/fp/tri-rcp.c create mode 100644 progs/fp/tri-rsq.c create mode 100644 progs/fp/tri-scs.c create mode 100644 progs/fp/tri-sge.c create mode 100644 progs/fp/tri-sge2.c create mode 100644 progs/fp/tri-sin.c create mode 100644 progs/fp/tri-slt.c create mode 100644 progs/fp/tri-sub.c create mode 100644 progs/fp/tri-swz.c create mode 100644 progs/fp/tri-swz2.c create mode 100644 progs/fp/tri-tex.c create mode 100644 progs/fp/tri-xpd.c create mode 100644 progs/ggi/asc-view.c create mode 100644 progs/ggi/blah create mode 100644 progs/ggi/blat create mode 100644 progs/ggi/box.asc create mode 100644 progs/ggi/cone.asc create mode 100644 progs/ggi/gears.c create mode 100644 progs/ggi/gears2.c create mode 100644 progs/ggi/sphere.asc create mode 100644 progs/ggi/torus.asc create mode 100644 progs/ggi/tube.asc create mode 100644 progs/images/arch.rgb create mode 100644 progs/images/bw.rgb create mode 100644 progs/images/girl.rgb create mode 100644 progs/images/girl2.rgb create mode 100644 progs/images/reflect.rgb create mode 100644 progs/images/s128.rgb create mode 100644 progs/images/tile.rgb create mode 100644 progs/images/tree2.rgba create mode 100644 progs/images/tree3.rgb create mode 100644 progs/images/wrs_logo.rgb create mode 100644 progs/miniglx/Makefile create mode 100644 progs/miniglx/glfbdevtest.c create mode 100644 progs/miniglx/manytex.c create mode 100644 progs/miniglx/miniglxsample.c create mode 100644 progs/miniglx/miniglxtest.c create mode 100644 progs/miniglx/sample_server.c create mode 100644 progs/miniglx/sample_server2.c create mode 100644 progs/miniglx/texline.c create mode 100644 progs/osdemos/Makefile create mode 100644 progs/osdemos/osdemo.c create mode 100644 progs/osdemos/osdemo16.c create mode 100644 progs/osdemos/osdemo32.c create mode 100644 progs/osdemos/ostest1.c create mode 100644 progs/redbook/.cvsignore create mode 100644 progs/redbook/Imakefile create mode 100644 progs/redbook/Makefile create mode 100644 progs/redbook/Makefile.win create mode 100644 progs/redbook/README create mode 100644 progs/redbook/Windows/redbook.dsw create mode 100644 progs/redbook/Windows/teapots.dsp create mode 100644 progs/redbook/aaindex.c create mode 100644 progs/redbook/aapoly.c create mode 100644 progs/redbook/aargb.c create mode 100644 progs/redbook/accanti.c create mode 100644 progs/redbook/accpersp.c create mode 100644 progs/redbook/alpha.c create mode 100644 progs/redbook/alpha3D.c create mode 100644 progs/redbook/anti.c create mode 100644 progs/redbook/bezcurve.c create mode 100644 progs/redbook/bezmesh.c create mode 100644 progs/redbook/checker.c create mode 100644 progs/redbook/clip.c create mode 100644 progs/redbook/colormat.c create mode 100644 progs/redbook/cube.c create mode 100644 progs/redbook/depthcue.c create mode 100644 progs/redbook/dof.c create mode 100644 progs/redbook/double.c create mode 100644 progs/redbook/drawf.c create mode 100644 progs/redbook/feedback.c create mode 100644 progs/redbook/fog.c create mode 100644 progs/redbook/fogindex.c create mode 100644 progs/redbook/font.c create mode 100644 progs/redbook/hello.c create mode 100644 progs/redbook/image.c create mode 100644 progs/redbook/jitter.h create mode 100644 progs/redbook/light.c create mode 100644 progs/redbook/lines.c create mode 100644 progs/redbook/list.c create mode 100644 progs/redbook/material.c create mode 100644 progs/redbook/mipmap.c create mode 100644 progs/redbook/model.c create mode 100644 progs/redbook/movelight.c create mode 100644 progs/redbook/nurbs.c create mode 100644 progs/redbook/pickdepth.c create mode 100644 progs/redbook/picksquare.c create mode 100644 progs/redbook/plane.c create mode 100644 progs/redbook/planet.c create mode 100644 progs/redbook/polyoff.c create mode 100644 progs/redbook/polys.c create mode 100644 progs/redbook/quadric.c create mode 100644 progs/redbook/robot.c create mode 100644 progs/redbook/sccolorlight.c create mode 100644 progs/redbook/scene.c create mode 100644 progs/redbook/scenebamb.c create mode 100644 progs/redbook/sceneflat.c create mode 100644 progs/redbook/select.c create mode 100644 progs/redbook/smooth.c create mode 100644 progs/redbook/stencil.c create mode 100644 progs/redbook/stroke.c create mode 100644 progs/redbook/surface.c create mode 100644 progs/redbook/teaambient.c create mode 100644 progs/redbook/teapots.c create mode 100644 progs/redbook/tess.c create mode 100644 progs/redbook/tesswind.c create mode 100644 progs/redbook/texbind.c create mode 100644 progs/redbook/texgen.c create mode 100644 progs/redbook/texprox.c create mode 100644 progs/redbook/texsub.c create mode 100644 progs/redbook/texturesurf.c create mode 100644 progs/redbook/torus.c create mode 100644 progs/redbook/trim.c create mode 100644 progs/redbook/unproject.c create mode 100644 progs/redbook/varray.c create mode 100644 progs/redbook/wrap.c create mode 100644 progs/samples/.cvsignore create mode 100644 progs/samples/Imakefile create mode 100644 progs/samples/Makefile create mode 100644 progs/samples/Makefile.DJ create mode 100644 progs/samples/Makefile.dja create mode 100644 progs/samples/Makefile.mgw create mode 100644 progs/samples/Makefile.win create mode 100644 progs/samples/README create mode 100644 progs/samples/accum.c create mode 100644 progs/samples/bitmap1.c create mode 100644 progs/samples/bitmap2.c create mode 100644 progs/samples/blendeq.c create mode 100644 progs/samples/blendxor.c create mode 100644 progs/samples/copy.c create mode 100644 progs/samples/cursor.c create mode 100644 progs/samples/depth.c create mode 100644 progs/samples/eval.c create mode 100644 progs/samples/fog.c create mode 100644 progs/samples/font.c create mode 100644 progs/samples/line.c create mode 100644 progs/samples/loadppm.c create mode 100644 progs/samples/logo.c create mode 100644 progs/samples/nurb.c create mode 100644 progs/samples/oglinfo.c create mode 100644 progs/samples/olympic.c create mode 100644 progs/samples/overlay.c create mode 100644 progs/samples/point.c create mode 100644 progs/samples/prim.c create mode 100644 progs/samples/quad.c create mode 100644 progs/samples/rgbtoppm.c create mode 100644 progs/samples/select.c create mode 100644 progs/samples/shape.c create mode 100644 progs/samples/sphere.c create mode 100644 progs/samples/star.c create mode 100644 progs/samples/stencil.c create mode 100644 progs/samples/stretch.c create mode 100644 progs/samples/texture.c create mode 100644 progs/samples/tkmap.c create mode 100644 progs/samples/tri.c create mode 100644 progs/samples/wave.c create mode 100644 progs/tests/.cvsignore create mode 100644 progs/tests/Makefile create mode 100644 progs/tests/Makefile.win create mode 100644 progs/tests/afsmultiarb.c create mode 100644 progs/tests/antialias.c create mode 100644 progs/tests/api_speed.c create mode 100755 progs/tests/api_speed.py create mode 100644 progs/tests/arbfpspec.c create mode 100644 progs/tests/arbfptest1.c create mode 100644 progs/tests/arbfptexture.c create mode 100644 progs/tests/arbfptrig.c create mode 100644 progs/tests/arbnpot.c create mode 100644 progs/tests/arbvptest1.c create mode 100644 progs/tests/arbvptest3.c create mode 100644 progs/tests/arbvptorus.c create mode 100644 progs/tests/arbvpwarpmesh.c create mode 100644 progs/tests/auxbuffer.c create mode 100644 progs/tests/blendminmax.c create mode 100644 progs/tests/blendsquare.c create mode 100644 progs/tests/bufferobj.c create mode 100644 progs/tests/bug_3050.c create mode 100644 progs/tests/bug_3101.c create mode 100644 progs/tests/bug_3195.c create mode 100644 progs/tests/copypixrate.c create mode 100644 progs/tests/crossbar.c create mode 100644 progs/tests/cva.c create mode 100644 progs/tests/debugger.c create mode 100644 progs/tests/descrip.mms create mode 100644 progs/tests/dinoshade.c create mode 100644 progs/tests/ext422square.c create mode 100644 progs/tests/fbotest1.c create mode 100644 progs/tests/fbotest2.c create mode 100644 progs/tests/fbotexture.c create mode 100644 progs/tests/floattex.c create mode 100644 progs/tests/fog.c create mode 100644 progs/tests/fogcoord.c create mode 100644 progs/tests/fptest1.c create mode 100644 progs/tests/fptexture.c create mode 100644 progs/tests/getprocaddress.c create mode 100644 progs/tests/getprocaddress.py create mode 100644 progs/tests/interleave.c create mode 100644 progs/tests/invert.c create mode 100644 progs/tests/jkrahntest.c create mode 100644 progs/tests/manytex.c create mode 100644 progs/tests/mipmap_limits.c create mode 100644 progs/tests/multipal.c create mode 100644 progs/tests/multitexarray.c create mode 100644 progs/tests/multiwindow.c create mode 100644 progs/tests/no_s3tc.c create mode 100644 progs/tests/packedpixels.c create mode 100644 progs/tests/pbo.c create mode 100644 progs/tests/projtex.c create mode 100644 progs/tests/readrate.c create mode 100644 progs/tests/seccolor.c create mode 100644 progs/tests/sharedtex.c create mode 100644 progs/tests/stencil_wrap.c create mode 100644 progs/tests/stencilwrap.c create mode 100644 progs/tests/subtexrate.c create mode 100644 progs/tests/tex1d.c create mode 100644 progs/tests/texcmp.c create mode 100644 progs/tests/texcompress2.c create mode 100644 progs/tests/texfilt.c create mode 100644 progs/tests/texgenmix.c create mode 100644 progs/tests/texline.c create mode 100644 progs/tests/texobjshare.c create mode 100644 progs/tests/texrect.c create mode 100644 progs/tests/texwrap.c create mode 100644 progs/tests/vparray.c create mode 100644 progs/tests/vpeval.c create mode 100644 progs/tests/vptest1.c create mode 100644 progs/tests/vptest2.c create mode 100644 progs/tests/vptest3.c create mode 100644 progs/tests/vptorus.c create mode 100644 progs/tests/vpwarpmesh.c create mode 100644 progs/tests/yuvrect.c create mode 100644 progs/tests/yuvsquare.c create mode 100644 progs/tests/zreaddraw.c create mode 100644 progs/util/descrip.mms create mode 100644 progs/util/imagesgi.cpp create mode 100644 progs/vp/Makefile create mode 100644 progs/vp/abs.txt create mode 100644 progs/vp/add.txt create mode 100644 progs/vp/arl.txt create mode 100644 progs/vp/dp3.txt create mode 100644 progs/vp/dp4.txt create mode 100644 progs/vp/dph.txt create mode 100644 progs/vp/dst.txt create mode 100644 progs/vp/ex2.txt create mode 100644 progs/vp/flr.txt create mode 100644 progs/vp/frc.txt create mode 100644 progs/vp/lg2.txt create mode 100644 progs/vp/lit.txt create mode 100644 progs/vp/mad.txt create mode 100644 progs/vp/max.txt create mode 100644 progs/vp/min.txt create mode 100644 progs/vp/mov.txt create mode 100644 progs/vp/mul.txt create mode 100644 progs/vp/pow.txt create mode 100644 progs/vp/rcp.txt create mode 100644 progs/vp/rsq.txt create mode 100644 progs/vp/sge.txt create mode 100644 progs/vp/slt.txt create mode 100644 progs/vp/sub.txt create mode 100644 progs/vp/swz.txt create mode 100644 progs/vp/swz2.txt create mode 100644 progs/vp/vp-tris.c create mode 100644 progs/vp/xpd.txt create mode 100644 progs/windml/Makefile.ugl create mode 100644 progs/windml/readtex.c create mode 100644 progs/windml/uglaccum.c create mode 100644 progs/windml/uglalldemos.c create mode 100644 progs/windml/uglbounce.c create mode 100644 progs/windml/uglcube.c create mode 100644 progs/windml/ugldrawpix.c create mode 100644 progs/windml/uglflip.c create mode 100644 progs/windml/uglgears.c create mode 100644 progs/windml/uglicotorus.c create mode 100644 progs/windml/uglline.c create mode 100644 progs/windml/uglolympic.c create mode 100644 progs/windml/uglpoint.c create mode 100644 progs/windml/uglstencil.c create mode 100644 progs/windml/uglteapot.c create mode 100644 progs/windml/ugltexcube.c create mode 100644 progs/windml/ugltexcyl.c create mode 100644 progs/windml/wrs_logo.bmp create mode 100644 progs/xdemos/.cvsignore create mode 100644 progs/xdemos/Makefile create mode 100644 progs/xdemos/descrip.mms create mode 100644 progs/xdemos/glthreads.c create mode 100644 progs/xdemos/glxcontexts.c create mode 100644 progs/xdemos/glxdemo.c create mode 100644 progs/xdemos/glxgears.c create mode 100644 progs/xdemos/glxgears_fbconfig.c create mode 100644 progs/xdemos/glxheads.c create mode 100644 progs/xdemos/glxinfo.c create mode 100644 progs/xdemos/glxpbdemo.c create mode 100644 progs/xdemos/glxpixmap.c create mode 100644 progs/xdemos/glxswapcontrol.c create mode 100644 progs/xdemos/manywin.c create mode 100644 progs/xdemos/offset.c create mode 100644 progs/xdemos/opencloseopen.c create mode 100644 progs/xdemos/overlay.c create mode 100644 progs/xdemos/pbdemo.c create mode 100644 progs/xdemos/pbinfo.c create mode 100644 progs/xdemos/pbutil.c create mode 100644 progs/xdemos/pbutil.h create mode 100644 progs/xdemos/shape.c create mode 100644 progs/xdemos/vgears.c create mode 100644 progs/xdemos/vindex.c create mode 100644 progs/xdemos/vtest.c create mode 100644 progs/xdemos/wincopy.c create mode 100644 progs/xdemos/xdemo.c create mode 100644 progs/xdemos/xfont.c create mode 100644 progs/xdemos/xrotfontdemo.c create mode 100644 progs/xdemos/xuserotfont.c create mode 100644 progs/xdemos/xuserotfont.h create mode 100644 progs/xdemos/yuvrect_client.c (limited to 'progs') diff --git a/progs/beos/GLInfo.cpp b/progs/beos/GLInfo.cpp new file mode 100644 index 00000000000..cfa8c83af82 --- /dev/null +++ b/progs/beos/GLInfo.cpp @@ -0,0 +1,151 @@ +// Small app to display GL infos + +#include +#include + +#include +#include +#include +#include +#include + +#include + +#include +#include + +#define GLUT_INFO 1 +#ifdef GLUT_INFO + #include +#endif + + +class GLInfoWindow : public BWindow +{ +public: + GLInfoWindow(BRect frame); + virtual bool QuitRequested() { be_app->PostMessage(B_QUIT_REQUESTED); return true; } + +private: + BGLView *gl; + BOutlineListView *list; + BScrollView *scroller; +}; + + +class GLInfoApp : public BApplication +{ +public: + GLInfoApp(); +private: + GLInfoWindow *window; +}; + + +GLInfoApp::GLInfoApp() + : BApplication("application/x-vnd.OBOS-GLInfo") +{ + window = new GLInfoWindow(BRect(50, 50, 350, 350)); +} + +GLInfoWindow::GLInfoWindow(BRect frame) + : BWindow(frame, "OpenGL Info", B_TITLED_WINDOW, 0) +{ + BRect r = Bounds(); + char *s; + BString l; + + // Add a outline list view + r.right -= B_V_SCROLL_BAR_WIDTH; + list = new BOutlineListView(r, "GLInfoList", B_SINGLE_SELECTION_LIST, B_FOLLOW_ALL_SIDES); + scroller = new BScrollView("GLInfoListScroller", list, B_FOLLOW_ALL_SIDES, + B_WILL_DRAW | B_FRAME_EVENTS, false, true); + + gl = new BGLView(r, "opengl", B_FOLLOW_ALL_SIDES, 0, BGL_RGB | BGL_DOUBLE); + gl->Hide(); + AddChild(gl); + AddChild(scroller); + + Show(); + + LockLooper(); + + // gl->LockGL(); + + list->AddItem(new BStringItem("OpenGL", 0)); + + s = (char *) glGetString(GL_VENDOR); + if (s) { + l = ""; l << "Vendor Name: " << s; + list->AddItem(new BStringItem(l.String(), 1)); + } + + s = (char *) glGetString(GL_VERSION); + if (s) { + l = ""; l << "Version: " << s; + list->AddItem(new BStringItem(l.String(), 1)); + } + + s = (char *) glGetString(GL_RENDERER); + if (s) { + l = ""; l << "Renderer Name: " << s; + list->AddItem(new BStringItem(l.String(), 1)); + } + + s = (char *) glGetString(GL_EXTENSIONS); + if (s) { + list->AddItem(new BStringItem("Extensions", 1)); + while (*s) { + char extname[255]; + int n = strcspn(s, " "); + strncpy(extname, s, n); + extname[n] = 0; + list->AddItem(new BStringItem(extname, 2)); + if (! s[n]) + break; + s += (n + 1); // next ! + } + } + + list->AddItem(new BStringItem("GLU", 0)); + s = (char *) gluGetString(GLU_VERSION); + if (s) { + l = ""; l << "Version: " << s; + list->AddItem(new BStringItem(l.String(), 1)); + } + + s = (char *) gluGetString(GLU_EXTENSIONS); + if (s) { + list->AddItem(new BStringItem("Extensions", 1)); + while (*s) { + char extname[255]; + int n = strcspn(s, " "); + strncpy(extname, s, n); + extname[n] = 0; + list->AddItem(new BStringItem(extname, 2)); + if (! s[n]) + break; + s += (n + 1); // next ! + } + } + +#ifdef GLUT_INFO + list->AddItem(new BStringItem("GLUT", 0)); + l = "API version: "; l << GLUT_API_VERSION; + list->AddItem(new BStringItem(l.String(), 1)); +#endif + + // gl->UnlockGL(); + + UnlockLooper(); +} + + + +int main(int argc, char *argv[]) +{ + GLInfoApp *app = new GLInfoApp; + app->Run(); + delete app; + return 0; +} diff --git a/progs/beos/Makefile b/progs/beos/Makefile new file mode 100644 index 00000000000..45782fb3cf7 --- /dev/null +++ b/progs/beos/Makefile @@ -0,0 +1,33 @@ +# progs/beos/Makefile + +TOP = ../.. +include $(TOP)/configs/current + +# Makefile for BeOS demos + +# Written by Brian Paul +# This file is in the public domain. +# +# Modified by Philippe Houdoin + +LDFLAGS += -soname=_APP_ $(APP_LIB_DEPS) + +INCLUDES = -I. -I- -I../../include + +default: demo sample GLInfo + +clean: + rm -f demo sample GLInfo + rm -f *.o + +demo: demo.o + $(LD) demo.o $(LDFLAGS) -o $@ + +sample: sample.o + $(LD) sample.o $(LDFLAGS) -o $@ + +GTLInfo: GLInfo.o + $(LD) GLInfo.o $(INCLUDES) $(LDFLAGS) -o $@ + +.cpp.o: + $(CC) -c $< $(INCLUDES) $(CFLAGS) -o $@ diff --git a/progs/beos/demo.cpp b/progs/beos/demo.cpp new file mode 100644 index 00000000000..42f316a71f1 --- /dev/null +++ b/progs/beos/demo.cpp @@ -0,0 +1,147 @@ +// $Id: demo.cpp,v 1.2 2004-08-14 09:59:16 phoudoin Exp $ + +// Simple BeOS GLView demo +// Written by Brian Paul +// Changes by Philippe Houdoin +// This file is in the public domain. + + + +#include +#include +#include +#include + +class MyGL : public BGLView +{ +public: + MyGL(BRect rect, char *name, ulong options); + + virtual void AttachedToWindow(); + virtual void Pulse(); + virtual void FrameResized(float w, float h); + +private: + void Render(); + void Reshape(float w, float h); + float mAngle; +}; + + +class MyWindow : public BWindow +{ +public: + MyWindow(BRect frame); + virtual bool QuitRequested(); +}; + + +MyWindow::MyWindow(BRect frame) + : BWindow(frame, "demo", B_TITLED_WINDOW, B_NOT_ZOOMABLE) +{ + // Make OpenGL view and put it in the window + BRect r = Bounds(); + r.InsetBy(5, 5); + + MyGL *gl = new MyGL(r, "GL", BGL_RGB | BGL_DOUBLE); + AddChild(gl); + SetPulseRate(1000000 / 30); +} + +bool MyWindow::QuitRequested() +{ + be_app->PostMessage(B_QUIT_REQUESTED); + return true; +} + + + +MyGL::MyGL(BRect rect, char *name, ulong options) + : BGLView(rect, name, B_FOLLOW_ALL_SIDES, B_PULSE_NEEDED, options) +{ + mAngle = 0.0; +} + + +void MyGL::AttachedToWindow() +{ + BGLView::AttachedToWindow(); + + LockGL(); + glClearColor(0.7, 0.7, 0, 0); + Reshape(Bounds().Width(), Bounds().Height()); + UnlockGL(); +} + + +void MyGL::FrameResized(float w, float h) +{ + BGLView::FrameResized(w, h); + + LockGL(); + Reshape(w, h); + UnlockGL(); + + Render(); +} + + +void MyGL::Pulse() +{ + mAngle += 1.0; + Render(); +} + + +void MyGL::Render() +{ + LockGL(); + + glClear(GL_COLOR_BUFFER_BIT); + + glPushMatrix(); + + glRotated(mAngle, 0, 0, 1); + glColor3f(0, 0, 1); + + glBegin(GL_POLYGON); + glVertex2f(-1, -1); + glVertex2f( 1, -1); + glVertex2f( 1, 1); + glVertex2f(-1, 1); + glEnd(); + + glPopMatrix(); + + SwapBuffers(); + + UnlockGL(); +} + + +void MyGL::Reshape(float w, float h) +{ + glViewport(0, 0, (int) (w + 1), (int) (h + 1)); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glFrustum(-1, 1, -1, 1, 10, 30); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTranslatef(0, 0, -18); +} + + +int main(int argc, char *argv[]) +{ + BApplication *app = new BApplication("application/demo"); + + // make top-level window + MyWindow *win = new MyWindow(BRect(100, 100, 500, 500)); + win->Show(); + + app->Run(); + + delete app; + + return 0; +} diff --git a/progs/beos/sample.cpp b/progs/beos/sample.cpp new file mode 100644 index 00000000000..a86a118747f --- /dev/null +++ b/progs/beos/sample.cpp @@ -0,0 +1,225 @@ +// sample BGLView app from the Be Book + + +#include +#include +#include +#include + + +class SampleGLView : public BGLView +{ +public: + SampleGLView(BRect frame, uint32 type); + virtual void AttachedToWindow(void); + virtual void FrameResized(float newWidth, float newHeight); + virtual void ErrorCallback(GLenum which); + + void Render(void); + +private: + void gInit(void); + void gDraw(void); + void gReshape(int width, int height); + + float width; + float height; +}; + + + +class SampleGLWindow : public BWindow +{ +public: + SampleGLWindow(BRect frame, uint32 type); + virtual bool QuitRequested() { be_app->PostMessage(B_QUIT_REQUESTED); return true; } + +private: + SampleGLView *theView; +}; + + +class SampleGLApp : public BApplication +{ +public: + SampleGLApp(); +private: + SampleGLWindow *theWindow; +}; + + +SampleGLApp::SampleGLApp() + : BApplication("application/x-vnd.sample") +{ + BRect windowRect; + uint32 type = BGL_RGB|BGL_DOUBLE; + + windowRect.Set(50, 50, 350, 350); + + theWindow = new SampleGLWindow(windowRect, type); +} + + + +SampleGLWindow::SampleGLWindow(BRect frame, uint32 type) + : BWindow(frame, "OpenGL Test", B_TITLED_WINDOW, 0) +{ + theView = new SampleGLView(Bounds(), type); + AddChild(theView); + Show(); + theView->Render(); +} + + + +SampleGLView::SampleGLView(BRect frame, uint32 type) + : BGLView(frame, "SampleGLView", B_FOLLOW_ALL_SIDES, 0, type) +{ + width = frame.right-frame.left; + height = frame.bottom-frame.top; +} + + +void SampleGLView::AttachedToWindow(void) +{ + LockGL(); + BGLView::AttachedToWindow(); + gInit(); + gReshape(width, height); + UnlockGL(); +} + + +void SampleGLView::FrameResized(float newWidth, float newHeight) +{ + BGLView::FrameResized(newWidth, newHeight); + + LockGL(); + + width = newWidth; + height = newHeight; + + gReshape(width,height); + + UnlockGL(); + Render(); +} + + +void SampleGLView::ErrorCallback(GLenum whichError) +{ +// fprintf(stderr, "Unexpected error occured (%d):\\n", whichError); +// fprintf(stderr, " %s\\n", gluErrorString(whichError)); +} + + + +// globals +GLenum use_stipple_mode; // GL_TRUE to use dashed lines +GLenum use_smooth_mode; // GL_TRUE to use anti-aliased lines +GLint linesize; // Line width +GLint pointsize; // Point diameter + +float pntA[3] = { + -160.0, 0.0, 0.0 +}; +float pntB[3] = { + -130.0, 0.0, 0.0 +}; + + + +void SampleGLView::gInit(void) +{ + glClearColor(0.0, 0.0, 0.0, 0.0); + glLineStipple(1, 0xF0E0); + glBlendFunc(GL_SRC_ALPHA, GL_ONE); + use_stipple_mode = GL_FALSE; + use_smooth_mode = GL_TRUE; + linesize = 2; + pointsize = 6; +} + + + +void SampleGLView::gDraw(void) +{ + GLint i; + + glClear(GL_COLOR_BUFFER_BIT); + glLineWidth(linesize); + +/* + + if (use_stipple_mode) { + glEnable(GL_LINE_STIPPLE); + } else { + glDisable(GL_LINE_STIPPLE); + } +*/ + + glDisable(GL_POINT_SMOOTH); + + + glPushMatrix(); + + glPointSize(pointsize); // Set size for point + + for (i = 0; i < 360; i += 5) { + glRotatef(5.0, 0,0,1); // Rotate right 5 degrees + + if (use_smooth_mode) { + glEnable(GL_LINE_SMOOTH); + glEnable(GL_BLEND); + } else { + glDisable(GL_LINE_SMOOTH); + glDisable(GL_BLEND); + } + + glColor3f(1.0, 1.0, 0.0); // Set color for line + glBegin(GL_LINE_STRIP); // And create the line + glVertex3fv(pntA); + glVertex3fv(pntB); + glEnd(); + + glDisable(GL_POINT_SMOOTH); + glDisable(GL_BLEND); + + glColor3f(0.0, 1.0, 0.0); // Set color for point + glBegin(GL_POINTS); + glVertex3fv(pntA); // Draw point at one end + glVertex3fv(pntB); // Draw point at other end + glEnd(); + } + + glPopMatrix(); // Done with matrix +} + + +void SampleGLView::gReshape(int width, int height) +{ + glViewport(0, 0, width, height); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-175, 175, -175, 175, -1, 1); + glMatrixMode(GL_MODELVIEW); +} + + +void SampleGLView::Render(void) +{ + LockGL(); + gDraw(); + SwapBuffers(); + UnlockGL(); +} + + + +int main(int argc, char *argv[]) +{ + SampleGLApp *app = new SampleGLApp; + app->Run(); + delete app; + return 0; +} diff --git a/progs/demos/.cvsignore b/progs/demos/.cvsignore new file mode 100644 index 00000000000..f764b3d117e --- /dev/null +++ b/progs/demos/.cvsignore @@ -0,0 +1,48 @@ +.cvsignore +arbfplight +arbocclude +bounce +clearspd +cubemap +drawpix +fire +fplight +gamma +gears +geartrain +glinfo +gloss +gltestperf +glutfx +ipers +isosurf +lodbias +morph3d +multiarb +occlude +osdemo +paltex +pixeltex +pointblast +ray +readpix +readtex.c +readtex.h +reflect +renormal +shadowtex +showbuffer.c +showbuffer.h +spectex +stex3d +teapot +terrain +tessdemo +texcyl +texdown +texenv +texobj +trispd +tunnel +tunnel2 +winpos diff --git a/progs/demos/Makefile b/progs/demos/Makefile new file mode 100644 index 00000000000..c7a4cc7b828 --- /dev/null +++ b/progs/demos/Makefile @@ -0,0 +1,119 @@ +# progs/demos/Makefile + +TOP = ../.. +include $(TOP)/configs/current + +INCDIR = $(TOP)/include + +OSMESA_LIBS = -L$(LIB_DIR) -lglut -lOSMesa -lGLU -lGL $(APP_LIB_DEPS) + +OSMESA16_LIBS = -L$(LIB_DIR) -lglut -lOSMesa16 -lGLU -lGL $(APP_LIB_DEPS) + +OSMESA32_LIBS = -L$(LIB_DIR) -lglut -lOSMesa32 -lGLU -lGL $(APP_LIB_DEPS) + +LIB_DEP = $(LIB_DIR)/$(GL_LIB_NAME) $(LIB_DIR)/$(GLU_LIB_NAME) $(LIB_DIR)/$(GLUT_LIB_NAME) + +PROGS = \ + arbfplight \ + arbfslight \ + arbocclude \ + bounce \ + clearspd \ + cubemap \ + drawpix \ + fire \ + fogcoord \ + fplight \ + gamma \ + gearbox \ + gears \ + geartrain \ + glinfo \ + gloss \ + glslnoise \ + gltestperf \ + glutfx \ + isosurf \ + ipers \ + lodbias \ + morph3d \ + multiarb \ + occlude \ + paltex \ + pointblast \ + ray \ + readpix \ + reflect \ + renormal \ + shadowtex \ + singlebuffer \ + spectex \ + spriteblast \ + stex3d \ + teapot \ + terrain \ + tessdemo \ + texcyl \ + texdown \ + texenv \ + texobj \ + trispd \ + tunnel \ + tunnel2 \ + winpos + + +##### RULES ##### + +.SUFFIXES: +.SUFFIXES: .c + + +# make executable from .c file: +.c: $(LIB_DEP) readtex.o + $(CC) -I$(INCDIR) $(CFLAGS) $< readtex.o $(APP_LIB_DEPS) -o $@ + + +##### TARGETS ##### + +default: $(PROGS) + +$(PROGS): readtex.o + +readtex.c: $(TOP)/progs/util/readtex.c + cp $< . + +readtex.h: $(TOP)/progs/util/readtex.h + cp $< . + +readtex.o: readtex.c readtex.h + $(CC) -c -I$(INCDIR) $(CFLAGS) readtex.c + + +showbuffer.c: $(TOP)/progs/util/showbuffer.c + cp $< . + +showbuffer.h: $(TOP)/progs/util/showbuffer.h + cp $< . + +showbuffer.o: showbuffer.c showbuffer.h + $(CC) -c -I$(INCDIR) $(CFLAGS) showbuffer.c + + +reflect: reflect.o showbuffer.o readtex.o + $(CC) -I$(INCDIR) $(CFLAGS) reflect.o showbuffer.o readtex.o $(APP_LIB_DEPS) -o $@ + +reflect.o: reflect.c showbuffer.h + $(CC) -c -I$(INCDIR) $(CFLAGS) reflect.c + + +shadowtex: shadowtex.o showbuffer.o + $(CC) -I$(INCDIR) $(CFLAGS) shadowtex.o showbuffer.o $(APP_LIB_DEPS) -o $@ + +shadowtex.o: shadowtex.c showbuffer.h + $(CC) -c -I$(INCDIR) $(CFLAGS) shadowtex.c + +clean: + -rm -f $(PROGS) + -rm -f *.o *~ + -rm -f readtex.[ch] showbuffer.[ch] diff --git a/progs/demos/Makefile.cygnus b/progs/demos/Makefile.cygnus new file mode 100644 index 00000000000..0efc1ab0c99 --- /dev/null +++ b/progs/demos/Makefile.cygnus @@ -0,0 +1,87 @@ + +# Mesa 3-D graphics library +# Version: 3.3 +# Copyright (C) 1995-2000 Brian Paul + + +# Makefile for demo programs for cygnus +# Stephane Rehel (rehel@worldnet.fr) April 13 1997 + + + +##### MACROS ##### + +INCDIR = ../include +LIBDIR = ../lib + +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 + + +##### RULES ##### + +.SUFFIXES: +.SUFFIXES: .c + +.c: $(LIB_DEP) + $(CC) -I$(INCDIR) -I../util $(CFLAGS) $< $(GL_LIBS) -o $@ + + +##### TARGETS ##### + +default: + @echo "Specify a target configuration" + +clean: + -rm *.o *~ + +realclean: + -rm $(PROGS:=.exe) + -rm *.o *~ + +targets: $(PROGS) + +include ../Make-config + + diff --git a/progs/demos/Makefile.win b/progs/demos/Makefile.win new file mode 100644 index 00000000000..4ac32361b26 --- /dev/null +++ b/progs/demos/Makefile.win @@ -0,0 +1,118 @@ + +# Mesa 3-D graphics library +# Version: 6.5 +# Copyright (C) 1995-2006 Brian Paul + +# Makefile for GLUT-based demo programs for Windows + +# Build the Mesa and GLUT libraries by using the Visual Studio +# Workspaces in this distribution before running this Makefile. + +# Invocation: nmake -f Makefile.win + +NODEBUG=1 +!include + +##### MACROS ##### + +TOP = ..\.. +INCDIR = ..\..\include +LIBDIR = ..\..\lib +LIBS = GLUT32.LIB OPENGL32.LIB + +all: OPENGL32.DLL GLU32.DLL GLUT32.DLL \ + readtex.h readtex.c showbuffer.h showbuffer.c \ + arbfplight.exe arbfslight.exe arbocclude.exe bounce.exe \ + clearspd.exe cubemap.exe drawpix.exe fire.exe fogcoord.exe \ + fplight.exe gamma.exe gearbox.exe \ + gears.exe geartrain.exe gloss.exe \ + glinfo.exe glslnoise.exe \ + gltestperf.exe glutfx.exe ipers.exe isosurf.exe lodbias.exe \ + morph3d.exe multiarb.exe occlude.exe paltex.exe pointblast.exe \ + ray.exe readpix.exe reflect.exe renormal.exe \ + shadowtex.exe singlebuffer.exe spectex.exe spriteblast.exe \ + stex3d.exe teapot.exe terrain.exe tessdemo.exe texcyl.exe \ + texdown.exe texenv.exe texobj.exe trispd.exe tunnel.exe tunnel2.exe \ + winpos.exe + +arbfplight.exe: arbfplight.obj +arbfslight.exe: arbfslight.obj +arbocclude.exe: arbocclude.obj +bounce.exe: bounce.obj +clearspd.exe: clearspd.obj +cubemap.exe: cubemap.obj readtex.obj +drawpix.exe: drawpix.obj readtex.obj +fire.exe: fire.obj readtex.obj +fogcoord.exe: fogcoord.obj readtex.obj +fplight.exe: fplight.obj +gamma.exe: gamma.obj +gearbox.exe: gearbox.obj +gears.exe: gears.obj +geartrain.exe: geartrain.obj +gloss.exe: gloss.obj readtex.obj +glinfo.exe: glinfo.obj +glslnoise.exe: glslnoise.obj +gltestperf.exe: gltestperf.obj +glutfx.exe: glutfx.obj +ipers.exe: ipers.obj readtex.obj +isosurf.exe: isosurf.obj readtex.obj +lodbias.exe: lodbias.obj readtex.obj +morph3d.exe: morph3d.obj +multiarb.exe: multiarb.obj readtex.obj +occlude.exe: occlude.obj +paltex.exe: paltex.obj +pointblast.exe: pointblast.obj +ray.exe: ray.obj +readpix.exe: readpix.obj readtex.obj +reflect.exe: reflect.obj readtex.obj showbuffer.obj +renormal.exe: renormal.obj +shadowtex.exe: shadowtex.obj showbuffer.obj +singlebuffer.exe: singlebuffer.obj +spectex.exe: spectex.obj +spriteblast.exe: spriteblast.obj +stex3d.exe: stex3d.obj +teapot.exe: teapot.obj readtex.obj +terrain.exe: terrain.obj +tessdemo.exe: tessdemo.obj +texcyl.exe: texcyl.obj readtex.obj +texdown.exe: texdown.obj +texenv.exe: texenv.obj +texobj.exe: texobj.obj +trispd.exe: trispd.obj +tunnel.exe: tunnel.obj readtex.obj +tunnel2.exe: tunnel2.obj readtex.obj +winpos.exe: winpos.obj readtex.obj + + +OPENGL32.DLL: $(LIBDIR)\OPENGL32.DLL + copy $? . + +GLU32.DLL: $(LIBDIR)\GLU32.DLL + copy $? . + +GLUT32.DLL: $(LIBDIR)\GLUT32.DLL + copy $? . + +readtex.c: $(TOP)\progs\util\readtex.c + copy $** . + +readtex.h: $(TOP)\progs\util\readtex.h + copy $** . + +showbuffer.c: $(TOP)\progs\util\showbuffer.c + copy $** . + +showbuffer.h: $(TOP)\progs\util\showbuffer.h + copy $** . + +.obj.exe: + $(link) $(ldebug) -out:$@ $** /LIBPATH:$(LIBDIR) $(LIBS) + +.c.obj: + $(cc) $(cdebug) $(cflags) $(cvars) /I$(INCDIR) $*.c + +clean:: + del *.obj *.exe readtex.* showbuffer.* + +clobber:: + diff --git a/progs/demos/README b/progs/demos/README new file mode 100644 index 00000000000..a3d0c18bb97 --- /dev/null +++ b/progs/demos/README @@ -0,0 +1,230 @@ +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). diff --git a/progs/demos/Windows/all.dsp b/progs/demos/Windows/all.dsp new file mode 100644 index 00000000000..b47283c5882 --- /dev/null +++ b/progs/demos/Windows/all.dsp @@ -0,0 +1,101 @@ +# Microsoft Developer Studio Project File - Name="all" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Application" 0x0101 + +CFG=all - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "all.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "all.mak" CFG="all - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "all - Win32 Release" (based on "Win32 (x86) Application") +!MESSAGE "all - Win32 Debug" (based on "Win32 (x86) Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe + +!IF "$(CFG)" == "all - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 + +!ELSEIF "$(CFG)" == "all - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept + +!ENDIF + +# Begin Target + +# Name "all - Win32 Release" +# Name "all - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/progs/demos/Windows/bounce.dsp b/progs/demos/Windows/bounce.dsp new file mode 100644 index 00000000000..0510e77d994 --- /dev/null +++ b/progs/demos/Windows/bounce.dsp @@ -0,0 +1,112 @@ +# Microsoft Developer Studio Project File - Name="bounce" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=bounce - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "bounce.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "bounce.mak" CFG="bounce - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "bounce - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "bounce - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "bounce - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /I "../../../include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../../../lib/GLUT32.LIB ../../../lib/GLU32.LIB ../../../lib/OPENGL32.LIB /nologo /subsystem:console /machine:I386 /out:"../bounce.exe" +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copy DLLs +PostBuild_Cmds=copy ..\..\..\lib\*.dll .. +# End Special Build Tool + +!ELSEIF "$(CFG)" == "bounce - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../../../include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../../../lib/GLUT32.LIB ../../../lib/GLU32.LIB ../../../lib/OPENGL32.LIB /nologo /subsystem:console /debug /machine:I386 /out:"../bounce.exe" /pdbtype:sept +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copy DLLs +PostBuild_Cmds=copy ..\..\..\lib\*.dll .. +# End Special Build Tool + +!ENDIF + +# Begin Target + +# Name "bounce - Win32 Release" +# Name "bounce - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=..\bounce.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/progs/demos/Windows/clearspd.dsp b/progs/demos/Windows/clearspd.dsp new file mode 100644 index 00000000000..440c7ae64e9 --- /dev/null +++ b/progs/demos/Windows/clearspd.dsp @@ -0,0 +1,112 @@ +# Microsoft Developer Studio Project File - Name="clearspd" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=clearspd - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "clearspd.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "clearspd.mak" CFG="clearspd - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "clearspd - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "clearspd - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "clearspd - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /I "../../../include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../../../lib/GLUT32.LIB ../../../lib/GLU32.LIB ../../../lib/OPENGL32.LIB /nologo /subsystem:console /machine:I386 /out:"../clearspd.exe" +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copy DLLs +PostBuild_Cmds=copy ..\..\..\lib\*.dll .. +# End Special Build Tool + +!ELSEIF "$(CFG)" == "clearspd - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../../../include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../../../lib/GLUT32.LIB ../../../lib/GLU32.LIB ../../../lib/OPENGL32.LIB /nologo /subsystem:console /debug /machine:I386 /out:"../clearspd.exe" /pdbtype:sept +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copy DLLs +PostBuild_Cmds=copy ..\..\..\lib\*.dll .. +# End Special Build Tool + +!ENDIF + +# Begin Target + +# Name "clearspd - Win32 Release" +# Name "clearspd - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=..\clearspd.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/progs/demos/Windows/cubemap.dsp b/progs/demos/Windows/cubemap.dsp new file mode 100644 index 00000000000..220a3a0df61 --- /dev/null +++ b/progs/demos/Windows/cubemap.dsp @@ -0,0 +1,112 @@ +# Microsoft Developer Studio Project File - Name="cubemap" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=cubemap - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "cubemap.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "cubemap.mak" CFG="cubemap - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "cubemap - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "cubemap - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "cubemap - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /I "../../../include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../../../lib/GLUT32.LIB ../../../lib/GLU32.LIB ../../../lib/OPENGL32.LIB /nologo /subsystem:console /machine:I386 /out:"../cubemap.exe" +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copy DLLs +PostBuild_Cmds=copy ..\..\..\lib\*.dll .. +# End Special Build Tool + +!ELSEIF "$(CFG)" == "cubemap - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../../../include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../../../lib/GLUT32.LIB ../../../lib/GLU32.LIB ../../../lib/OPENGL32.LIB /nologo /subsystem:console /debug /machine:I386 /out:"../cubemap.exe" /pdbtype:sept +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copy DLLs +PostBuild_Cmds=copy ..\..\..\lib\*.dll .. +# End Special Build Tool + +!ENDIF + +# Begin Target + +# Name "cubemap - Win32 Release" +# Name "cubemap - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=..\cubemap.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/progs/demos/Windows/demos.dsw b/progs/demos/Windows/demos.dsw new file mode 100644 index 00000000000..2d6f629e07a --- /dev/null +++ b/progs/demos/Windows/demos.dsw @@ -0,0 +1,782 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00 +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! + +############################################################################### + +Project: "all"=".\all.dsp" - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ + Begin Project Dependency + Project_Dep_Name bounce + End Project Dependency + Begin Project Dependency + Project_Dep_Name clearspd + End Project Dependency + Begin Project Dependency + Project_Dep_Name cubemap + End Project Dependency + Begin Project Dependency + Project_Dep_Name drawpix + End Project Dependency + Begin Project Dependency + Project_Dep_Name fire + End Project Dependency + Begin Project Dependency + Project_Dep_Name gears + End Project Dependency + Begin Project Dependency + Project_Dep_Name geartrain + End Project Dependency + Begin Project Dependency + Project_Dep_Name glinfo + End Project Dependency + Begin Project Dependency + Project_Dep_Name gloss + End Project Dependency + Begin Project Dependency + Project_Dep_Name gltestperf + End Project Dependency + Begin Project Dependency + Project_Dep_Name glutfx + End Project Dependency + Begin Project Dependency + Project_Dep_Name ipers + End Project Dependency + Begin Project Dependency + Project_Dep_Name isosurf + End Project Dependency + Begin Project Dependency + Project_Dep_Name lodbias + End Project Dependency + Begin Project Dependency + Project_Dep_Name morph3d + End Project Dependency + Begin Project Dependency + Project_Dep_Name multiarb + End Project Dependency + Begin Project Dependency + Project_Dep_Name occlude + End Project Dependency + Begin Project Dependency + Project_Dep_Name osdemo + End Project Dependency + Begin Project Dependency + Project_Dep_Name paltex + End Project Dependency + Begin Project Dependency + Project_Dep_Name pixeltex + End Project Dependency + Begin Project Dependency + Project_Dep_Name pointblast + End Project Dependency + Begin Project Dependency + Project_Dep_Name rain + End Project Dependency + Begin Project Dependency + Project_Dep_Name ray + End Project Dependency + Begin Project Dependency + Project_Dep_Name readpix + End Project Dependency + Begin Project Dependency + Project_Dep_Name reflect + End Project Dependency + Begin Project Dependency + Project_Dep_Name renormal + End Project Dependency + Begin Project Dependency + Project_Dep_Name shadowtex + End Project Dependency + Begin Project Dependency + Project_Dep_Name spectex + End Project Dependency + Begin Project Dependency + Project_Dep_Name stex3d + End Project Dependency + Begin Project Dependency + Project_Dep_Name teapot + End Project Dependency + Begin Project Dependency + Project_Dep_Name terrain + End Project Dependency + Begin Project Dependency + Project_Dep_Name tessdemo + End Project Dependency + Begin Project Dependency + Project_Dep_Name texcyl + End Project Dependency + Begin Project Dependency + Project_Dep_Name texdown + End Project Dependency + Begin Project Dependency + Project_Dep_Name texenv + End Project Dependency + Begin Project Dependency + Project_Dep_Name texobj + End Project Dependency + Begin Project Dependency + Project_Dep_Name trispd + End Project Dependency + Begin Project Dependency + Project_Dep_Name tunnel + End Project Dependency + Begin Project Dependency + Project_Dep_Name tunnel2 + End Project Dependency + Begin Project Dependency + Project_Dep_Name winpos + End Project Dependency + Begin Project Dependency + Project_Dep_Name spriteblast + End Project Dependency + Begin Project Dependency + Project_Dep_Name glut + End Project Dependency +}}} + +############################################################################### + +Project: "bounce"=".\bounce.dsp" - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ + Begin Project Dependency + Project_Dep_Name glut + End Project Dependency +}}} + +############################################################################### + +Project: "clearspd"=".\clearspd.dsp" - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ + Begin Project Dependency + Project_Dep_Name glut + End Project Dependency +}}} + +############################################################################### + +Project: "cubemap"=".\cubemap.dsp" - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ + Begin Project Dependency + Project_Dep_Name glut + End Project Dependency +}}} + +############################################################################### + +Project: "drawpix"=".\drawpix.dsp" - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ + Begin Project Dependency + Project_Dep_Name glut + End Project Dependency +}}} + +############################################################################### + +Project: "fire"=".\fire.dsp" - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ + Begin Project Dependency + Project_Dep_Name glut + End Project Dependency +}}} + +############################################################################### + +Project: "gears"=".\gears.dsp" - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ + Begin Project Dependency + Project_Dep_Name glut + End Project Dependency +}}} + +############################################################################### + +Project: "geartrain"=".\geartrain.dsp" - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ + Begin Project Dependency + Project_Dep_Name glut + End Project Dependency +}}} + +############################################################################### + +Project: "glinfo"=".\glinfo.dsp" - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ + Begin Project Dependency + Project_Dep_Name glut + End Project Dependency +}}} + +############################################################################### + +Project: "gloss"=".\gloss.dsp" - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ + Begin Project Dependency + Project_Dep_Name glut + End Project Dependency +}}} + +############################################################################### + +Project: "gltestperf"=".\gltestperf.dsp" - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ + Begin Project Dependency + Project_Dep_Name glut + End Project Dependency +}}} + +############################################################################### + +Project: "glut"="..\..\..\src\glut\glx\glut.dsp" - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Project: "glutfx"=".\glutfx.dsp" - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ + Begin Project Dependency + Project_Dep_Name glut + End Project Dependency +}}} + +############################################################################### + +Project: "ipers"=".\ipers.dsp" - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ + Begin Project Dependency + Project_Dep_Name glut + End Project Dependency +}}} + +############################################################################### + +Project: "isosurf"=".\isosurf.dsp" - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ + Begin Project Dependency + Project_Dep_Name glut + End Project Dependency +}}} + +############################################################################### + +Project: "lodbias"=".\loadbias.dsp" - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ + Begin Project Dependency + Project_Dep_Name glut + End Project Dependency +}}} + +############################################################################### + +Project: "morph3d"=".\morph3d.dsp" - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ + Begin Project Dependency + Project_Dep_Name glut + End Project Dependency +}}} + +############################################################################### + +Project: "multiarb"=".\multiarb.dsp" - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ + Begin Project Dependency + Project_Dep_Name glut + End Project Dependency +}}} + +############################################################################### + +Project: "occlude"=".\occlude.dsp" - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ + Begin Project Dependency + Project_Dep_Name glut + End Project Dependency +}}} + +############################################################################### + +Project: "osdemo"=".\osdemo.dsp" - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ + Begin Project Dependency + Project_Dep_Name glut + End Project Dependency +}}} + +############################################################################### + +Project: "paltex"=".\paltex.dsp" - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ + Begin Project Dependency + Project_Dep_Name glut + End Project Dependency +}}} + +############################################################################### + +Project: "pixeltex"=".\pixeltex.dsp" - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ + Begin Project Dependency + Project_Dep_Name glut + End Project Dependency +}}} + +############################################################################### + +Project: "pointblast"=".\pointblast.dsp" - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ + Begin Project Dependency + Project_Dep_Name glut + End Project Dependency +}}} + +############################################################################### + +Project: "rain"=".\rain.dsp" - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ + Begin Project Dependency + Project_Dep_Name glut + End Project Dependency +}}} + +############################################################################### + +Project: "ray"=".\ray.dsp" - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ + Begin Project Dependency + Project_Dep_Name glut + End Project Dependency +}}} + +############################################################################### + +Project: "readpix"=".\readpix.dsp" - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ + Begin Project Dependency + Project_Dep_Name glut + End Project Dependency +}}} + +############################################################################### + +Project: "reflect"=".\reflect.dsp" - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ + Begin Project Dependency + Project_Dep_Name glut + End Project Dependency +}}} + +############################################################################### + +Project: "renormal"=".\renormal.dsp" - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ + Begin Project Dependency + Project_Dep_Name glut + End Project Dependency +}}} + +############################################################################### + +Project: "shadowtex"=".\shadowtex.dsp" - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ + Begin Project Dependency + Project_Dep_Name glut + End Project Dependency +}}} + +############################################################################### + +Project: "spectex"=".\spectex.dsp" - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ + Begin Project Dependency + Project_Dep_Name glut + End Project Dependency +}}} + +############################################################################### + +Project: "spriteblast"=".\spriteblast.dsp" - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ + Begin Project Dependency + Project_Dep_Name glut + End Project Dependency +}}} + +############################################################################### + +Project: "stex3d"=".\stex3d.dsp" - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ + Begin Project Dependency + Project_Dep_Name glut + End Project Dependency +}}} + +############################################################################### + +Project: "teapot"=".\teapot.dsp" - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ + Begin Project Dependency + Project_Dep_Name glut + End Project Dependency +}}} + +############################################################################### + +Project: "terrain"=".\terrain.dsp" - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ + Begin Project Dependency + Project_Dep_Name glut + End Project Dependency +}}} + +############################################################################### + +Project: "tessdemo"=".\tessdemo.dsp" - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ + Begin Project Dependency + Project_Dep_Name glut + End Project Dependency +}}} + +############################################################################### + +Project: "texcyl"=".\texcyl.dsp" - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ + Begin Project Dependency + Project_Dep_Name glut + End Project Dependency +}}} + +############################################################################### + +Project: "texdown"=".\texdown.dsp" - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ + Begin Project Dependency + Project_Dep_Name glut + End Project Dependency +}}} + +############################################################################### + +Project: "texenv"=".\texenv.dsp" - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ + Begin Project Dependency + Project_Dep_Name glut + End Project Dependency +}}} + +############################################################################### + +Project: "texobj"=".\texobj.dsp" - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ + Begin Project Dependency + Project_Dep_Name glut + End Project Dependency +}}} + +############################################################################### + +Project: "trispd"=".\trispd.dsp" - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ + Begin Project Dependency + Project_Dep_Name glut + End Project Dependency +}}} + +############################################################################### + +Project: "tunnel"=".\tunnel.dsp" - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ + Begin Project Dependency + Project_Dep_Name glut + End Project Dependency +}}} + +############################################################################### + +Project: "tunnel2"=".\tunnel2.dsp" - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ + Begin Project Dependency + Project_Dep_Name glut + End Project Dependency +}}} + +############################################################################### + +Project: "winpos"=".\winpos.dsp" - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ + Begin Project Dependency + Project_Dep_Name glut + End Project Dependency +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/progs/demos/Windows/drawpix.dsp b/progs/demos/Windows/drawpix.dsp new file mode 100644 index 00000000000..57003e616b4 --- /dev/null +++ b/progs/demos/Windows/drawpix.dsp @@ -0,0 +1,112 @@ +# Microsoft Developer Studio Project File - Name="drawpix" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=drawpix - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "drawpix.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "drawpix.mak" CFG="drawpix - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "drawpix - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "drawpix - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "drawpix - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /I "../" /I "../../../include" /I "../../util" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../../../lib/GLUT32.LIB ../../../lib/GLU32.LIB ../../../lib/OPENGL32.LIB /nologo /subsystem:console /machine:I386 /out:"../drawpix.exe" +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copy DLLs +PostBuild_Cmds=copy ..\..\..\lib\*.dll .. +# End Special Build Tool + +!ELSEIF "$(CFG)" == "drawpix - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../../util" /I "../../../include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../../../lib/GLUT32.LIB ../../../lib/GLU32.LIB ../../../lib/OPENGL32.LIB /nologo /subsystem:console /debug /machine:I386 /out:"../drawpix.exe" /pdbtype:sept +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copy DLLs +PostBuild_Cmds=copy ..\..\..\lib\*.dll .. +# End Special Build Tool + +!ENDIF + +# Begin Target + +# Name "drawpix - Win32 Release" +# Name "drawpix - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=..\drawpix.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/progs/demos/Windows/fire.dsp b/progs/demos/Windows/fire.dsp new file mode 100644 index 00000000000..f8a536d3349 --- /dev/null +++ b/progs/demos/Windows/fire.dsp @@ -0,0 +1,112 @@ +# Microsoft Developer Studio Project File - Name="fire" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=fire - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "fire.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "fire.mak" CFG="fire - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "fire - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "fire - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "fire - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /I "../../util" /I "../../../include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../../../lib/GLUT32.LIB ../../../lib/GLU32.LIB ../../../lib/OPENGL32.LIB /nologo /subsystem:console /machine:I386 /out:"../fire.exe" +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copy DLLs +PostBuild_Cmds=copy ..\..\..\lib\*.dll .. +# End Special Build Tool + +!ELSEIF "$(CFG)" == "fire - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../../util" /I "../../../include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../../../lib/GLUT32.LIB ../../../lib/GLU32.LIB ../../../lib/OPENGL32.LIB /nologo /subsystem:console /debug /machine:I386 /out:"../fire.exe" /pdbtype:sept +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copy DLLs +PostBuild_Cmds=copy ..\..\..\lib\*.dll .. +# End Special Build Tool + +!ENDIF + +# Begin Target + +# Name "fire - Win32 Release" +# Name "fire - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=..\fire.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/progs/demos/Windows/gears.dsp b/progs/demos/Windows/gears.dsp new file mode 100644 index 00000000000..43a588dc68d --- /dev/null +++ b/progs/demos/Windows/gears.dsp @@ -0,0 +1,112 @@ +# Microsoft Developer Studio Project File - Name="gears" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=gears - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "gears.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "gears.mak" CFG="gears - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "gears - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "gears - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "gears - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /I "../../../include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../../../lib/GLUT32.LIB ../../../lib/GLU32.LIB ../../../lib/OPENGL32.LIB /nologo /subsystem:console /machine:I386 /out:"../gears.exe" +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copy DLLs +PostBuild_Cmds=copy ..\..\..\lib\*.dll .. +# End Special Build Tool + +!ELSEIF "$(CFG)" == "gears - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../../../include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../../../lib/GLUT32.LIB ../../../lib/GLU32.LIB ../../../lib/OPENGL32.LIB /nologo /subsystem:console /debug /machine:I386 /out:"../gears.exe" /pdbtype:sept +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copy DLLs +PostBuild_Cmds=copy ..\..\..\lib\*.dll .. +# End Special Build Tool + +!ENDIF + +# Begin Target + +# Name "gears - Win32 Release" +# Name "gears - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=..\gears.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/progs/demos/Windows/geartrain.dsp b/progs/demos/Windows/geartrain.dsp new file mode 100644 index 00000000000..8dee77de4d5 --- /dev/null +++ b/progs/demos/Windows/geartrain.dsp @@ -0,0 +1,112 @@ +# Microsoft Developer Studio Project File - Name="geartrain" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=geartrain - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "geartrain.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "geartrain.mak" CFG="geartrain - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "geartrain - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "geartrain - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "geartrain - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /I "../../../include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../../../lib/GLUT32.LIB ../../../lib/GLU32.LIB ../../../lib/OPENGL32.LIB /nologo /subsystem:console /machine:I386 /out:"../geartrain.exe" +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copy DLLs +PostBuild_Cmds=copy ..\..\..\lib\*.dll .. +# End Special Build Tool + +!ELSEIF "$(CFG)" == "geartrain - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../../../include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../../../lib/GLUT32.LIB ../../../lib/GLU32.LIB ../../../lib/OPENGL32.LIB /nologo /subsystem:console /debug /machine:I386 /out:"../geartrain.exe" /pdbtype:sept +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copy DLLs +PostBuild_Cmds=copy ..\..\..\lib\*.dll .. +# End Special Build Tool + +!ENDIF + +# Begin Target + +# Name "geartrain - Win32 Release" +# Name "geartrain - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=..\geartrain.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/progs/demos/Windows/glinfo.dsp b/progs/demos/Windows/glinfo.dsp new file mode 100644 index 00000000000..d9d61eb424d --- /dev/null +++ b/progs/demos/Windows/glinfo.dsp @@ -0,0 +1,112 @@ +# Microsoft Developer Studio Project File - Name="glinfo" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=glinfo - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "glinfo.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "glinfo.mak" CFG="glinfo - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "glinfo - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "glinfo - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "glinfo - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /I "../../../include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../../../lib/GLUT32.LIB ../../../lib/GLU32.LIB ../../../lib/OPENGL32.LIB /nologo /subsystem:console /machine:I386 /out:"../glinfo.exe" +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copy DLLs +PostBuild_Cmds=copy ..\..\..\lib\*.dll .. +# End Special Build Tool + +!ELSEIF "$(CFG)" == "glinfo - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../../../include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../../../lib/GLUT32.LIB ../../../lib/GLU32.LIB ../../../lib/OPENGL32.LIB /nologo /subsystem:console /debug /machine:I386 /out:"../glinfo.exe" /pdbtype:sept +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copy DLLs +PostBuild_Cmds=copy ..\..\..\lib\*.dll .. +# End Special Build Tool + +!ENDIF + +# Begin Target + +# Name "glinfo - Win32 Release" +# Name "glinfo - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=..\glinfo.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/progs/demos/Windows/gloss.dsp b/progs/demos/Windows/gloss.dsp new file mode 100644 index 00000000000..402d291f4dc --- /dev/null +++ b/progs/demos/Windows/gloss.dsp @@ -0,0 +1,112 @@ +# Microsoft Developer Studio Project File - Name="gloss" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=gloss - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "gloss.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "gloss.mak" CFG="gloss - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "gloss - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "gloss - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "gloss - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /I "../../util" /I "../../../include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../../../lib/GLUT32.LIB ../../../lib/GLU32.LIB ../../../lib/OPENGL32.LIB /nologo /subsystem:console /machine:I386 /out:"../gloss.exe" +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copy DLLs +PostBuild_Cmds=copy ..\..\..\lib\*.dll .. +# End Special Build Tool + +!ELSEIF "$(CFG)" == "gloss - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../../util" /I "../../../include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../../../lib/GLUT32.LIB ../../../lib/GLU32.LIB ../../../lib/OPENGL32.LIB /nologo /subsystem:console /debug /machine:I386 /out:"../gloss.exe" /pdbtype:sept +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copy DLLs +PostBuild_Cmds=copy ..\..\..\lib\*.dll .. +# End Special Build Tool + +!ENDIF + +# Begin Target + +# Name "gloss - Win32 Release" +# Name "gloss - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=..\gloss.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/progs/demos/Windows/gltestperf.dsp b/progs/demos/Windows/gltestperf.dsp new file mode 100644 index 00000000000..e5066201522 --- /dev/null +++ b/progs/demos/Windows/gltestperf.dsp @@ -0,0 +1,112 @@ +# Microsoft Developer Studio Project File - Name="gltestperf" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=gltestperf - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "gltestperf.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "gltestperf.mak" CFG="gltestperf - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "gltestperf - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "gltestperf - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "gltestperf - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /I "../../../include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../../../lib/GLUT32.LIB ../../../lib/GLU32.LIB ../../../lib/OPENGL32.LIB /nologo /subsystem:console /machine:I386 /out:"../gltestperf.exe" +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copy DLLs +PostBuild_Cmds=copy ..\..\..\lib\*.dll .. +# End Special Build Tool + +!ELSEIF "$(CFG)" == "gltestperf - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../../../include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../../../lib/GLUT32.LIB ../../../lib/GLU32.LIB ../../../lib/OPENGL32.LIB /nologo /subsystem:console /debug /machine:I386 /out:"../gltestperf.exe" /pdbtype:sept +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copy DLLs +PostBuild_Cmds=copy ..\..\..\lib\*.dll .. +# End Special Build Tool + +!ENDIF + +# Begin Target + +# Name "gltestperf - Win32 Release" +# Name "gltestperf - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=..\gltestperf.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/progs/demos/Windows/glutfx.dsp b/progs/demos/Windows/glutfx.dsp new file mode 100644 index 00000000000..90eca930d22 --- /dev/null +++ b/progs/demos/Windows/glutfx.dsp @@ -0,0 +1,112 @@ +# Microsoft Developer Studio Project File - Name="glutfx" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=glutfx - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "glutfx.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "glutfx.mak" CFG="glutfx - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "glutfx - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "glutfx - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "glutfx - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /I "../../../include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../../../lib/GLUT32.LIB ../../../lib/GLU32.LIB ../../../lib/OPENGL32.LIB /nologo /subsystem:console /machine:I386 /out:"../glutfx.exe" +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copy DLLs +PostBuild_Cmds=copy ..\..\..\lib\*.dll .. +# End Special Build Tool + +!ELSEIF "$(CFG)" == "glutfx - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../../../include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../../../lib/GLUT32.LIB ../../../lib/GLU32.LIB ../../../lib/OPENGL32.LIB /nologo /subsystem:console /debug /machine:I386 /out:"../glutfx.exe" /pdbtype:sept +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copy DLLs +PostBuild_Cmds=copy ..\..\..\lib\*.dll .. +# End Special Build Tool + +!ENDIF + +# Begin Target + +# Name "glutfx - Win32 Release" +# Name "glutfx - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=..\glutfx.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/progs/demos/Windows/ipers.dsp b/progs/demos/Windows/ipers.dsp new file mode 100644 index 00000000000..430f1b6258d --- /dev/null +++ b/progs/demos/Windows/ipers.dsp @@ -0,0 +1,112 @@ +# Microsoft Developer Studio Project File - Name="ipers" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=ipers - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "ipers.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "ipers.mak" CFG="ipers - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "ipers - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "ipers - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "ipers - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /I "../../util" /I "../../../include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../../../lib/GLUT32.LIB ../../../lib/GLU32.LIB ../../../lib/OPENGL32.LIB /nologo /subsystem:console /machine:I386 /out:"../ipers.exe" +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copy DLLs +PostBuild_Cmds=copy ..\..\..\lib\*.dll .. +# End Special Build Tool + +!ELSEIF "$(CFG)" == "ipers - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../../util" /I "../../../include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../../../lib/GLUT32.LIB ../../../lib/GLU32.LIB ../../../lib/OPENGL32.LIB /nologo /subsystem:console /debug /machine:I386 /out:"../ipers.exe" /pdbtype:sept +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copy DLLs +PostBuild_Cmds=copy ..\..\..\lib\*.dll .. +# End Special Build Tool + +!ENDIF + +# Begin Target + +# Name "ipers - Win32 Release" +# Name "ipers - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=..\ipers.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/progs/demos/Windows/isosurf.dsp b/progs/demos/Windows/isosurf.dsp new file mode 100644 index 00000000000..1c59d40081e --- /dev/null +++ b/progs/demos/Windows/isosurf.dsp @@ -0,0 +1,112 @@ +# Microsoft Developer Studio Project File - Name="isosurf" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=isosurf - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "isosurf.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "isosurf.mak" CFG="isosurf - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "isosurf - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "isosurf - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "isosurf - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /I "../../util" /I "../../../include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../../../lib/GLUT32.LIB ../../../lib/GLU32.LIB ../../../lib/OPENGL32.LIB /nologo /subsystem:console /machine:I386 /out:"../isosurf.exe" +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copy DLLs +PostBuild_Cmds=copy ..\..\..\lib\*.dll .. +# End Special Build Tool + +!ELSEIF "$(CFG)" == "isosurf - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../../util" /I "../../../include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../../../lib/GLUT32.LIB ../../../lib/GLU32.LIB ../../../lib/OPENGL32.LIB /nologo /subsystem:console /debug /machine:I386 /out:"../isosurf.exe" /pdbtype:sept +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copy DLLs +PostBuild_Cmds=copy ..\..\..\lib\*.dll .. +# End Special Build Tool + +!ENDIF + +# Begin Target + +# Name "isosurf - Win32 Release" +# Name "isosurf - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=..\isosurf.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/progs/demos/Windows/loadbias.dsp b/progs/demos/Windows/loadbias.dsp new file mode 100644 index 00000000000..ed51960e493 --- /dev/null +++ b/progs/demos/Windows/loadbias.dsp @@ -0,0 +1,112 @@ +# Microsoft Developer Studio Project File - Name="lodbias" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=lodbias - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "lodbias.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "lodbias.mak" CFG="lodbias - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "lodbias - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "lodbias - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "lodbias - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /I "../../util" /I "../../../include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../../../lib/GLUT32.LIB ../../../lib/GLU32.LIB ../../../lib/OPENGL32.LIB /nologo /subsystem:console /machine:I386 /out:"../lodbias.exe" +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copy DLLs +PostBuild_Cmds=copy ..\..\..\lib\*.dll .. +# End Special Build Tool + +!ELSEIF "$(CFG)" == "lodbias - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../../util" /I "../../../include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../../../lib/GLUT32.LIB ../../../lib/GLU32.LIB ../../../lib/OPENGL32.LIB /nologo /subsystem:console /debug /machine:I386 /out:"../lodbias.exe" /pdbtype:sept +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copy DLLs +PostBuild_Cmds=copy ..\..\..\lib\*.dll .. +# End Special Build Tool + +!ENDIF + +# Begin Target + +# Name "lodbias - Win32 Release" +# Name "lodbias - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=..\lodbias.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/progs/demos/Windows/morph3d.dsp b/progs/demos/Windows/morph3d.dsp new file mode 100644 index 00000000000..247dbf03d7a --- /dev/null +++ b/progs/demos/Windows/morph3d.dsp @@ -0,0 +1,112 @@ +# Microsoft Developer Studio Project File - Name="morph3d" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=morph3d - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "morph3d.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "morph3d.mak" CFG="morph3d - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "morph3d - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "morph3d - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "morph3d - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /I "../../../include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../../../lib/GLUT32.LIB ../../../lib/GLU32.LIB ../../../lib/OPENGL32.LIB /nologo /subsystem:console /machine:I386 /out:"../morph3d.exe" +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copy DLLs +PostBuild_Cmds=copy ..\..\..\lib\*.dll .. +# End Special Build Tool + +!ELSEIF "$(CFG)" == "morph3d - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../../../include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../../../lib/GLUT32.LIB ../../../lib/GLU32.LIB ../../../lib/OPENGL32.LIB /nologo /subsystem:console /debug /machine:I386 /out:"../morph3d.exe" /pdbtype:sept +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copy DLLs +PostBuild_Cmds=copy ..\..\..\lib\*.dll .. +# End Special Build Tool + +!ENDIF + +# Begin Target + +# Name "morph3d - Win32 Release" +# Name "morph3d - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=..\morph3d.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/progs/demos/Windows/multiarb.dsp b/progs/demos/Windows/multiarb.dsp new file mode 100644 index 00000000000..57c32deb294 --- /dev/null +++ b/progs/demos/Windows/multiarb.dsp @@ -0,0 +1,112 @@ +# Microsoft Developer Studio Project File - Name="multiarb" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=multiarb - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "multiarb.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "multiarb.mak" CFG="multiarb - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "multiarb - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "multiarb - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "multiarb - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /I "../../util" /I "../../../include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../../../lib/GLUT32.LIB ../../../lib/GLU32.LIB ../../../lib/OPENGL32.LIB /nologo /subsystem:console /machine:I386 /out:"../multiarb.exe" +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copy DLLs +PostBuild_Cmds=copy ..\..\..\lib\*.dll .. +# End Special Build Tool + +!ELSEIF "$(CFG)" == "multiarb - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../../util" /I "../../../include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../../../lib/GLUT32.LIB ../../../lib/GLU32.LIB ../../../lib/OPENGL32.LIB /nologo /subsystem:console /debug /machine:I386 /out:"../multiarb.exe" /pdbtype:sept +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copy DLLs +PostBuild_Cmds=copy ..\..\..\lib\*.dll .. +# End Special Build Tool + +!ENDIF + +# Begin Target + +# Name "multiarb - Win32 Release" +# Name "multiarb - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=..\multiarb.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/progs/demos/Windows/occlude.dsp b/progs/demos/Windows/occlude.dsp new file mode 100644 index 00000000000..ca4afa579e1 --- /dev/null +++ b/progs/demos/Windows/occlude.dsp @@ -0,0 +1,112 @@ +# Microsoft Developer Studio Project File - Name="occlude" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=occlude - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "occlude.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "occlude.mak" CFG="occlude - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "occlude - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "occlude - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "occlude - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /I "../../../include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../../../lib/GLUT32.LIB ../../../lib/GLU32.LIB ../../../lib/OPENGL32.LIB /nologo /subsystem:console /machine:I386 /out:"../occlude.exe" +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copy DLLs +PostBuild_Cmds=copy ..\..\..\lib\*.dll .. +# End Special Build Tool + +!ELSEIF "$(CFG)" == "occlude - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../../../include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../../../lib/GLUT32.LIB ../../../lib/GLU32.LIB ../../../lib/OPENGL32.LIB /nologo /subsystem:console /debug /machine:I386 /out:"../occlude.exe" /pdbtype:sept +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copy DLLs +PostBuild_Cmds=copy ..\..\..\lib\*.dll .. +# End Special Build Tool + +!ENDIF + +# Begin Target + +# Name "occlude - Win32 Release" +# Name "occlude - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=..\occlude.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/progs/demos/Windows/osdemo.dsp b/progs/demos/Windows/osdemo.dsp new file mode 100644 index 00000000000..ccaa6d2b42a --- /dev/null +++ b/progs/demos/Windows/osdemo.dsp @@ -0,0 +1,112 @@ +# Microsoft Developer Studio Project File - Name="osdemo" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=osdemo - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "osdemo.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "osdemo.mak" CFG="osdemo - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "osdemo - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "osdemo - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "osdemo - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /I "../../../include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../../../lib/GLUT32.LIB ../../../lib/GLU32.LIB ../../../lib/OPENGL32.LIB ../../../lib/OSMESA32.LIB /nologo /subsystem:console /machine:I386 /out:"../osdemo.exe" +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copy DLLs +PostBuild_Cmds=copy ..\..\..\lib\*.dll .. +# End Special Build Tool + +!ELSEIF "$(CFG)" == "osdemo - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../../../include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../../../lib/GLUT32.LIB ../../../lib/GLU32.LIB ../../../lib/OPENGL32.LIB ../../../lib/OSMESA32.LIB /nologo /subsystem:console /debug /machine:I386 /out:"../osdemo.exe" /pdbtype:sept +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copy DLLs +PostBuild_Cmds=copy ..\..\..\lib\*.dll .. +# End Special Build Tool + +!ENDIF + +# Begin Target + +# Name "osdemo - Win32 Release" +# Name "osdemo - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=..\osdemo.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/progs/demos/Windows/paltex.dsp b/progs/demos/Windows/paltex.dsp new file mode 100644 index 00000000000..efc63842115 --- /dev/null +++ b/progs/demos/Windows/paltex.dsp @@ -0,0 +1,112 @@ +# Microsoft Developer Studio Project File - Name="paltex" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=paltex - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "paltex.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "paltex.mak" CFG="paltex - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "paltex - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "paltex - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "paltex - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /I "../../../include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../../../lib/GLUT32.LIB ../../../lib/GLU32.LIB ../../../lib/OPENGL32.LIB /nologo /subsystem:console /machine:I386 /out:"../paltex.exe" +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copy DLLs +PostBuild_Cmds=copy ..\..\..\lib\*.dll .. +# End Special Build Tool + +!ELSEIF "$(CFG)" == "paltex - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../../../include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../../../lib/GLUT32.LIB ../../../lib/GLU32.LIB ../../../lib/OPENGL32.LIB /nologo /subsystem:console /debug /machine:I386 /out:"../paltex.exe" /pdbtype:sept +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copy DLLs +PostBuild_Cmds=copy ..\..\..\lib\*.dll .. +# End Special Build Tool + +!ENDIF + +# Begin Target + +# Name "paltex - Win32 Release" +# Name "paltex - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=..\paltex.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/progs/demos/Windows/pixeltex.dsp b/progs/demos/Windows/pixeltex.dsp new file mode 100644 index 00000000000..d09f9f312cb --- /dev/null +++ b/progs/demos/Windows/pixeltex.dsp @@ -0,0 +1,112 @@ +# Microsoft Developer Studio Project File - Name="pixeltex" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=pixeltex - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "pixeltex.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "pixeltex.mak" CFG="pixeltex - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "pixeltex - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "pixeltex - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "pixeltex - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /I "../../util" /I "../../../include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../../../lib/GLUT32.LIB ../../../lib/GLU32.LIB ../../../lib/OPENGL32.LIB /nologo /subsystem:console /machine:I386 /out:"../pixeltex.exe" +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copy DLLs +PostBuild_Cmds=copy ..\..\..\lib\*.dll .. +# End Special Build Tool + +!ELSEIF "$(CFG)" == "pixeltex - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../../util" /I "../../../include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../../../lib/GLUT32.LIB ../../../lib/GLU32.LIB ../../../lib/OPENGL32.LIB /nologo /subsystem:console /debug /machine:I386 /out:"../pixeltex.exe" /pdbtype:sept +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copy DLLs +PostBuild_Cmds=copy ..\..\..\lib\*.dll .. +# End Special Build Tool + +!ENDIF + +# Begin Target + +# Name "pixeltex - Win32 Release" +# Name "pixeltex - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=..\pixeltex.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/progs/demos/Windows/pointblast.dsp b/progs/demos/Windows/pointblast.dsp new file mode 100644 index 00000000000..7be695839fa --- /dev/null +++ b/progs/demos/Windows/pointblast.dsp @@ -0,0 +1,112 @@ +# Microsoft Developer Studio Project File - Name="pointblast" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=pointblast - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "pointblast.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "pointblast.mak" CFG="pointblast - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "pointblast - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "pointblast - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "pointblast - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /I "../../../include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../../../lib/GLUT32.LIB ../../../lib/GLU32.LIB ../../../lib/OPENGL32.LIB /nologo /subsystem:console /machine:I386 /out:"../pointblast.exe" +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copy DLLs +PostBuild_Cmds=copy ..\..\..\lib\*.dll .. +# End Special Build Tool + +!ELSEIF "$(CFG)" == "pointblast - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../../../include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../../../lib/GLUT32.LIB ../../../lib/GLU32.LIB ../../../lib/OPENGL32.LIB /nologo /subsystem:console /debug /machine:I386 /out:"../pointblast.exe" /pdbtype:sept +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copy DLLs +PostBuild_Cmds=copy ..\..\..\lib\*.dll .. +# End Special Build Tool + +!ENDIF + +# Begin Target + +# Name "pointblast - Win32 Release" +# Name "pointblast - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=..\pointblast.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/progs/demos/Windows/rain.dsp b/progs/demos/Windows/rain.dsp new file mode 100644 index 00000000000..7e380e66aaf --- /dev/null +++ b/progs/demos/Windows/rain.dsp @@ -0,0 +1,112 @@ +# Microsoft Developer Studio Project File - Name="rain" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=rain - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "rain.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "rain.mak" CFG="rain - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "rain - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "rain - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "rain - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /I "../../util" /I "../../../include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../../../lib/GLUT32.LIB ../../../lib/GLU32.LIB ../../../lib/OPENGL32.LIB /nologo /subsystem:console /machine:I386 /out:"../rain.exe" +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copy DLLs +PostBuild_Cmds=copy ..\..\..\lib\*.dll .. +# End Special Build Tool + +!ELSEIF "$(CFG)" == "rain - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../../util" /I "../../../include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../../../lib/GLUT32.LIB ../../../lib/GLU32.LIB ../../../lib/OPENGL32.LIB /nologo /subsystem:console /debug /machine:I386 /out:"../rain.exe" /pdbtype:sept +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copy DLLs +PostBuild_Cmds=copy ..\..\..\lib\*.dll .. +# End Special Build Tool + +!ENDIF + +# Begin Target + +# Name "rain - Win32 Release" +# Name "rain - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=..\rain.cxx +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/progs/demos/Windows/ray.dsp b/progs/demos/Windows/ray.dsp new file mode 100644 index 00000000000..dfa26e7755c --- /dev/null +++ b/progs/demos/Windows/ray.dsp @@ -0,0 +1,112 @@ +# Microsoft Developer Studio Project File - Name="ray" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=ray - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "ray.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "ray.mak" CFG="ray - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "ray - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "ray - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "ray - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /I "../../../include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../../../lib/GLUT32.LIB ../../../lib/GLU32.LIB ../../../lib/OPENGL32.LIB /nologo /subsystem:console /machine:I386 /out:"../ray.exe" +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copy DLLs +PostBuild_Cmds=copy ..\..\..\lib\*.dll .. +# End Special Build Tool + +!ELSEIF "$(CFG)" == "ray - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../../../include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../../../lib/GLUT32.LIB ../../../lib/GLU32.LIB ../../../lib/OPENGL32.LIB /nologo /subsystem:console /debug /machine:I386 /out:"../ray.exe" /pdbtype:sept +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copy DLLs +PostBuild_Cmds=copy ..\..\..\lib\*.dll .. +# End Special Build Tool + +!ENDIF + +# Begin Target + +# Name "ray - Win32 Release" +# Name "ray - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=..\ray.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/progs/demos/Windows/readpix.dsp b/progs/demos/Windows/readpix.dsp new file mode 100644 index 00000000000..8097d10625b --- /dev/null +++ b/progs/demos/Windows/readpix.dsp @@ -0,0 +1,112 @@ +# Microsoft Developer Studio Project File - Name="readpix" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=readpix - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "readpix.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "readpix.mak" CFG="readpix - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "readpix - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "readpix - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "readpix - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /I "../../util" /I "../../../include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../../../lib/GLUT32.LIB ../../../lib/GLU32.LIB ../../../lib/OPENGL32.LIB /nologo /subsystem:console /machine:I386 /out:"../readpix.exe" +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copy DLLs +PostBuild_Cmds=copy ..\..\..\lib\*.dll .. +# End Special Build Tool + +!ELSEIF "$(CFG)" == "readpix - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../../util" /I "../../../include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../../../lib/GLUT32.LIB ../../../lib/GLU32.LIB ../../../lib/OPENGL32.LIB /nologo /subsystem:console /debug /machine:I386 /out:"../readpix.exe" /pdbtype:sept +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copy DLLs +PostBuild_Cmds=copy ..\..\..\lib\*.dll .. +# End Special Build Tool + +!ENDIF + +# Begin Target + +# Name "readpix - Win32 Release" +# Name "readpix - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=..\readpix.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/progs/demos/Windows/reflect.dsp b/progs/demos/Windows/reflect.dsp new file mode 100644 index 00000000000..fa09700afe2 --- /dev/null +++ b/progs/demos/Windows/reflect.dsp @@ -0,0 +1,112 @@ +# Microsoft Developer Studio Project File - Name="reflect" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=reflect - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "reflect.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "reflect.mak" CFG="reflect - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "reflect - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "reflect - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "reflect - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /I "../../util" /I "../../../include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../../../lib/GLUT32.LIB ../../../lib/GLU32.LIB ../../../lib/OPENGL32.LIB /nologo /subsystem:console /machine:I386 /out:"../reflect.exe" +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copy DLLs +PostBuild_Cmds=copy ..\..\..\lib\*.dll .. +# End Special Build Tool + +!ELSEIF "$(CFG)" == "reflect - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../../util" /I "../../../include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../../../lib/GLUT32.LIB ../../../lib/GLU32.LIB ../../../lib/OPENGL32.LIB /nologo /subsystem:console /debug /machine:I386 /out:"../reflect.exe" /pdbtype:sept +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copy DLLs +PostBuild_Cmds=copy ..\..\..\lib\*.dll .. +# End Special Build Tool + +!ENDIF + +# Begin Target + +# Name "reflect - Win32 Release" +# Name "reflect - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=..\reflect.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/progs/demos/Windows/renormal.dsp b/progs/demos/Windows/renormal.dsp new file mode 100644 index 00000000000..4d72e88d8ed --- /dev/null +++ b/progs/demos/Windows/renormal.dsp @@ -0,0 +1,112 @@ +# Microsoft Developer Studio Project File - Name="renormal" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=renormal - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "renormal.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "renormal.mak" CFG="bounce - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "renormal - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "renormal - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "renormal - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /I "../../../include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../../../lib/GLUT32.LIB ../../../lib/GLU32.LIB ../../../lib/OPENGL32.LIB /nologo /subsystem:console /machine:I386 /out:"../renormal.exe" +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copy DLLs +PostBuild_Cmds=copy ..\..\..\lib\*.dll .. +# End Special Build Tool + +!ELSEIF "$(CFG)" == "renormal - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../../../include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../../../lib/GLUT32.LIB ../../../lib/GLU32.LIB ../../../lib/OPENGL32.LIB /nologo /subsystem:console /debug /machine:I386 /out:"../renormal.exe" /pdbtype:sept +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copy DLLs +PostBuild_Cmds=copy ..\..\..\lib\*.dll .. +# End Special Build Tool + +!ENDIF + +# Begin Target + +# Name "renormal - Win32 Release" +# Name "renormal - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=..\renormal.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/progs/demos/Windows/shadowtex.dsp b/progs/demos/Windows/shadowtex.dsp new file mode 100644 index 00000000000..419ec241386 --- /dev/null +++ b/progs/demos/Windows/shadowtex.dsp @@ -0,0 +1,112 @@ +# Microsoft Developer Studio Project File - Name="shadowtex" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=shadowtex - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "shadowtex.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "shadowtex.mak" CFG="bounce - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "shadowtex - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "shadowtex - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "shadowtex - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /I "../../../include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../../../lib/GLUT32.LIB ../../../lib/GLU32.LIB ../../../lib/OPENGL32.LIB /nologo /subsystem:console /machine:I386 /out:"../shadowtex.exe" +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copy DLLs +PostBuild_Cmds=copy ..\..\..\lib\*.dll .. +# End Special Build Tool + +!ELSEIF "$(CFG)" == "shadowtex - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../../../include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../../../lib/GLUT32.LIB ../../../lib/GLU32.LIB ../../../lib/OPENGL32.LIB /nologo /subsystem:console /debug /machine:I386 /out:"../shadowtex.exe" /pdbtype:sept +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copy DLLs +PostBuild_Cmds=copy ..\..\..\lib\*.dll .. +# End Special Build Tool + +!ENDIF + +# Begin Target + +# Name "shadowtex - Win32 Release" +# Name "shadowtex - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=..\shadowtex.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/progs/demos/Windows/spectex.dsp b/progs/demos/Windows/spectex.dsp new file mode 100644 index 00000000000..d1960b3d139 --- /dev/null +++ b/progs/demos/Windows/spectex.dsp @@ -0,0 +1,112 @@ +# Microsoft Developer Studio Project File - Name="spectex" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=spectex - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "spectex.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "spectex.mak" CFG="bounce - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "spectex - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "spectex - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "spectex - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /I "../../../include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../../../lib/GLUT32.LIB ../../../lib/GLU32.LIB ../../../lib/OPENGL32.LIB /nologo /subsystem:console /machine:I386 /out:"../spectex.exe" +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copy DLLs +PostBuild_Cmds=copy ..\..\..\lib\*.dll .. +# End Special Build Tool + +!ELSEIF "$(CFG)" == "spectex - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../../../include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../../../lib/GLUT32.LIB ../../../lib/GLU32.LIB ../../../lib/OPENGL32.LIB /nologo /subsystem:console /debug /machine:I386 /out:"../spectex.exe" /pdbtype:sept +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copy DLLs +PostBuild_Cmds=copy ..\..\..\lib\*.dll .. +# End Special Build Tool + +!ENDIF + +# Begin Target + +# Name "spectex - Win32 Release" +# Name "spectex - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=..\spectex.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/progs/demos/Windows/spriteblast.dsp b/progs/demos/Windows/spriteblast.dsp new file mode 100644 index 00000000000..8a02ed50d30 --- /dev/null +++ b/progs/demos/Windows/spriteblast.dsp @@ -0,0 +1,112 @@ +# Microsoft Developer Studio Project File - Name="spriteblast" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=spriteblast - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "spriteblast.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "spriteblast.mak" CFG="bounce - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "spriteblast - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "spriteblast - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "spriteblast - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /I "../../../include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../../../lib/GLUT32.LIB ../../../lib/GLU32.LIB ../../../lib/OPENGL32.LIB /nologo /subsystem:console /machine:I386 /out:"../spriteblast.exe" +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copy DLLs +PostBuild_Cmds=copy ..\..\..\lib\*.dll .. +# End Special Build Tool + +!ELSEIF "$(CFG)" == "spriteblast - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../../../include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../../../lib/GLUT32.LIB ../../../lib/GLU32.LIB ../../../lib/OPENGL32.LIB /nologo /subsystem:console /debug /machine:I386 /out:"../spriteblast.exe" /pdbtype:sept +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copy DLLs +PostBuild_Cmds=copy ..\..\..\lib\*.dll .. +# End Special Build Tool + +!ENDIF + +# Begin Target + +# Name "spriteblast - Win32 Release" +# Name "spriteblast - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=..\spriteblast.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/progs/demos/Windows/stex3d.dsp b/progs/demos/Windows/stex3d.dsp new file mode 100644 index 00000000000..7c112d62ca8 --- /dev/null +++ b/progs/demos/Windows/stex3d.dsp @@ -0,0 +1,112 @@ +# Microsoft Developer Studio Project File - Name="stex3d" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=stex3d - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "stex3d.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "stex3d.mak" CFG="bounce - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "stex3d - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "stex3d - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "stex3d - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /I "../../../include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../../../lib/GLUT32.LIB ../../../lib/GLU32.LIB ../../../lib/OPENGL32.LIB /nologo /subsystem:console /machine:I386 /out:"../stex3d.exe" +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copy DLLs +PostBuild_Cmds=copy ..\..\..\lib\*.dll .. +# End Special Build Tool + +!ELSEIF "$(CFG)" == "stex3d - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../../../include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../../../lib/GLUT32.LIB ../../../lib/GLU32.LIB ../../../lib/OPENGL32.LIB /nologo /subsystem:console /debug /machine:I386 /out:"../stex3d.exe" /pdbtype:sept +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copy DLLs +PostBuild_Cmds=copy ..\..\..\lib\*.dll .. +# End Special Build Tool + +!ENDIF + +# Begin Target + +# Name "stex3d - Win32 Release" +# Name "stex3d - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=..\stex3d.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/progs/demos/Windows/teapot.dsp b/progs/demos/Windows/teapot.dsp new file mode 100644 index 00000000000..3260e635a4b --- /dev/null +++ b/progs/demos/Windows/teapot.dsp @@ -0,0 +1,112 @@ +# Microsoft Developer Studio Project File - Name="teapot" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=teapot - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "teapot.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "teapot.mak" CFG="gloss - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "teapot - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "teapot - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "teapot - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /I "../../util" /I "../../../include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../../../lib/GLUT32.LIB ../../../lib/GLU32.LIB ../../../lib/OPENGL32.LIB /nologo /subsystem:console /machine:I386 /out:"../teapot.exe" +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copy DLLs +PostBuild_Cmds=copy ..\..\..\lib\*.dll .. +# End Special Build Tool + +!ELSEIF "$(CFG)" == "teapot - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../../util" /I "../../../include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../../../lib/GLUT32.LIB ../../../lib/GLU32.LIB ../../../lib/OPENGL32.LIB /nologo /subsystem:console /debug /machine:I386 /out:"../teapot.exe" /pdbtype:sept +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copy DLLs +PostBuild_Cmds=copy ..\..\..\lib\*.dll .. +# End Special Build Tool + +!ENDIF + +# Begin Target + +# Name "teapot - Win32 Release" +# Name "teapot - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=..\teapot.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/progs/demos/Windows/terrain.dsp b/progs/demos/Windows/terrain.dsp new file mode 100644 index 00000000000..9fe490db81e --- /dev/null +++ b/progs/demos/Windows/terrain.dsp @@ -0,0 +1,112 @@ +# Microsoft Developer Studio Project File - Name="terrain" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=terrain - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "terrain.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "terrain.mak" CFG="bounce - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "terrain - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "terrain - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "terrain - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /I "../../../include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../../../lib/GLUT32.LIB ../../../lib/GLU32.LIB ../../../lib/OPENGL32.LIB /nologo /subsystem:console /machine:I386 /out:"../terrain.exe" +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copy DLLs +PostBuild_Cmds=copy ..\..\..\lib\*.dll .. +# End Special Build Tool + +!ELSEIF "$(CFG)" == "terrain - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../../../include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../../../lib/GLUT32.LIB ../../../lib/GLU32.LIB ../../../lib/OPENGL32.LIB /nologo /subsystem:console /debug /machine:I386 /out:"../terrain.exe" /pdbtype:sept +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copy DLLs +PostBuild_Cmds=copy ..\..\..\lib\*.dll .. +# End Special Build Tool + +!ENDIF + +# Begin Target + +# Name "terrain - Win32 Release" +# Name "terrain - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=..\terrain.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/progs/demos/Windows/tessdemo.dsp b/progs/demos/Windows/tessdemo.dsp new file mode 100644 index 00000000000..61345c79e6a --- /dev/null +++ b/progs/demos/Windows/tessdemo.dsp @@ -0,0 +1,112 @@ +# Microsoft Developer Studio Project File - Name="tessdemo" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=tessdemo - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "tessdemo.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "tessdemo.mak" CFG="bounce - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "tessdemo - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "tessdemo - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "tessdemo - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /I "../../../include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../../../lib/GLUT32.LIB ../../../lib/GLU32.LIB ../../../lib/OPENGL32.LIB /nologo /subsystem:console /machine:I386 /out:"../tessdemo.exe" +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copy DLLs +PostBuild_Cmds=copy ..\..\..\lib\*.dll .. +# End Special Build Tool + +!ELSEIF "$(CFG)" == "tessdemo - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../../../include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../../../lib/GLUT32.LIB ../../../lib/GLU32.LIB ../../../lib/OPENGL32.LIB /nologo /subsystem:console /debug /machine:I386 /out:"../tessdemo.exe" /pdbtype:sept +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copy DLLs +PostBuild_Cmds=copy ..\..\..\lib\*.dll .. +# End Special Build Tool + +!ENDIF + +# Begin Target + +# Name "tessdemo - Win32 Release" +# Name "tessdemo - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=..\tessdemo.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/progs/demos/Windows/texcyl.dsp b/progs/demos/Windows/texcyl.dsp new file mode 100644 index 00000000000..b227e02c297 --- /dev/null +++ b/progs/demos/Windows/texcyl.dsp @@ -0,0 +1,112 @@ +# Microsoft Developer Studio Project File - Name="texcyl" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=texcyl - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "texcyl.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "texcyl.mak" CFG="gloss - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "texcyl - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "texcyl - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "texcyl - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /I "../../util" /I "../../../include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../../../lib/GLUT32.LIB ../../../lib/GLU32.LIB ../../../lib/OPENGL32.LIB /nologo /subsystem:console /machine:I386 /out:"../texcyl.exe" +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copy DLLs +PostBuild_Cmds=copy ..\..\..\lib\*.dll .. +# End Special Build Tool + +!ELSEIF "$(CFG)" == "texcyl - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../../util" /I "../../../include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../../../lib/GLUT32.LIB ../../../lib/GLU32.LIB ../../../lib/OPENGL32.LIB /nologo /subsystem:console /debug /machine:I386 /out:"../texcyl.exe" /pdbtype:sept +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copy DLLs +PostBuild_Cmds=copy ..\..\..\lib\*.dll .. +# End Special Build Tool + +!ENDIF + +# Begin Target + +# Name "texcyl - Win32 Release" +# Name "texcyl - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=..\texcyl.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/progs/demos/Windows/texdown.dsp b/progs/demos/Windows/texdown.dsp new file mode 100644 index 00000000000..acea7666afc --- /dev/null +++ b/progs/demos/Windows/texdown.dsp @@ -0,0 +1,112 @@ +# Microsoft Developer Studio Project File - Name="texdown" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=texdown - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "texdown.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "texdown.mak" CFG="bounce - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "texdown - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "texdown - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "texdown - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /I "../../../include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../../../lib/GLUT32.LIB ../../../lib/GLU32.LIB ../../../lib/OPENGL32.LIB /nologo /subsystem:console /machine:I386 /out:"../texdown.exe" +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copy DLLs +PostBuild_Cmds=copy ..\..\..\lib\*.dll .. +# End Special Build Tool + +!ELSEIF "$(CFG)" == "texdown - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../../../include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../../../lib/GLUT32.LIB ../../../lib/GLU32.LIB ../../../lib/OPENGL32.LIB /nologo /subsystem:console /debug /machine:I386 /out:"../texdown.exe" /pdbtype:sept +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copy DLLs +PostBuild_Cmds=copy ..\..\..\lib\*.dll .. +# End Special Build Tool + +!ENDIF + +# Begin Target + +# Name "texdown - Win32 Release" +# Name "texdown - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=..\texdown.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/progs/demos/Windows/texenv.dsp b/progs/demos/Windows/texenv.dsp new file mode 100644 index 00000000000..3eb7eecdb71 --- /dev/null +++ b/progs/demos/Windows/texenv.dsp @@ -0,0 +1,112 @@ +# Microsoft Developer Studio Project File - Name="texenv" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=texenv - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "texenv.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "texenv.mak" CFG="bounce - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "texenv - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "texenv - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "texenv - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /I "../../../include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../../../lib/GLUT32.LIB ../../../lib/GLU32.LIB ../../../lib/OPENGL32.LIB /nologo /subsystem:console /machine:I386 /out:"../texenv.exe" +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copy DLLs +PostBuild_Cmds=copy ..\..\..\lib\*.dll .. +# End Special Build Tool + +!ELSEIF "$(CFG)" == "texenv - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../../../include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../../../lib/GLUT32.LIB ../../../lib/GLU32.LIB ../../../lib/OPENGL32.LIB /nologo /subsystem:console /debug /machine:I386 /out:"../texenv.exe" /pdbtype:sept +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copy DLLs +PostBuild_Cmds=copy ..\..\..\lib\*.dll .. +# End Special Build Tool + +!ENDIF + +# Begin Target + +# Name "texenv - Win32 Release" +# Name "texenv - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=..\texenv.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/progs/demos/Windows/texobj.dsp b/progs/demos/Windows/texobj.dsp new file mode 100644 index 00000000000..5db5f2ee798 --- /dev/null +++ b/progs/demos/Windows/texobj.dsp @@ -0,0 +1,112 @@ +# Microsoft Developer Studio Project File - Name="texobj" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=texobj - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "texobj.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "texobj.mak" CFG="bounce - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "texobj - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "texobj - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "texobj - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /I "../../../include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../../../lib/GLUT32.LIB ../../../lib/GLU32.LIB ../../../lib/OPENGL32.LIB /nologo /subsystem:console /machine:I386 /out:"../texobj.exe" +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copy DLLs +PostBuild_Cmds=copy ..\..\..\lib\*.dll .. +# End Special Build Tool + +!ELSEIF "$(CFG)" == "texobj - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../../../include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../../../lib/GLUT32.LIB ../../../lib/GLU32.LIB ../../../lib/OPENGL32.LIB /nologo /subsystem:console /debug /machine:I386 /out:"../texobj.exe" /pdbtype:sept +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copy DLLs +PostBuild_Cmds=copy ..\..\..\lib\*.dll .. +# End Special Build Tool + +!ENDIF + +# Begin Target + +# Name "texobj - Win32 Release" +# Name "texobj - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=..\texobj.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/progs/demos/Windows/trispd.dsp b/progs/demos/Windows/trispd.dsp new file mode 100644 index 00000000000..7e27cf3d04b --- /dev/null +++ b/progs/demos/Windows/trispd.dsp @@ -0,0 +1,112 @@ +# Microsoft Developer Studio Project File - Name="trispd" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=trispd - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "trispd.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "trispd.mak" CFG="bounce - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "trispd - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "trispd - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "trispd - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /I "../../../include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../../../lib/GLUT32.LIB ../../../lib/GLU32.LIB ../../../lib/OPENGL32.LIB /nologo /subsystem:console /machine:I386 /out:"../trispd.exe" +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copy DLLs +PostBuild_Cmds=copy ..\..\..\lib\*.dll .. +# End Special Build Tool + +!ELSEIF "$(CFG)" == "trispd - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../../../include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../../../lib/GLUT32.LIB ../../../lib/GLU32.LIB ../../../lib/OPENGL32.LIB /nologo /subsystem:console /debug /machine:I386 /out:"../trispd.exe" /pdbtype:sept +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copy DLLs +PostBuild_Cmds=copy ..\..\..\lib\*.dll .. +# End Special Build Tool + +!ENDIF + +# Begin Target + +# Name "trispd - Win32 Release" +# Name "trispd - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=..\trispd.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/progs/demos/Windows/tunnel.dsp b/progs/demos/Windows/tunnel.dsp new file mode 100644 index 00000000000..965f109c33e --- /dev/null +++ b/progs/demos/Windows/tunnel.dsp @@ -0,0 +1,112 @@ +# Microsoft Developer Studio Project File - Name="tunnel" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=tunnel - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "tunnel.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "tunnel.mak" CFG="gloss - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "tunnel - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "tunnel - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "tunnel - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /I "../../util" /I "../../../include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../../../lib/GLUT32.LIB ../../../lib/GLU32.LIB ../../../lib/OPENGL32.LIB /nologo /subsystem:console /machine:I386 /out:"../tunnel.exe" +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copy DLLs +PostBuild_Cmds=copy ..\..\..\lib\*.dll .. +# End Special Build Tool + +!ELSEIF "$(CFG)" == "tunnel - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../../util" /I "../../../include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../../../lib/GLUT32.LIB ../../../lib/GLU32.LIB ../../../lib/OPENGL32.LIB /nologo /subsystem:console /debug /machine:I386 /out:"../tunnel.exe" /pdbtype:sept +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copy DLLs +PostBuild_Cmds=copy ..\..\..\lib\*.dll .. +# End Special Build Tool + +!ENDIF + +# Begin Target + +# Name "tunnel - Win32 Release" +# Name "tunnel - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=..\tunnel.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/progs/demos/Windows/tunnel2.dsp b/progs/demos/Windows/tunnel2.dsp new file mode 100644 index 00000000000..3ae2800a04d --- /dev/null +++ b/progs/demos/Windows/tunnel2.dsp @@ -0,0 +1,112 @@ +# Microsoft Developer Studio Project File - Name="tunnel2" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=tunnel2 - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "tunnel2.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "tunnel2.mak" CFG="gloss - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "tunnel2 - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "tunnel2 - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "tunnel2 - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /I "../../util" /I "../../../include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../../../lib/GLUT32.LIB ../../../lib/GLU32.LIB ../../../lib/OPENGL32.LIB /nologo /subsystem:console /machine:I386 /out:"../tunnel2.exe" +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copy DLLs +PostBuild_Cmds=copy ..\..\..\lib\*.dll .. +# End Special Build Tool + +!ELSEIF "$(CFG)" == "tunnel2 - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../../util" /I "../../../include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../../../lib/GLUT32.LIB ../../../lib/GLU32.LIB ../../../lib/OPENGL32.LIB /nologo /subsystem:console /debug /machine:I386 /out:"../tunnel2.exe" /pdbtype:sept +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copy DLLs +PostBuild_Cmds=copy ..\..\..\lib\*.dll .. +# End Special Build Tool + +!ENDIF + +# Begin Target + +# Name "tunnel2 - Win32 Release" +# Name "tunnel2 - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=..\tunnel2.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/progs/demos/Windows/winpos.dsp b/progs/demos/Windows/winpos.dsp new file mode 100644 index 00000000000..b7b569e6402 --- /dev/null +++ b/progs/demos/Windows/winpos.dsp @@ -0,0 +1,112 @@ +# Microsoft Developer Studio Project File - Name="winpos" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=winpos - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "winpos.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "winpos.mak" CFG="gloss - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "winpos - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "winpos - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "winpos - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /I "../../util" /I "../../../include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../../../lib/GLUT32.LIB ../../../lib/GLU32.LIB ../../../lib/OPENGL32.LIB /nologo /subsystem:console /machine:I386 /out:"../winpos.exe" +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copy DLLs +PostBuild_Cmds=copy ..\..\..\lib\*.dll .. +# End Special Build Tool + +!ELSEIF "$(CFG)" == "winpos - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../../util" /I "../../../include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../../../lib/GLUT32.LIB ../../../lib/GLU32.LIB ../../../lib/OPENGL32.LIB /nologo /subsystem:console /debug /machine:I386 /out:"../winpos.exe" /pdbtype:sept +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copy DLLs +PostBuild_Cmds=copy ..\..\..\lib\*.dll .. +# End Special Build Tool + +!ENDIF + +# Begin Target + +# Name "winpos - Win32 Release" +# Name "winpos - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=..\winpos.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/progs/demos/arbfplight.c b/progs/demos/arbfplight.c new file mode 100644 index 00000000000..d9c564fbe56 --- /dev/null +++ b/progs/demos/arbfplight.c @@ -0,0 +1,395 @@ +/* + * Use GL_ARB_fragment_program and GL_ARB_vertex_program to implement + * simple per-pixel lighting. + * + * Brian Paul + * 17 April 2003 + */ + +#include +#include +#include +#include +#include +#include + + +static GLfloat Diffuse[4] = { 0.5, 0.5, 1.0, 1.0 }; +static GLfloat Specular[4] = { 0.8, 0.8, 0.8, 1.0 }; +static GLfloat LightPos[4] = { 0.0, 10.0, 20.0, 1.0 }; +static GLfloat Delta = 1.0; + +static GLuint FragProg; +static GLuint VertProg; +static GLboolean Anim = GL_TRUE; +static GLboolean Wire = GL_FALSE; +static GLboolean PixelLight = GL_TRUE; + +static GLint T0 = 0; +static GLint Frames = 0; + +static GLfloat Xrot = 0, Yrot = 0; + +static PFNGLPROGRAMLOCALPARAMETER4FVARBPROC glProgramLocalParameter4fvARB_func; +static PFNGLPROGRAMLOCALPARAMETER4DARBPROC glProgramLocalParameter4dARB_func; +static PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC glGetProgramLocalParameterdvARB_func; +static PFNGLGENPROGRAMSARBPROC glGenProgramsARB_func; +static PFNGLPROGRAMSTRINGARBPROC glProgramStringARB_func; +static PFNGLBINDPROGRAMARBPROC glBindProgramARB_func; +static PFNGLISPROGRAMARBPROC glIsProgramARB_func; +static PFNGLDELETEPROGRAMSARBPROC glDeleteProgramsARB_func; + +/* These must match the indexes used in the fragment program */ +#define LIGHTPOS 3 + +/* Set to one to test ARB_fog_linear program option */ +#define DO_FRAGMENT_FOG 0 + + +static void Redisplay( void ) +{ + glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); + + if (PixelLight) { + glProgramLocalParameter4fvARB_func(GL_FRAGMENT_PROGRAM_ARB, + LIGHTPOS, LightPos); + glEnable(GL_FRAGMENT_PROGRAM_ARB); + glEnable(GL_VERTEX_PROGRAM_ARB); + glDisable(GL_LIGHTING); + } + else { + glLightfv(GL_LIGHT0, GL_POSITION, LightPos); + glDisable(GL_FRAGMENT_PROGRAM_ARB); + glDisable(GL_VERTEX_PROGRAM_ARB); + glEnable(GL_LIGHTING); + } + + glPushMatrix(); + glRotatef(Xrot, 1, 0, 0); + glRotatef(Yrot, 0, 1, 0); + glutSolidSphere(2.0, 10, 5); + glPopMatrix(); + + glutSwapBuffers(); + + Frames++; + + if (Anim) { + 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); + T0 = t; + Frames = 0; + } + } +} + + +static void Idle(void) +{ + LightPos[0] += Delta; + if (LightPos[0] > 25.0) + Delta = -1.0; + else if (LightPos[0] <- 25.0) + Delta = 1.0; + glutPostRedisplay(); +} + + +static void Reshape( int width, int height ) +{ + glViewport( 0, 0, width, height ); + glMatrixMode( GL_PROJECTION ); + glLoadIdentity(); + glFrustum( -1.0, 1.0, -1.0, 1.0, 5.0, 25.0 ); + glMatrixMode( GL_MODELVIEW ); + glLoadIdentity(); + glTranslatef( 0.0, 0.0, -15.0 ); +} + + +static void Key( unsigned char key, int x, int y ) +{ + (void) x; + (void) y; + switch (key) { + case ' ': + case 'a': + Anim = !Anim; + if (Anim) + glutIdleFunc(Idle); + else + glutIdleFunc(NULL); + break; + case 'x': + LightPos[0] -= 1.0; + break; + case 'X': + LightPos[0] += 1.0; + break; + case 'w': + Wire = !Wire; + if (Wire) + glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); + else + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); + break; + case 'p': + PixelLight = !PixelLight; + if (PixelLight) { + printf("Per-pixel lighting\n"); + } + else { + printf("Conventional lighting\n"); + } + break; + case 27: + glDeleteProgramsARB_func(1, &VertProg); + glDeleteProgramsARB_func(1, &FragProg); + 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(); +} + + +/* A helper for finding errors in program strings */ +static int FindLine( const char *program, int position ) +{ + int i, line = 1; + for (i = 0; i < position; i++) { + if (program[i] == '\n') + line++; + } + return line; +} + + +static void Init( void ) +{ + GLint errorPos; + + /* Yes, this could be expressed more efficiently */ + static const char *fragProgramText = + "!!ARBfp1.0\n" +#if DO_FRAGMENT_FOG + "OPTION ARB_fog_linear; \n" +#endif + "PARAM Diffuse = state.material.diffuse; \n" + "PARAM Specular = state.material.specular; \n" + "PARAM LightPos = program.local[3]; \n" + "TEMP lightDir, normal, len; \n" + "TEMP dotProd, specAtten; \n" + "TEMP diffuseColor, specularColor; \n" + + "# Compute normalized light direction \n" + "DP3 len.x, LightPos, LightPos; \n" + "RSQ len.y, len.x; \n" + "MUL lightDir, LightPos, len.y; \n" + + "# Compute normalized normal \n" + "DP3 len.x, fragment.texcoord[0], fragment.texcoord[0]; \n" + "RSQ len.y, len.x; \n" + "MUL normal, fragment.texcoord[0], len.y; \n" + + "# Compute dot product of light direction and normal vector\n" + "DP3_SAT dotProd, lightDir, normal; # limited to [0,1]\n" + + "MUL diffuseColor, Diffuse, dotProd; # diffuse attenuation\n" + + "POW specAtten.x, dotProd.x, {20.0}.x; # specular exponent\n" + + "MUL specularColor, Specular, specAtten.x; # specular attenuation\n" + +#if DO_FRAGMENT_FOG + "# need to clamp color to [0,1] before fogging \n" + "ADD_SAT result.color, diffuseColor, specularColor; # add colors\n" +#else + "# clamping will be done after program's finished \n" + "ADD result.color, diffuseColor, specularColor; # add colors\n" +#endif + "END \n" + ; + + static const char *vertProgramText = + "!!ARBvp1.0\n" + "ATTRIB pos = vertex.position; \n" + "ATTRIB norm = vertex.normal; \n" + "PARAM modelview[4] = { state.matrix.modelview }; \n" + "PARAM modelviewProj[4] = { state.matrix.mvp }; \n" + "PARAM invModelview[4] = { state.matrix.modelview.invtrans }; \n" + + "# typical modelview/projection transform \n" + "DP4 result.position.x, pos, modelviewProj[0]; \n" + "DP4 result.position.y, pos, modelviewProj[1]; \n" + "DP4 result.position.z, pos, modelviewProj[2]; \n" + "DP4 result.position.w, pos, modelviewProj[3]; \n" + + "# transform normal by inv transpose of modelview, put in tex0 \n" + "DP3 result.texcoord[0].x, norm, invModelview[0]; \n" + "DP3 result.texcoord[0].y, norm, invModelview[1]; \n" + "DP3 result.texcoord[0].z, norm, invModelview[2]; \n" + "DP3 result.texcoord[0].w, norm, invModelview[3]; \n" + +#if DO_FRAGMENT_FOG + "# compute fog coordinate = vertex eye-space Z coord (negated)\n" + "DP4 result.fogcoord, -pos, modelview[2]; \n" +#endif + "END\n"; + ; + + if (!glutExtensionSupported("GL_ARB_vertex_program")) { + printf("Sorry, this demo requires GL_ARB_vertex_program\n"); + exit(1); + } + if (!glutExtensionSupported("GL_ARB_fragment_program")) { + printf("Sorry, this demo requires GL_ARB_fragment_program\n"); + exit(1); + } + + /* + * Get extension function pointers. + */ + glProgramLocalParameter4fvARB_func = (PFNGLPROGRAMLOCALPARAMETER4FVARBPROC) glutGetProcAddress("glProgramLocalParameter4fvARB"); + assert(glProgramLocalParameter4fvARB_func); + + glProgramLocalParameter4dARB_func = (PFNGLPROGRAMLOCALPARAMETER4DARBPROC) glutGetProcAddress("glProgramLocalParameter4dARB"); + assert(glProgramLocalParameter4dARB_func); + + glGetProgramLocalParameterdvARB_func = (PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC) glutGetProcAddress("glGetProgramLocalParameterdvARB"); + assert(glGetProgramLocalParameterdvARB_func); + + glGenProgramsARB_func = (PFNGLGENPROGRAMSARBPROC) glutGetProcAddress("glGenProgramsARB"); + assert(glGenProgramsARB_func); + + glProgramStringARB_func = (PFNGLPROGRAMSTRINGARBPROC) glutGetProcAddress("glProgramStringARB"); + assert(glProgramStringARB_func); + + glBindProgramARB_func = (PFNGLBINDPROGRAMARBPROC) glutGetProcAddress("glBindProgramARB"); + assert(glBindProgramARB_func); + + glIsProgramARB_func = (PFNGLISPROGRAMARBPROC) glutGetProcAddress("glIsProgramARB"); + assert(glIsProgramARB_func); + + glDeleteProgramsARB_func = (PFNGLDELETEPROGRAMSARBPROC) glutGetProcAddress("glDeleteProgramsARB"); + assert(glDeleteProgramsARB_func); + + /* + * Fragment program + */ + glGenProgramsARB_func(1, &FragProg); + assert(FragProg > 0); + glBindProgramARB_func(GL_FRAGMENT_PROGRAM_ARB, FragProg); + glProgramStringARB_func(GL_FRAGMENT_PROGRAM_ARB, + GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(fragProgramText), + (const GLubyte *) fragProgramText); + glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errorPos); + if (glGetError() != GL_NO_ERROR || errorPos != -1) { + int l = FindLine(fragProgramText, errorPos); + printf("Fragment Program Error (pos=%d line=%d): %s\n", errorPos, l, + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + exit(0); + } + assert(glIsProgramARB_func(FragProg)); + + /* + * Do some sanity tests + */ + { + GLdouble v[4]; + glProgramLocalParameter4dARB_func(GL_FRAGMENT_PROGRAM_ARB, 8, + 10.0, 20.0, 30.0, 40.0); + glGetProgramLocalParameterdvARB_func(GL_FRAGMENT_PROGRAM_ARB, 8, v); + assert(v[0] == 10.0); + assert(v[1] == 20.0); + assert(v[2] == 30.0); + assert(v[3] == 40.0); + } + + /* + * Vertex program + */ + glGenProgramsARB_func(1, &VertProg); + assert(VertProg > 0); + glBindProgramARB_func(GL_VERTEX_PROGRAM_ARB, VertProg); + glProgramStringARB_func(GL_VERTEX_PROGRAM_ARB, + GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(vertProgramText), + (const GLubyte *) vertProgramText); + glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errorPos); + if (glGetError() != GL_NO_ERROR || errorPos != -1) { + int l = FindLine(vertProgramText, errorPos); + printf("Vertex Program Error (pos=%d line=%d): %s\n", errorPos, l, + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + exit(0); + } + assert(glIsProgramARB_func(VertProg)); + + /* + * Misc init + */ + glClearColor(0.3, 0.3, 0.3, 0.0); + glEnable(GL_DEPTH_TEST); + glEnable(GL_LIGHT0); + glEnable(GL_LIGHTING); + glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, Diffuse); + glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, Specular); + glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 20.0); + +#if DO_FRAGMENT_FOG + { + /* Green-ish fog color */ + static const GLfloat fogColor[4] = {0.5, 1.0, 0.5, 0}; + glFogfv(GL_FOG_COLOR, fogColor); + glFogf(GL_FOG_START, 5.0); + glFogf(GL_FOG_END, 25.0); + } +#endif + + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + printf("Press p to toggle between per-pixel and per-vertex lighting\n"); +} + + +int main( int argc, char *argv[] ) +{ + glutInit( &argc, argv ); + glutInitWindowPosition( 0, 0 ); + glutInitWindowSize( 200, 200 ); + glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ); + glutCreateWindow(argv[0]); + glutReshapeFunc( Reshape ); + glutKeyboardFunc( Key ); + glutSpecialFunc( SpecialKey ); + glutDisplayFunc( Redisplay ); + if (Anim) + glutIdleFunc(Idle); + Init(); + glutMainLoop(); + return 0; +} diff --git a/progs/demos/arbfslight.c b/progs/demos/arbfslight.c new file mode 100644 index 00000000000..30332a3f641 --- /dev/null +++ b/progs/demos/arbfslight.c @@ -0,0 +1,289 @@ +/* + * Use GL_ARB_fragment_shader and GL_ARB_vertex_shader to implement + * simple per-pixel lighting. + * + * Michal Krol + * 20 February 2006 + * + * Based on the original demo by: + * Brian Paul + * 17 April 2003 + */ + +#ifdef WIN32 +#include +#endif + +#include +#include +#include +#include +#include + +#ifdef WIN32 +#define GETPROCADDRESS wglGetProcAddress +#else +#define GETPROCADDRESS glutGetProcAddress +#endif + +static GLfloat diffuse[4] = { 0.5f, 0.5f, 1.0f, 1.0f }; +static GLfloat specular[4] = { 0.8f, 0.8f, 0.8f, 1.0f }; +static GLfloat lightPos[4] = { 0.0f, 10.0f, 20.0f, 1.0f }; +static GLfloat delta = 1.0f; + +static GLhandleARB fragShader; +static GLhandleARB vertShader; +static GLhandleARB program; + +static GLint uLightPos; +static GLint uDiffuse; +static GLint uSpecular; + +static GLboolean anim = GL_TRUE; +static GLboolean wire = GL_FALSE; +static GLboolean pixelLight = GL_TRUE; + +static GLint t0 = 0; +static GLint frames = 0; + +static GLfloat xRot = 0.0f, yRot = 0.0f; + +static PFNGLCREATESHADEROBJECTARBPROC glCreateShaderObjectARB = NULL; +static PFNGLSHADERSOURCEARBPROC glShaderSourceARB = NULL; +static PFNGLCOMPILESHADERARBPROC glCompileShaderARB = NULL; +static PFNGLCREATEPROGRAMOBJECTARBPROC glCreateProgramObjectARB = NULL; +static PFNGLATTACHOBJECTARBPROC glAttachObjectARB = NULL; +static PFNGLLINKPROGRAMARBPROC glLinkProgramARB = NULL; +static PFNGLUSEPROGRAMOBJECTARBPROC glUseProgramObjectARB = NULL; +static PFNGLGETUNIFORMLOCATIONARBPROC glGetUniformLocationARB = NULL; +static PFNGLUNIFORM4FVARBPROC glUniform4fvARB = NULL; + +static void Redisplay (void) +{ + glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + if (pixelLight) + { + glUseProgramObjectARB (program); + glUniform4fvARB (uLightPos, 1, lightPos); + glDisable(GL_LIGHTING); + } + else + { + glUseProgramObjectARB (0); + glLightfv (GL_LIGHT0, GL_POSITION, lightPos); + glEnable(GL_LIGHTING); + } + + glPushMatrix (); + glRotatef (xRot, 1.0f, 0.0f, 0.0f); + glRotatef (yRot, 0.0f, 1.0f, 0.0f); + glutSolidSphere (2.0, 10, 5); + glPopMatrix (); + + glutSwapBuffers(); + frames++; + + if (anim) + { + GLint t = glutGet (GLUT_ELAPSED_TIME); + if (t - t0 >= 5000) + { + GLfloat seconds = (GLfloat) (t - t0) / 1000.0f; + GLfloat fps = frames / seconds; + printf ("%d frames in %6.3f seconds = %6.3f FPS\n", frames, seconds, fps); + t0 = t; + frames = 0; + } + } +} + +static void Idle (void) +{ + lightPos[0] += delta; + if (lightPos[0] > 25.0f || lightPos[0] < -25.0f) + delta = -delta; + glutPostRedisplay (); +} + +static void Reshape (int width, int height) +{ + glViewport (0, 0, width, height); + glMatrixMode (GL_PROJECTION); + glLoadIdentity (); + glFrustum (-1.0, 1.0, -1.0, 1.0, 5.0, 25.0); + glMatrixMode (GL_MODELVIEW); + glLoadIdentity (); + glTranslatef (0.0f, 0.0f, -15.0f); +} + +static void Key (unsigned char key, int x, int y) +{ + (void) x; + (void) y; + + switch (key) + { + case ' ': + case 'a': + anim = !anim; + if (anim) + glutIdleFunc (Idle); + else + glutIdleFunc (NULL); + break; + case 'x': + lightPos[0] -= 1.0f; + break; + case 'X': + lightPos[0] += 1.0f; + break; + case 'w': + wire = !wire; + if (wire) + glPolygonMode (GL_FRONT_AND_BACK, GL_LINE); + else + glPolygonMode (GL_FRONT_AND_BACK, GL_FILL); + break; + case 'p': + pixelLight = !pixelLight; + if (pixelLight) + printf ("Per-pixel lighting\n"); + else + printf ("Conventional lighting\n"); + break; + case 27: + exit(0); + break; + } + glutPostRedisplay (); +} + +static void SpecialKey (int key, int x, int y) +{ + const GLfloat step = 3.0f; + + (void) x; + (void) y; + + switch (key) + { + case GLUT_KEY_UP: + xRot -= step; + break; + case GLUT_KEY_DOWN: + xRot += step; + break; + case GLUT_KEY_LEFT: + yRot -= step; + break; + case GLUT_KEY_RIGHT: + yRot += step; + break; + } + glutPostRedisplay (); +} + +static void Init (void) +{ + static const char *fragShaderText = + "uniform vec4 lightPos;\n" + "uniform vec4 diffuse;\n" + "uniform vec4 specular;\n" + "void main () {\n" + " // Compute dot product of light direction and normal vector\n" + " float dotProd;\n" + " dotProd = clamp (dot (normalize (lightPos).xyz, normalize (gl_TexCoord[0]).xyz), 0.0, 1.0);\n" + " // Compute diffuse and specular contributions\n" + " gl_FragColor = diffuse * dotProd + specular * pow (dotProd, 20.0);\n" + "}\n" + ; + static const char *vertShaderText = + "void main () {\n" + " gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n" + " gl_TexCoord[0] = vec4 (gl_NormalMatrix * gl_Normal, 1.0);\n" + "}\n" + ; + + if (!glutExtensionSupported ("GL_ARB_fragment_shader")) + { + printf ("Sorry, this demo requires GL_ARB_fragment_shader\n"); + exit(1); + } + if (!glutExtensionSupported ("GL_ARB_shader_objects")) + { + printf ("Sorry, this demo requires GL_ARB_shader_objects\n"); + exit(1); + } + if (!glutExtensionSupported ("GL_ARB_shading_language_100")) + { + printf ("Sorry, this demo requires GL_ARB_shading_language_100\n"); + exit(1); + } + if (!glutExtensionSupported ("GL_ARB_vertex_shader")) + { + printf ("Sorry, this demo requires GL_ARB_vertex_shader\n"); + exit(1); + } + + glCreateShaderObjectARB = (PFNGLCREATESHADEROBJECTARBPROC) GETPROCADDRESS ("glCreateShaderObjectARB"); + glShaderSourceARB = (PFNGLSHADERSOURCEARBPROC) GETPROCADDRESS ("glShaderSourceARB"); + glCompileShaderARB = (PFNGLCOMPILESHADERARBPROC) GETPROCADDRESS ("glCompileShaderARB"); + glCreateProgramObjectARB = (PFNGLCREATEPROGRAMOBJECTARBPROC) GETPROCADDRESS ("glCreateProgramObjectARB"); + glAttachObjectARB = (PFNGLATTACHOBJECTARBPROC) GETPROCADDRESS ("glAttachObjectARB"); + glLinkProgramARB = (PFNGLLINKPROGRAMARBPROC) GETPROCADDRESS ("glLinkProgramARB"); + glUseProgramObjectARB = (PFNGLUSEPROGRAMOBJECTARBPROC) GETPROCADDRESS ("glUseProgramObjectARB"); + glGetUniformLocationARB = (PFNGLGETUNIFORMLOCATIONARBPROC) GETPROCADDRESS ("glGetUniformLocationARB"); + glUniform4fvARB = (PFNGLUNIFORM4FVARBPROC) GETPROCADDRESS ("glUniform4fvARB"); + + fragShader = glCreateShaderObjectARB (GL_FRAGMENT_SHADER_ARB); + glShaderSourceARB (fragShader, 1, &fragShaderText, NULL); + glCompileShaderARB (fragShader); + + vertShader = glCreateShaderObjectARB (GL_VERTEX_SHADER_ARB); + glShaderSourceARB (vertShader, 1, &vertShaderText, NULL); + glCompileShaderARB (vertShader); + + program = glCreateProgramObjectARB (); + glAttachObjectARB (program, fragShader); + glAttachObjectARB (program, vertShader); + glLinkProgramARB (program); + glUseProgramObjectARB (program); + + uLightPos = glGetUniformLocationARB (program, "lightPos"); + uDiffuse = glGetUniformLocationARB (program, "diffuse"); + uSpecular = glGetUniformLocationARB (program, "specular"); + + glUniform4fvARB (uDiffuse, 1, diffuse); + glUniform4fvARB (uSpecular, 1, specular); + + glClearColor (0.3f, 0.3f, 0.3f, 0.0f); + glEnable (GL_DEPTH_TEST); + glEnable (GL_LIGHT0); + glEnable (GL_LIGHTING); + glMaterialfv (GL_FRONT_AND_BACK, GL_DIFFUSE, diffuse); + glMaterialfv (GL_FRONT_AND_BACK, GL_SPECULAR, specular); + glMaterialf (GL_FRONT_AND_BACK, GL_SHININESS, 20.0f); + + printf ("GL_RENDERER = %s\n", (const char *) glGetString (GL_RENDERER)); + printf ("Press p to toggle between per-pixel and per-vertex lighting\n"); +} + +int main (int argc, char *argv[]) +{ + glutInit (&argc, argv); + glutInitWindowPosition ( 0, 0); + glutInitWindowSize (200, 200); + glutInitDisplayMode (GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); + glutCreateWindow (argv[0]); + glutReshapeFunc (Reshape); + glutKeyboardFunc (Key); + glutSpecialFunc (SpecialKey); + glutDisplayFunc (Redisplay); + if (anim) + glutIdleFunc (Idle); + Init (); + glutMainLoop (); + return 0; +} + diff --git a/progs/demos/arbocclude.c b/progs/demos/arbocclude.c new file mode 100644 index 00000000000..ddbb1f1b759 --- /dev/null +++ b/progs/demos/arbocclude.c @@ -0,0 +1,283 @@ +/* + * GL_ARB_occlusion_query demo + * + * Brian Paul + * 12 June 2003 + * + * Copyright (C) 2003 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 +#include +#include +#include +#include +#define GL_GLEXT_PROTOTYPES +#include + +#define TEST_DISPLAY_LISTS 0 + +static GLboolean Anim = GL_TRUE; +static GLfloat Xpos = 0; +static GLuint OccQuery; + + + +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 ) +{ + GLuint passed; + GLint ready; + char s[100]; + + 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); + +#if defined(GL_ARB_occlusion_query) +#if TEST_DISPLAY_LISTS + glNewList(10, GL_COMPILE); + glBeginQueryARB(GL_SAMPLES_PASSED_ARB, OccQuery); + glEndList(); + glCallList(10); +#else + glBeginQueryARB(GL_SAMPLES_PASSED_ARB, OccQuery); +#endif + + glColorMask(0, 0, 0, 0); + glDepthMask(GL_FALSE); + + glBegin(GL_POLYGON); + glVertex3f(-1, -1, 0); + glVertex3f( 1, -1, 0); + glVertex3f( 1, 1, 0); + glVertex3f(-1, 1, 0); + glEnd(); + +#if TEST_DISPLAY_LISTS + glNewList(11, GL_COMPILE); + glEndQueryARB(GL_SAMPLES_PASSED_ARB); + glEndList(); + glCallList(11); +#else + glEndQueryARB(GL_SAMPLES_PASSED_ARB); +#endif + + do { + /* do useful work here, if any */ + glGetQueryObjectivARB(OccQuery, GL_QUERY_RESULT_AVAILABLE_ARB, &ready); + } while (!ready); + glGetQueryObjectuivARB(OccQuery, GL_QUERY_RESULT_ARB, &passed); + + /* turn off occlusion testing */ + glColorMask(1, 1, 1, 1); + glDepthMask(GL_TRUE); +#endif /* GL_ARB_occlusion_query */ + + /* draw the orange 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); +#if defined(GL_ARB_occlusion_query) + sprintf(s, " %4d Fragments Visible", passed); + glRasterPos3f(-0.50, -0.7, 0); + PrintString(s); + if (!passed) { + glRasterPos3f(-0.25, -0.8, 0); + PrintString("Fully Occluded"); + } +#else + glRasterPos3f(-0.25, -0.8, 0); + PrintString("GL_ARB_occlusion_query not available at compile time"); +#endif /* GL_ARB_occlusion_query */ + + 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; + case ' ': + Anim = !Anim; + if (Anim) + glutIdleFunc(Idle); + else + glutIdleFunc(NULL); + 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); + GLint bits; + + if (!strstr(ext, "GL_ARB_occlusion_query")) { + printf("Sorry, this demo requires the GL_ARB_occlusion_query extension\n"); + exit(-1); + } + +#if defined(GL_ARB_occlusion_query) + glGetQueryivARB(GL_SAMPLES_PASSED_ARB, GL_QUERY_COUNTER_BITS_ARB, &bits); + if (!bits) { + printf("Hmmm, GL_QUERY_COUNTER_BITS_ARB is zero!\n"); + exit(-1); + } +#endif /* GL_ARB_occlusion_query */ + + glGetIntegerv(GL_DEPTH_BITS, &bits); + printf("Depthbits: %d\n", bits); + +#if defined(GL_ARB_occlusion_query) + glGenQueriesARB(1, &OccQuery); + assert(OccQuery > 0); +#endif /* GL_ARB_occlusion_query */ + + 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; +} diff --git a/progs/demos/bounce.c b/progs/demos/bounce.c new file mode 100644 index 00000000000..436bc7d1fb8 --- /dev/null +++ b/progs/demos/bounce.c @@ -0,0 +1,226 @@ + +/* + * Bouncing ball demo. + * + * This program is in the public domain + * + * Brian Paul + * + * Conversion to GLUT by Mark J. Kilgard + */ + + +#include +#include +#include +#include + +#define COS(X) cos( (X) * 3.14159/180.0 ) +#define SIN(X) sin( (X) * 3.14159/180.0 ) + +#define RED 1 +#define WHITE 2 +#define CYAN 3 + +GLboolean IndexMode = GL_FALSE; +GLuint Ball; +GLenum Mode; +GLfloat Zrot = 0.0, Zstep = 180.0; +GLfloat Xpos = 0.0, Ypos = 1.0; +GLfloat Xvel = 2.0, Yvel = 0.0; +GLfloat Xmin = -4.0, Xmax = 4.0; +GLfloat Ymin = -3.8, Ymax = 4.0; +GLfloat G = -9.8; + +static GLuint +make_ball(void) +{ + GLuint list; + GLfloat a, b; + GLfloat da = 18.0, db = 18.0; + GLfloat radius = 1.0; + GLuint color; + GLfloat x, y, z; + + list = glGenLists(1); + + glNewList(list, GL_COMPILE); + + color = 0; + for (a = -90.0; a + da <= 90.0; a += da) { + + glBegin(GL_QUAD_STRIP); + for (b = 0.0; b <= 360.0; b += db) { + + if (color) { + glIndexi(RED); + glColor3f(1, 0, 0); + } else { + glIndexi(WHITE); + glColor3f(1, 1, 1); + } + + x = radius * COS(b) * COS(a); + y = radius * SIN(b) * COS(a); + z = radius * SIN(a); + glVertex3f(x, y, z); + + x = radius * COS(b) * COS(a + da); + y = radius * SIN(b) * COS(a + da); + z = radius * SIN(a + da); + glVertex3f(x, y, z); + + color = 1 - color; + } + glEnd(); + + } + + glEndList(); + + return list; +} + +static void +reshape(int width, int height) +{ + float aspect = (float) width / (float) height; + glViewport(0, 0, (GLint) width, (GLint) height); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-6.0 * aspect, 6.0 * aspect, -6.0, 6.0, -6.0, 6.0); + glMatrixMode(GL_MODELVIEW); +} + +/* ARGSUSED1 */ +static void +key(unsigned char k, int x, int y) +{ + switch (k) { + case 27: /* Escape */ + exit(0); + } +} + +static void +draw(void) +{ + GLint i; + + glClear(GL_COLOR_BUFFER_BIT); + + glIndexi(CYAN); + glColor3f(0, 1, 1); + glBegin(GL_LINES); + for (i = -5; i <= 5; i++) { + glVertex2i(i, -5); + glVertex2i(i, 5); + } + for (i = -5; i <= 5; i++) { + glVertex2i(-5, i); + glVertex2i(5, i); + } + for (i = -5; i <= 5; i++) { + glVertex2i(i, -5); + glVertex2f(i * 1.15, -5.9); + } + glVertex2f(-5.3, -5.35); + glVertex2f(5.3, -5.35); + glVertex2f(-5.75, -5.9); + glVertex2f(5.75, -5.9); + glEnd(); + + glPushMatrix(); + glTranslatef(Xpos, Ypos, 0.0); + glScalef(2.0, 2.0, 2.0); + glRotatef(8.0, 0.0, 0.0, 1.0); + glRotatef(90.0, 1.0, 0.0, 0.0); + glRotatef(Zrot, 0.0, 0.0, 1.0); + + glCallList(Ball); + + glPopMatrix(); + + glFlush(); + glutSwapBuffers(); +} + +static void +idle(void) +{ + static float vel0 = -100.0; + static double t0 = -1.; + double t, dt; + t = glutGet(GLUT_ELAPSED_TIME) / 1000.; + if (t0 < 0.) + t0 = t; + dt = t - t0; + t0 = t; + + Zrot += Zstep*dt; + + Xpos += Xvel*dt; + if (Xpos >= Xmax) { + Xpos = Xmax; + Xvel = -Xvel; + Zstep = -Zstep; + } + if (Xpos <= Xmin) { + Xpos = Xmin; + Xvel = -Xvel; + Zstep = -Zstep; + } + Ypos += Yvel*dt; + Yvel += G*dt; + if (Ypos < Ymin) { + Ypos = Ymin; + if (vel0 == -100.0) + vel0 = fabs(Yvel); + Yvel = vel0; + } + glutPostRedisplay(); +} + +static void +visible(int vis) +{ + if (vis == GLUT_VISIBLE) + glutIdleFunc(idle); + else + glutIdleFunc(NULL); +} + +int main(int argc, char *argv[]) +{ + glutInit(&argc, argv); + glutInitWindowPosition(0, 0); + glutInitWindowSize(600, 450); + + + IndexMode = argc > 1 && strcmp(argv[1], "-ci") == 0; + if (IndexMode) + glutInitDisplayMode(GLUT_INDEX | GLUT_DOUBLE); + else + glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE); + + glutCreateWindow("Bounce"); + Ball = make_ball(); + glCullFace(GL_BACK); + glEnable(GL_CULL_FACE); + glDisable(GL_DITHER); + glShadeModel(GL_FLAT); + + glutDisplayFunc(draw); + glutReshapeFunc(reshape); + glutVisibilityFunc(visible); + glutKeyboardFunc(key); + + if (IndexMode) { + glutSetColor(RED, 1.0, 0.0, 0.0); + glutSetColor(WHITE, 1.0, 1.0, 1.0); + glutSetColor(CYAN, 0.0, 1.0, 1.0); + } + + glutMainLoop(); + return 0; /* ANSI C requires main to return int. */ +} diff --git a/progs/demos/clearspd.c b/progs/demos/clearspd.c new file mode 100644 index 00000000000..42953f6675e --- /dev/null +++ b/progs/demos/clearspd.c @@ -0,0 +1,218 @@ + +/* + * Simple GLUT program to measure glClear() and glutSwapBuffers() speed. + * Brian Paul February 15, 1997 This file in public domain. + */ + + +#include +#include +#include +#include +#include + + +static float MinPeriod = 2.0; /* 2 seconds */ +static int ColorMode = GLUT_RGB; +static int Width = 400.0; +static int Height = 400.0; +static int Loops = 100; +static float ClearColor = 0.0; +static GLbitfield BufferMask = GL_COLOR_BUFFER_BIT; +static GLboolean SwapFlag = GL_FALSE; + + + +static void Idle( void ) +{ + glutPostRedisplay(); +} + + +static void Display( void ) +{ + double t0, t1; + double clearRate; + double pixelRate; + int i; + + glClearColor( ClearColor, ClearColor, ClearColor, 0.0 ); + ClearColor += 0.1; + if (ClearColor>1.0) + ClearColor = 0.0; + + if (SwapFlag) { + t0 = glutGet(GLUT_ELAPSED_TIME) * 0.001; + for (i=0;i +#include +#include +#include +#include +#include "GL/glut.h" +#include "readtex.h" + + +static GLfloat Xrot = 0, Yrot = 0; +static GLfloat EyeDist = 10; +static GLboolean use_vertex_arrays = GL_FALSE; +static GLboolean anim = GL_TRUE; + +#define eps1 0.99 +#define br 20.0 /* box radius */ + +static const GLfloat tex_coords[] = { + /* +X side */ + 1.0, -eps1, -eps1, + 1.0, -eps1, eps1, + 1.0, eps1, eps1, + 1.0, eps1, -eps1, + + /* -X side */ + -1.0, eps1, -eps1, + -1.0, eps1, eps1, + -1.0, -eps1, eps1, + -1.0, -eps1, -eps1, + + /* +Y side */ + -eps1, 1.0, -eps1, + -eps1, 1.0, eps1, + eps1, 1.0, eps1, + eps1, 1.0, -eps1, + + /* -Y side */ + -eps1, -1.0, -eps1, + -eps1, -1.0, eps1, + eps1, -1.0, eps1, + eps1, -1.0, -eps1, + + /* +Z side */ + eps1, -eps1, 1.0, + -eps1, -eps1, 1.0, + -eps1, eps1, 1.0, + eps1, eps1, 1.0, + + /* -Z side */ + eps1, eps1, -1.0, + -eps1, eps1, -1.0, + -eps1, -eps1, -1.0, + eps1, -eps1, -1.0, +}; + +static const GLfloat vtx_coords[] = { + /* +X side */ + br, -br, -br, + br, -br, br, + br, br, br, + br, br, -br, + + /* -X side */ + -br, br, -br, + -br, br, br, + -br, -br, br, + -br, -br, -br, + + /* +Y side */ + -br, br, -br, + -br, br, br, + br, br, br, + br, br, -br, + + /* -Y side */ + -br, -br, -br, + -br, -br, br, + br, -br, br, + br, -br, -br, + + /* +Z side */ + br, -br, br, + -br, -br, br, + -br, br, br, + br, br, br, + + /* -Z side */ + br, br, -br, + -br, br, -br, + -br, -br, -br, + br, -br, -br, +}; + +static void draw_skybox( void ) +{ + if ( use_vertex_arrays ) { + glTexCoordPointer( 3, GL_FLOAT, 0, tex_coords ); + glVertexPointer( 3, GL_FLOAT, 0, vtx_coords ); + + glEnableClientState( GL_TEXTURE_COORD_ARRAY ); + glEnableClientState( GL_VERTEX_ARRAY ); + + glDrawArrays( GL_QUADS, 0, 24 ); + + glDisableClientState( GL_TEXTURE_COORD_ARRAY ); + glDisableClientState( GL_VERTEX_ARRAY ); + } + else { + unsigned i; + + glBegin(GL_QUADS); + for ( i = 0 ; i < 24 ; i++ ) { + glTexCoord3fv( & tex_coords[ i * 3 ] ); + glVertex3fv ( & vtx_coords[ i * 3 ] ); + } + glEnd(); + } +} + + +static void draw( void ) +{ + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + glPushMatrix(); /*MODELVIEW*/ + glTranslatef( 0.0, 0.0, -EyeDist ); + + /* skybox */ + glDisable(GL_TEXTURE_GEN_S); + glDisable(GL_TEXTURE_GEN_T); + glDisable(GL_TEXTURE_GEN_R); + + glMatrixMode(GL_MODELVIEW); + glPushMatrix(); + glRotatef(Xrot, 1, 0, 0); + glRotatef(Yrot, 0, 1, 0); + draw_skybox(); + glPopMatrix(); + + /* sphere */ + glMatrixMode(GL_TEXTURE); + glLoadIdentity(); + glRotatef(-Yrot, 0, 1, 0); + glRotatef(-Xrot, 1, 0, 0); + + glEnable(GL_TEXTURE_GEN_S); + glEnable(GL_TEXTURE_GEN_T); + glEnable(GL_TEXTURE_GEN_R); + glutSolidSphere(2.0, 20, 20); + + glLoadIdentity(); /* texture */ + + glMatrixMode(GL_MODELVIEW); + glPopMatrix(); + + glutSwapBuffers(); +} + + +static void idle(void) +{ + GLfloat t = 0.05 * glutGet(GLUT_ELAPSED_TIME); + Yrot = t; + 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"); + } +} + + +static void key(unsigned char k, int x, int y) +{ + 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 'v': + use_vertex_arrays = ! use_vertex_arrays; + printf( "Vertex arrays are %sabled\n", + (use_vertex_arrays) ? "en" : "dis" ); + break; + case 'z': + EyeDist -= 0.5; + if (EyeDist < 6.0) + EyeDist = 6.0; + break; + case 'Z': + EyeDist += 0.5; + if (EyeDist > 90.0) + EyeDist = 90; + break; + case 27: + exit(0); + } + glutPostRedisplay(); +} + + +static void specialkey(int key, int x, int y) +{ + GLfloat step = 5; + (void) x; + (void) y; + switch (key) { + case GLUT_KEY_UP: + Xrot += step; + break; + case GLUT_KEY_DOWN: + Xrot -= step; + break; + case GLUT_KEY_LEFT: + Yrot -= step; + break; + case GLUT_KEY_RIGHT: + Yrot += step; + break; + } + glutPostRedisplay(); +} + + +/* new window size or exposure */ +static void reshape(int width, int height) +{ + GLfloat ar = (float) width / (float) height; + glViewport(0, 0, (GLint)width, (GLint)height); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glFrustum( -2.0*ar, 2.0*ar, -2.0, 2.0, 4.0, 100.0 ); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); +} + + +static void init_checkers( void ) +{ +#define CUBE_TEX_SIZE 64 + GLubyte image[CUBE_TEX_SIZE][CUBE_TEX_SIZE][3]; + static const GLubyte colors[6][3] = { + { 255, 0, 0 }, /* face 0 - red */ + { 0, 255, 255 }, /* face 1 - cyan */ + { 0, 255, 0 }, /* face 2 - green */ + { 255, 0, 255 }, /* face 3 - purple */ + { 0, 0, 255 }, /* face 4 - blue */ + { 255, 255, 0 } /* face 5 - yellow */ + }; + static const GLenum targets[6] = { + GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB, + GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB, + GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB, + GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB, + GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB, + GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB + }; + + GLint i, j, f; + + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + + /* make colored checkerboard cube faces */ + for (f = 0; f < 6; f++) { + for (i = 0; i < CUBE_TEX_SIZE; i++) { + for (j = 0; j < CUBE_TEX_SIZE; j++) { + if ((i/4 + j/4) & 1) { + image[i][j][0] = colors[f][0]; + image[i][j][1] = colors[f][1]; + image[i][j][2] = colors[f][2]; + } + else { + image[i][j][0] = 255; + image[i][j][1] = 255; + image[i][j][2] = 255; + } + } + } + + glTexImage2D(targets[f], 0, GL_RGB, CUBE_TEX_SIZE, CUBE_TEX_SIZE, 0, + GL_RGB, GL_UNSIGNED_BYTE, image); + } +} + + +static void load(GLenum target, const char *filename, + GLboolean flipTB, GLboolean flipLR) +{ + GLint w, h; + GLenum format; + GLubyte *img = LoadRGBImage( filename, &w, &h, &format ); + if (!img) { + printf("Error: couldn't load texture image %s\n", filename); + exit(1); + } + assert(format == GL_RGB); + + /* the way the texture cube mapping works, we have to flip + * images to make things look right. + */ + if (flipTB) { + const int stride = 3 * w; + GLubyte temp[3*1024]; + int i; + for (i = 0; i < h / 2; i++) { + memcpy(temp, img + i * stride, stride); + memcpy(img + i * stride, img + (h - i - 1) * stride, stride); + memcpy(img + (h - i - 1) * stride, temp, stride); + } + } + if (flipLR) { + const int stride = 3 * w; + GLubyte temp[3]; + GLubyte *row; + int i, j; + for (i = 0; i < h; i++) { + row = img + i * stride; + for (j = 0; j < w / 2; j++) { + int k = w - j - 1; + temp[0] = row[j*3+0]; + temp[1] = row[j*3+1]; + temp[2] = row[j*3+2]; + row[j*3+0] = row[k*3+0]; + row[j*3+1] = row[k*3+1]; + row[j*3+2] = row[k*3+2]; + row[k*3+0] = temp[0]; + row[k*3+1] = temp[1]; + row[k*3+2] = temp[2]; + } + } + } + + gluBuild2DMipmaps(target, GL_RGB, w, h, format, GL_UNSIGNED_BYTE, img); + free(img); +} + + +static void load_envmaps(void) +{ + load(GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB, "right.rgb", GL_TRUE, GL_FALSE); + load(GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB, "left.rgb", GL_TRUE, GL_FALSE); + load(GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB, "top.rgb", GL_FALSE, GL_TRUE); + load(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB, "bottom.rgb", GL_FALSE, GL_TRUE); + load(GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB, "front.rgb", GL_TRUE, GL_FALSE); + load(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB, "back.rgb", GL_TRUE, GL_FALSE); +} + + +static void init( GLboolean useImageFiles ) +{ + GLenum filter; + + /* 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); + } + } + printf("GL_RENDERER: %s\n", (char *) glGetString(GL_RENDERER)); + + if (useImageFiles) { + load_envmaps(); + filter = GL_LINEAR; + } + else { + init_checkers(); + filter = GL_NEAREST; + } + + glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MIN_FILTER, filter); + glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MAG_FILTER, filter); + glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + + glEnable(GL_TEXTURE_CUBE_MAP_ARB); + glEnable(GL_DEPTH_TEST); + + 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"); + printf(" z/Z - change viewing distance\n"); +} + + +int main( int argc, char *argv[] ) +{ + glutInitWindowPosition(0, 0); + glutInitWindowSize(600, 500); + glutInitDisplayMode( GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE ); + glutCreateWindow("Texture Cube Mapping"); + + if (argc > 1 && strcmp(argv[1] , "-i") == 0) + init( 1 ); + else + init( 0 ); + glutReshapeFunc( reshape ); + glutKeyboardFunc( key ); + glutSpecialFunc( specialkey ); + glutDisplayFunc( draw ); + if (anim) + glutIdleFunc(idle); + usage(); + glutMainLoop(); + return 0; +} diff --git a/progs/demos/descrip.mms b/progs/demos/descrip.mms new file mode 100644 index 00000000000..a374fdf13d0 --- /dev/null +++ b/progs/demos/descrip.mms @@ -0,0 +1,90 @@ +# Makefile for GLUT-based demo programs for VMS +# contributed by Jouk Jansen joukj@hrem.stm.tudelft.nl +# Last update : 20 May 2005 + +.first + define gl [--.include.gl] + +.include [--]mms-config. + +##### MACROS ##### + +INCDIR = ([--.include],[-.util]) +CFLAGS =/include=$(INCDIR)/prefix=all/name=(as_is,short)/float=ieee/ieee=denorm + +.ifdef SHARE +GL_LIBS = $(XLIBS) +LIB_DEP = [--.lib]$(GL_SHAR) [--.lib]$(GLU_SHAR) [--.lib]$(GLUT_SHAR) +.else +GL_LIBS = [--.lib]libGLUT/l,libMesaGLU/l,libMesaGL/l,$(XLIBS) +LIB_DEP = [--.lib]$(GL_LIB) [--.lib]$(GLU_LIB) [--.lib]$(GLUT_LIB) +.endif + + +PROGS = bounce.exe;,clearspd.exe;,drawpix.exe;,gamma.exe;,gears.exe;,\ + glinfo.exe;,glutfx.exe;,isosurf.exe;,morph3d.exe;,\ + paltex.exe;,pointblast.exe;,reflect.exe;,spectex.exe;,stex3d.exe;,\ + tessdemo.exe;,texcyl.exe;,texobj.exe;,trispd.exe;,winpos.exe; + + +##### RULES ##### +.obj.exe : + cxxlink $(MMS$TARGET_NAME),$(GL_LIBS) + +##### TARGETS ##### +default : + $(MMS)$(MMSQUALIFIERS) $(PROGS) + +clean : + delete *.obj;* + +realclean : + delete $(PROGS) + delete *.obj;* + +bounce.exe; : bounce.obj $(LIB_DEP) +clearspd.exe; : clearspd.obj $(LIB_DEP) +drawpix.exe; : drawpix.obj $(LIB_DEP) [-.util]readtex.obj + cxxlink $(MMS$TARGET_NAME),[-.util]readtex.obj,$(GL_LIBS) +gamma.exe; : gamma.obj $(LIB_DEP) +gears.exe; : gears.obj $(LIB_DEP) +glinfo.exe; : glinfo.obj $(LIB_DEP) +glutfx.exe; : glutfx.obj $(LIB_DEP) +isosurf.exe; : isosurf.obj $(LIB_DEP) [-.util]readtex.obj + cxxlink $(MMS$TARGET_NAME),[-.util]readtex.obj,$(GL_LIBS) +morph3d.exe; : morph3d.obj $(LIB_DEP) +paltex.exe; : paltex.obj $(LIB_DEP) +pointblast.exe; : pointblast.obj $(LIB_DEP) +reflect.exe; : reflect.obj [-.util]readtex.obj [-.util]showbuffer.obj\ + $(LIB_DEP) + cxxlink $(MMS$TARGET_NAME),[-.util]readtex,showbuffer,$(GL_LIBS) +spectex.exe; : spectex.obj $(LIB_DEP) +stex3d.exe; : stex3d.obj $(LIB_DEP) +tessdemo.exe; : tessdemo.obj $(LIB_DEP) +texcyl.exe; : texcyl.obj [-.util]readtex.obj $(LIB_DEP) + cxxlink $(MMS$TARGET_NAME),[-.util]readtex.obj,$(GL_LIBS) +texobj.exe; : texobj.obj $(LIB_DEP) +trispd.exe; : trispd.obj $(LIB_DEP) +winpos.exe; : winpos.obj [-.util]readtex.obj $(LIB_DEP) + cxxlink $(MMS$TARGET_NAME),[-.util]readtex.obj,$(GL_LIBS) + + +bounce.obj : bounce.c +clearspd.obj : clearspd.c +drawpix.obj : drawpix.c +gamma.obj : gamma.c +gears.obj : gears.c +glinfo.obj : glinfo.c +glutfx.obj : glutfx.c +isosurf.obj : isosurf.c +morph3d.obj : morph3d.c +paltex.obj : paltex.c +pointblast.obj : pointblast.c +reflect.obj : reflect.c +spectex.obj : spectex.c +stex3d.obj : stex3d.c +tessdemo.obj : tessdemo.c +texcyl.obj : texcyl.c +texobj.obj : texobj.c +trispd.obj : trispd.c +winpos.obj : winpos.c diff --git a/progs/demos/drawpix.c b/progs/demos/drawpix.c new file mode 100644 index 00000000000..d2f57486744 --- /dev/null +++ b/progs/demos/drawpix.c @@ -0,0 +1,358 @@ + +/* + * glDrawPixels demo/test/benchmark + * + * Brian Paul September 25, 1997 This file is in the public domain. + */ + +#include +#include +#include +#include +#include + +#include "readtex.h" + +#define IMAGE_FILE "../images/girl.rgb" + +static int ImgWidth, ImgHeight; +static GLenum ImgFormat; +static GLubyte *Image = NULL; + +static int Xpos, Ypos; +static int SkipPixels, SkipRows; +static int DrawWidth, DrawHeight; +static int Scissor = 0; +static int Fog = 0; +static GLfloat Zpos = -1.0; +static float Xzoom, Yzoom; +static GLboolean DrawFront = GL_FALSE; +static GLboolean Dither = GL_TRUE; + + +static void Reset( void ) +{ + Xpos = Ypos = 20; + DrawWidth = ImgWidth; + DrawHeight = ImgHeight; + SkipPixels = SkipRows = 0; + Scissor = 0; + Fog = 0; + Zpos = -1.0; + Xzoom = Yzoom = 1.0; +} + + +static void Display( void ) +{ + glClear( GL_COLOR_BUFFER_BIT ); + +#if 0 + glRasterPos2i(Xpos, Ypos); +#else + /* This allows negative raster positions: */ + glRasterPos3f(0, 0, Zpos); + glBitmap(0, 0, 0, 0, Xpos, Ypos, NULL); +#endif + + glPixelStorei(GL_UNPACK_SKIP_PIXELS, SkipPixels); + glPixelStorei(GL_UNPACK_SKIP_ROWS, SkipRows); + + glPixelZoom( Xzoom, Yzoom ); + + if (Scissor) + glEnable(GL_SCISSOR_TEST); + + if (Fog) + glEnable(GL_FOG); + + glDrawPixels(DrawWidth, DrawHeight, ImgFormat, GL_UNSIGNED_BYTE, Image); + + glDisable(GL_SCISSOR_TEST); + glDisable(GL_FOG); + + if (DrawFront) + glFinish(); + else + glutSwapBuffers(); +} + + +static void Benchmark( void ) +{ + int startTime, endTime; + int draws = 500; + double seconds, pixelsPerSecond; + + printf("Benchmarking...\n"); + /* GL set-up */ + glPixelStorei(GL_UNPACK_SKIP_PIXELS, SkipPixels); + glPixelStorei(GL_UNPACK_SKIP_ROWS, SkipRows); + glPixelZoom( Xzoom, Yzoom ); + if (Scissor) + glEnable(GL_SCISSOR_TEST); + if (Fog) + glEnable(GL_FOG); + + if (DrawFront) + glDrawBuffer(GL_FRONT); + else + glDrawBuffer(GL_BACK); + + /* Run timing test */ + draws = 0; + startTime = glutGet(GLUT_ELAPSED_TIME); + do { + glDrawPixels(DrawWidth, DrawHeight, ImgFormat, GL_UNSIGNED_BYTE, Image); + draws++; + endTime = glutGet(GLUT_ELAPSED_TIME); + } while (endTime - startTime < 4000); /* 4 seconds */ + + /* GL clean-up */ + glDisable(GL_SCISSOR_TEST); + glDisable(GL_FOG); + + /* Results */ + seconds = (double) (endTime - startTime) / 1000.0; + pixelsPerSecond = draws * DrawWidth * DrawHeight / seconds; + printf("Result: %d draws in %f seconds = %f pixels/sec\n", + draws, seconds, pixelsPerSecond); +} + + +static void Reshape( int width, int height ) +{ + glViewport( 0, 0, width, height ); + glMatrixMode( GL_PROJECTION ); + glLoadIdentity(); + glOrtho( 0.0, width, 0.0, height, 0.0, 2.0 ); + glMatrixMode( GL_MODELVIEW ); + glLoadIdentity(); + + glScissor(width/4, height/4, width/2, height/2); +} + + +static void Key( unsigned char key, int x, int y ) +{ + (void) x; + (void) y; + switch (key) { + case ' ': + Reset(); + break; + case 'd': + Dither = !Dither; + if (Dither) + glEnable(GL_DITHER); + else + glDisable(GL_DITHER); + break; + case 'w': + if (DrawWidth > 0) + DrawWidth--; + break; + case 'W': + DrawWidth++; + break; + case 'h': + if (DrawHeight > 0) + DrawHeight--; + break; + case 'H': + DrawHeight++; + break; + case 'p': + if (SkipPixels > 0) + SkipPixels--; + break; + case 'P': + SkipPixels++; + break; + case 'r': + if (SkipRows > 0) + SkipRows--; + break; + case 'R': + SkipRows++; + break; + case 's': + Scissor = !Scissor; + break; + case 'x': + Xzoom -= 0.1; + break; + case 'X': + Xzoom += 0.1; + break; + case 'y': + Yzoom -= 0.1; + break; + case 'Y': + Yzoom += 0.1; + break; + case 'z': + Zpos -= 0.1; + printf("RasterPos Z = %g\n", Zpos); + break; + case 'Z': + Zpos += 0.1; + printf("RasterPos Z = %g\n", Zpos); + break; + case 'b': + Benchmark(); + break; + case 'F': + Fog = !Fog; + printf("Fog %d\n", Fog); + break; + case 'f': + DrawFront = !DrawFront; + if (DrawFront) + glDrawBuffer(GL_FRONT); + else + glDrawBuffer(GL_BACK); + printf("glDrawBuffer(%s)\n", DrawFront ? "GL_FRONT" : "GL_BACK"); + 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: + Ypos += 1; + break; + case GLUT_KEY_DOWN: + Ypos -= 1; + break; + case GLUT_KEY_LEFT: + Xpos -= 1; + break; + case GLUT_KEY_RIGHT: + Xpos += 1; + break; + } + glutPostRedisplay(); +} + + +static void Init( GLboolean ciMode, const char *filename ) +{ + static const GLfloat fogColor[4] = {0, 1, 0, 0}; + + printf("GL_VERSION = %s\n", (char *) glGetString(GL_VERSION)); + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + Image = LoadRGBImage( filename, &ImgWidth, &ImgHeight, &ImgFormat ); + if (!Image) { + printf("Couldn't read %s\n", filename); + exit(0); + } + + if (ciMode) { + /* Convert RGB image to grayscale */ + GLubyte *indexImage = (GLubyte *) malloc( ImgWidth * ImgHeight ); + GLint i; + for (i=0; i i && strcmp(argv[i], "-ci")==0) { + ciMode = GL_TRUE; + i++; + } + if (argc > i) { + filename = argv[i]; + } + + glutInit( &argc, argv ); + glutInitWindowPosition( 0, 0 ); + glutInitWindowSize( 500, 400 ); + + if (ciMode) + glutInitDisplayMode( GLUT_INDEX | GLUT_DOUBLE ); + else + glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE); + + glutCreateWindow(argv[0]); + + Init(ciMode, filename); + Usage(); + + glutReshapeFunc( Reshape ); + glutKeyboardFunc( Key ); + glutSpecialFunc( SpecialKey ); + glutDisplayFunc( Display ); + + glutMainLoop(); + return 0; +} diff --git a/progs/demos/fire.c b/progs/demos/fire.c new file mode 100644 index 00000000000..dd70f6141db --- /dev/null +++ b/progs/demos/fire.c @@ -0,0 +1,777 @@ +/* + * 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 +#include +#include +#include +#include + +#ifdef WIN32 +#include +#include +#endif + +#include +#include "readtex.h" + +#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; + +static GLint T0 = 0; +static GLint Frames = 0; +static GLint NiceFog = 1; + +#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] = { 1.0, 0.2, 0.0 }; +static float blu2[3] = { 1.0, 1.0, 0.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 = -84.0; +static float beta = 90.0; + +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); + + if (dir[0] < 1.0e-5 && dir[0] > -1.0e-5) + dir[0] = 0; + if (dir[1] < 1.0e-5 && dir[1] > -1.0e-5) + dir[1] = 0; + if (dir[2] < 1.0e-5 && dir[2] > -1.0e-5) + dir[2] = 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 - Toggle 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 - Toggle Fog"); + glRasterPos2i(60, 210); + printstring(GLUT_BITMAP_TIMES_ROMAN_24, "s - Toggle 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 - 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.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 char frbuf[80] = ""; + int j; + static double t0 = -1.; + double t = glutGet(GLUT_ELAPSED_TIME) / 1000.0; + if (t0 < 0.0) + t0 = t; + dt = (t - t0) * 1.0; + t0 = t; + + dojoy(); + + if (NiceFog) + glHint(GL_FOG_HINT, GL_NICEST); + else + glHint(GL_FOG_HINT, GL_DONT_CARE); + + 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); +#if 1 + 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(); +#else + /* Subdivide the ground into a bunch of quads. This improves fog + * if GL_FOG_HINT != GL_NICEST + */ + { + float x, y; + float dx = 1.0, dy = 1.0; + glBegin(GL_QUADS); + for (y = -DIMP; y < DIMP; y += 1.0) { + for (x = -DIMP; x < DIMP; x += 1.0) { + glTexCoord2f(0, 0); glVertex3f(x, 0, y); + glTexCoord2f(1, 0); glVertex3f(x+dx, 0, y); + glTexCoord2f(1, 1); glVertex3f(x+dx, 0, y+dy); + glTexCoord2f(0, 1); glVertex3f(x, 0, y+dy); + } + } + glEnd(); + } +#endif + + + 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(); + + 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(); + + Frames++; + { + GLint t = glutGet(GLUT_ELAPSED_TIME); + if (t - T0 >= 2000) { + GLfloat seconds = (t - T0) / 1000.0; + GLfloat fps = Frames / seconds; + sprintf(frbuf, "Frame rate: %f", fps); + T0 = t; + Frames = 0; + } + } +} + + +static void +idle(void) +{ + glutPostRedisplay(); +} + + +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; + } + glutPostRedisplay(); +} + +static void +key(unsigned char key, int x, int y) +{ + switch (key) { + case 27: + exit(0); + break; + + case 'a': + v += 0.0005; + break; + case 'z': + v -= 0.0005; + 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 + case 'n': + NiceFog = !NiceFog; + printf("NiceFog %d\n", NiceFog); + break; + } + glutPostRedisplay(); +} + +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", (char *) 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 */ + + np = 800; + eject_r = -0.65; + dt = 0.015; + eject_vy = 4; + eject_vl = 1; + shadows = 1; + ridtri = 0.25; + + 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); + + p = (part *) malloc(sizeof(part) * np); + + for (i = 0; i < np; i++) + setnewpart(&p[i]); + + inittree(); + + glutKeyboardFunc(key); + glutSpecialFunc(special); + glutDisplayFunc(drawfire); + glutIdleFunc(idle); + glutReshapeFunc(reshape); + glutMainLoop(); + + return (0); +} diff --git a/progs/demos/fogcoord.c b/progs/demos/fogcoord.c new file mode 100644 index 00000000000..19a15f05b87 --- /dev/null +++ b/progs/demos/fogcoord.c @@ -0,0 +1,420 @@ +/* + * EXT_fog_coord. + * + * Based on glutskel.c by Brian Paul + * and NeHe's Volumetric fog tutorial! + * + * Daniel Borca + */ + + +#include +#include +#include +#include + +#include "readtex.h" + +#define TEXTURE_FILE "../images/bw.rgb" + +#define ARRAYS 0 /* use glDrawElements */ + +#define VERBOSE 1 /* tell me what happens */ + +#define DEPTH 15.0f + +#if !defined(GLAPIENTRYP) +# define GLAPIENTRYP * +#endif + +typedef void (GLAPIENTRYP GLFOGCOORDFEXTPROC) (GLfloat f); +typedef void (GLAPIENTRYP GLFOGCOORDPOINTEREXTPROC) (GLenum, GLsizei, const GLvoid *); + +static GLFOGCOORDFEXTPROC glFogCoordf_ext; +#if ARRAYS +static GLFOGCOORDPOINTEREXTPROC glFogCoordPointer_ext; +#endif +static GLboolean have_fog_coord; + +static GLfloat camz; +static GLuint texture[1]; + +static GLint fogMode; +static GLboolean fogCoord; +static GLfloat fogDensity = 0.75; +static GLfloat fogStart = 1.0, fogEnd = 40.0; +static GLfloat fogColor[4] = {0.6f, 0.3f, 0.0f, 1.0f}; + + +static void APIENTRY glFogCoordf_nop (GLfloat f) +{ + (void)f; +} + + +static int BuildTexture (const char *filename, GLuint texid[]) +{ + GLubyte *tex_data; + GLenum tex_format; + GLint tex_width, tex_height; + + tex_data = LoadRGBImage(filename, &tex_width, &tex_height, &tex_format); + if (tex_data == NULL) { + return -1; + } + + { + GLint tex_max; + glGetIntegerv(GL_MAX_TEXTURE_SIZE, &tex_max); + if ((tex_width > tex_max) || (tex_height > tex_max)) { + return -1; + } + } + + glGenTextures(1, texid); + + glBindTexture(GL_TEXTURE_2D, texid[0]); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + + glTexImage2D(GL_TEXTURE_2D, 0, tex_format, tex_width, tex_height, 0, + tex_format, GL_UNSIGNED_BYTE, tex_data); + + return 0; +} + + +static int SetFogMode (GLint fogMode) +{ + fogMode &= 3; + switch (fogMode) { + case 0: + glDisable(GL_FOG); +#if VERBOSE + printf("fog(disable)\n"); +#endif + break; + case 1: + glEnable(GL_FOG); + glFogi(GL_FOG_MODE, GL_LINEAR); + glFogf(GL_FOG_START, fogStart); + glFogf(GL_FOG_END, fogEnd); +#if VERBOSE + printf("fog(GL_LINEAR, %.2f, %.2f)\n", fogStart, fogEnd); +#endif + break; + case 2: + glEnable(GL_FOG); + glFogi(GL_FOG_MODE, GL_EXP); + glFogf(GL_FOG_DENSITY, fogDensity); +#if VERBOSE + printf("fog(GL_EXP, %.2f)\n", fogDensity); +#endif + break; + case 3: + glEnable(GL_FOG); + glFogi(GL_FOG_MODE, GL_EXP2); + glFogf(GL_FOG_DENSITY, fogDensity); +#if VERBOSE + printf("fog(GL_EXP2, %.2f)\n", fogDensity); +#endif + break; + } + return fogMode; +} + + +static GLboolean SetFogCoord (GLboolean fogCoord) +{ + glFogCoordf_ext = glFogCoordf_nop; + + if (!have_fog_coord) { +#if VERBOSE + printf("fog(GL_FRAGMENT_DEPTH_EXT)%s\n", fogCoord ? " EXT_fog_coord not available!" : ""); +#endif + return GL_FALSE; + } + + if (fogCoord) { + glFogCoordf_ext = (GLFOGCOORDFEXTPROC)glutGetProcAddress("glFogCoordfEXT"); + glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FOG_COORDINATE_EXT); +#if VERBOSE + printf("fog(GL_FOG_COORDINATE_EXT)\n"); +#endif + } else { + glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT); +#if VERBOSE + printf("fog(GL_FRAGMENT_DEPTH_EXT)\n"); +#endif + } + return fogCoord; +} + + +#if ARRAYS +/* could reuse vertices */ +static GLuint vertex_index[] = { + /* Back */ + 0, 1, 2, 3, + + /* Floor */ + 4, 5, 6, 7, + + /* Roof */ + 8, 9, 10, 11, + + /* Right */ + 12, 13, 14, 15, + + /* Left */ + 16, 17, 18, 19 +}; + +static GLfloat vertex_pointer[][3] = { + /* Back */ + {-2.5f,-2.5f,-DEPTH}, { 2.5f,-2.5f,-DEPTH}, { 2.5f, 2.5f,-DEPTH}, {-2.5f, 2.5f,-DEPTH}, + + /* Floor */ + {-2.5f,-2.5f,-DEPTH}, { 2.5f,-2.5f,-DEPTH}, { 2.5f,-2.5f, DEPTH}, {-2.5f,-2.5f, DEPTH}, + + /* Roof */ + {-2.5f, 2.5f,-DEPTH}, { 2.5f, 2.5f,-DEPTH}, { 2.5f, 2.5f, DEPTH}, {-2.5f, 2.5f, DEPTH}, + + /* Right */ + { 2.5f,-2.5f, DEPTH}, { 2.5f, 2.5f, DEPTH}, { 2.5f, 2.5f,-DEPTH}, { 2.5f,-2.5f,-DEPTH}, + + /* Left */ + {-2.5f,-2.5f, DEPTH}, {-2.5f, 2.5f, DEPTH}, {-2.5f, 2.5f,-DEPTH}, {-2.5f,-2.5f,-DEPTH} +}; + +static GLfloat texcoord_pointer[][2] = { + /* Back */ + {0.0f, 0.0f}, {1.0f, 0.0f}, {1.0f, 1.0f}, {0.0f, 1.0f}, + + /* Floor */ + {0.0f, 0.0f}, {1.0f, 0.0f}, {1.0f, 1.0f}, {0.0f, 1.0f}, + + /* Roof */ + {0.0f, 0.0f}, {1.0f, 0.0f}, {1.0f, 1.0f}, {0.0f, 1.0f}, + + /* Right */ + {0.0f, 0.0f}, {0.0f, 1.0f}, {1.0f, 1.0f}, {1.0f, 0.0f}, + + /* Left */ + {0.0f, 0.0f}, {0.0f, 1.0f}, {1.0f, 1.0f}, {1.0f, 0.0f} +}; + +static GLfloat fogcoord_pointer[][1] = { + /* Back */ + {1.0f}, {1.0f}, {1.0f}, {1.0f}, + + /* Floor */ + {1.0f}, {1.0f}, {0.0f}, {0.0f}, + + /* Roof */ + {1.0f}, {1.0f}, {0.0f}, {0.0f}, + + /* Right */ + {0.0f}, {0.0f}, {1.0f}, {1.0f}, + + /* Left */ + {0.0f}, {0.0f}, {1.0f}, {1.0f} +}; +#endif + + +static void Display( void ) +{ + glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glLoadIdentity (); + + glTranslatef(0.0f, 0.0f, camz); + +#if ARRAYS + glDrawElements(GL_QUADS, sizeof(vertex_index) / sizeof(vertex_index[0]), GL_UNSIGNED_INT, vertex_index); +#else + /* Back */ + glBegin(GL_QUADS); + glFogCoordf_ext(1.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f(-2.5f,-2.5f,-DEPTH); + glFogCoordf_ext(1.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f( 2.5f,-2.5f,-DEPTH); + glFogCoordf_ext(1.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f( 2.5f, 2.5f,-DEPTH); + glFogCoordf_ext(1.0f); glTexCoord2f(0.0f, 1.0f); glVertex3f(-2.5f, 2.5f,-DEPTH); + glEnd(); + + /* Floor */ + glBegin(GL_QUADS); + glFogCoordf_ext(1.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f(-2.5f,-2.5f,-DEPTH); + glFogCoordf_ext(1.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f( 2.5f,-2.5f,-DEPTH); + glFogCoordf_ext(0.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f( 2.5f,-2.5f, DEPTH); + glFogCoordf_ext(0.0f); glTexCoord2f(0.0f, 1.0f); glVertex3f(-2.5f,-2.5f, DEPTH); + glEnd(); + + /* Roof */ + glBegin(GL_QUADS); + glFogCoordf_ext(1.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f(-2.5f, 2.5f,-DEPTH); + glFogCoordf_ext(1.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f( 2.5f, 2.5f,-DEPTH); + glFogCoordf_ext(0.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f( 2.5f, 2.5f, DEPTH); + glFogCoordf_ext(0.0f); glTexCoord2f(0.0f, 1.0f); glVertex3f(-2.5f, 2.5f, DEPTH); + glEnd(); + + /* Right */ + glBegin(GL_QUADS); + glFogCoordf_ext(0.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f( 2.5f,-2.5f, DEPTH); + glFogCoordf_ext(0.0f); glTexCoord2f(0.0f, 1.0f); glVertex3f( 2.5f, 2.5f, DEPTH); + glFogCoordf_ext(1.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f( 2.5f, 2.5f,-DEPTH); + glFogCoordf_ext(1.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f( 2.5f,-2.5f,-DEPTH); + glEnd(); + + /* Left */ + glBegin(GL_QUADS); + glFogCoordf_ext(0.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f(-2.5f,-2.5f, DEPTH); + glFogCoordf_ext(0.0f); glTexCoord2f(0.0f, 1.0f); glVertex3f(-2.5f, 2.5f, DEPTH); + glFogCoordf_ext(1.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f(-2.5f, 2.5f,-DEPTH); + glFogCoordf_ext(1.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f(-2.5f,-2.5f,-DEPTH); + glEnd(); +#endif + + glutSwapBuffers(); +} + + +static void Reshape( int width, int height ) +{ + glViewport(0, 0, width, height); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluPerspective(45.0f, (GLfloat)(width)/(GLfloat)(height), 0.1f, 100.0f); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); +} + + +static void Key( unsigned char key, int x, int y ) +{ + (void) x; + (void) y; + switch (key) { + case 'f': + fogMode = SetFogMode(fogMode + 1); + break; + case '+': + if (fogDensity < 1.0) { + fogDensity += 0.05; + } + SetFogMode(fogMode); + break; + case '-': + if (fogDensity > 0.0) { + fogDensity -= 0.05; + } + SetFogMode(fogMode); + break; + case 's': + if (fogStart > 0.0) { + fogStart -= 1.0; + } + SetFogMode(fogMode); + break; + case 'S': + if (fogStart < fogEnd) { + fogStart += 1.0; + } + SetFogMode(fogMode); + break; + case 'e': + if (fogEnd > fogStart) { + fogEnd -= 1.0; + } + SetFogMode(fogMode); + break; + case 'E': + if (fogEnd < 100.0) { + fogEnd += 1.0; + } + SetFogMode(fogMode); + break; + case 'c': + fogCoord = SetFogCoord(fogCoord ^ GL_TRUE); + 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 (camz < (DEPTH - 1.0)) { + camz += 1.0f; + } + break; + case GLUT_KEY_DOWN: + if (camz > -19.0) { + camz -= 1.0f; + } + break; + } + glutPostRedisplay(); +} + + +static void Init( void ) +{ + have_fog_coord = glutExtensionSupported("GL_EXT_fog_coord"); + + if (BuildTexture(TEXTURE_FILE, texture) == -1) { + exit(1); + } + + glEnable(GL_TEXTURE_2D); + glClearColor(0.0f, 0.0f, 0.0f, 0.5f); + glClearDepth(1.0f); + glDepthFunc(GL_LEQUAL); + glEnable(GL_DEPTH_TEST); + glShadeModel(GL_SMOOTH); + glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); + + glFogfv(GL_FOG_COLOR, fogColor); + glHint(GL_FOG_HINT, GL_NICEST); + fogCoord = SetFogCoord(GL_TRUE); /* try to enable fog_coord */ + fogMode = SetFogMode(2); /* GL_EXP */ + + camz = -19.0f; + +#if ARRAYS + glEnableClientState(GL_VERTEX_ARRAY); + glVertexPointer(3, GL_FLOAT, 0, vertex_pointer); + + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + glTexCoordPointer(2, GL_FLOAT, 0, texcoord_pointer); + + if (have_fog_coord) { + glFogCoordPointer_ext = (GLFOGCOORDPOINTEREXTPROC)glutGetProcAddress("glFogCoordPointerEXT"); + glEnableClientState(GL_FOG_COORDINATE_ARRAY_EXT); + glFogCoordPointer_ext(GL_FLOAT, 0, fogcoord_pointer); + } +#endif +} + + +int main( int argc, char *argv[] ) +{ + glutInit( &argc, argv ); + glutInitWindowPosition( 0, 0 ); + glutInitWindowSize( 640, 480 ); + glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ); + glutCreateWindow(argv[0]); + glutReshapeFunc( Reshape ); + glutKeyboardFunc( Key ); + glutSpecialFunc( SpecialKey ); + glutDisplayFunc( Display ); + Init(); + glutMainLoop(); + return 0; +} diff --git a/progs/demos/fplight.c b/progs/demos/fplight.c new file mode 100644 index 00000000000..c7a38248d38 --- /dev/null +++ b/progs/demos/fplight.c @@ -0,0 +1,285 @@ +/* + * Use GL_NV_fragment_program to implement per-pixel lighting. + * + * Brian Paul + * 7 April 2003 + */ + +#include +#include +#include +#include +#include +#define GL_GLEXT_PROTOTYPES +#include + + +static GLfloat Diffuse[4] = { 0.5, 0.5, 1.0, 1.0 }; +static GLfloat Specular[4] = { 0.8, 0.8, 0.8, 1.0 }; +static GLfloat LightPos[4] = { 0.0, 10.0, 20.0, 1.0 }; +static GLfloat Delta = 1.0; + +static GLuint FragProg; +static GLuint VertProg; +static GLboolean Anim = GL_TRUE; +static GLboolean Wire = GL_FALSE; +static GLboolean PixelLight = GL_TRUE; + +static GLfloat Xrot = 0, Yrot = 0; + + +#define NAMED_PARAMETER4FV(prog, name, v) \ + glProgramNamedParameter4fvNV(prog, strlen(name), (const GLubyte *) name, v) + + +static void Display( void ) +{ + glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); + + if (PixelLight) { +#if defined(GL_NV_fragment_program) + NAMED_PARAMETER4FV(FragProg, "LightPos", LightPos); + glEnable(GL_FRAGMENT_PROGRAM_NV); + glEnable(GL_VERTEX_PROGRAM_NV); +#endif + glDisable(GL_LIGHTING); + } + else { + glLightfv(GL_LIGHT0, GL_POSITION, LightPos); +#if defined(GL_NV_fragment_program) + glDisable(GL_FRAGMENT_PROGRAM_NV); + glDisable(GL_VERTEX_PROGRAM_NV); +#endif + glEnable(GL_LIGHTING); + } + + glPushMatrix(); + glRotatef(Xrot, 1, 0, 0); + glRotatef(Yrot, 0, 1, 0); + +#if 1 + glutSolidSphere(2.0, 10, 5); +#else + { + GLUquadricObj *q = gluNewQuadric(); + gluQuadricNormals(q, GL_SMOOTH); + gluQuadricTexture(q, GL_TRUE); + glRotatef(90, 1, 0, 0); + glTranslatef(0, 0, -1); + gluCylinder(q, 1.0, 1.0, 2.0, 24, 1); + gluDeleteQuadric(q); + } +#endif + + glPopMatrix(); + + glutSwapBuffers(); +} + + +static void Idle(void) +{ + LightPos[0] += Delta; + if (LightPos[0] > 25.0) + Delta = -1.0; + else if (LightPos[0] <- 25.0) + Delta = 1.0; + glutPostRedisplay(); +} + + +static void Reshape( int width, int height ) +{ + glViewport( 0, 0, width, height ); + glMatrixMode( GL_PROJECTION ); + glLoadIdentity(); + glFrustum( -1.0, 1.0, -1.0, 1.0, 5.0, 25.0 ); + /*glOrtho( -2.0, 2.0, -2.0, 2.0, 5.0, 25.0 );*/ + glMatrixMode( GL_MODELVIEW ); + glLoadIdentity(); + glTranslatef( 0.0, 0.0, -15.0 ); +} + + +static void Key( unsigned char key, int x, int y ) +{ + (void) x; + (void) y; + switch (key) { + case ' ': + Anim = !Anim; + if (Anim) + glutIdleFunc(Idle); + else + glutIdleFunc(NULL); + break; + case 'x': + LightPos[0] -= 1.0; + break; + case 'X': + LightPos[0] += 1.0; + break; + case 'w': + Wire = !Wire; + if (Wire) + glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); + else + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); + break; + case 'p': + PixelLight = !PixelLight; + if (PixelLight) { + printf("Per-pixel lighting\n"); + } + else { + printf("Conventional lighting\n"); + } + 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 ) +{ + static const char *fragProgramText = + "!!FP1.0\n" + "DECLARE Diffuse; \n" + "DECLARE Specular; \n" + "DECLARE LightPos; \n" + + "# Compute normalized LightPos, put it in R0\n" + "DP3 R0.x, LightPos, LightPos;\n" + "RSQ R0.y, R0.x;\n" + "MUL R0, LightPos, R0.y;\n" + + "# Compute normalized normal, put it in R1\n" + "DP3 R1, f[TEX0], f[TEX0]; \n" + "RSQ R1.y, R1.x;\n" + "MUL R1, f[TEX0], R1.y;\n" + + "# Compute dot product of light direction and normal vector\n" + "DP3_SAT R2, R0, R1;" + + "MUL R3, Diffuse, R2; # diffuse attenuation\n" + + "POW R4, R2.x, {20.0}.x; # specular exponent\n" + + "MUL R5, Specular, R4; # specular attenuation\n" + + "ADD o[COLR], R3, R5; # add diffuse and specular colors\n" + "END \n" + ; + + static const char *vertProgramText = + "!!VP1.0\n" + "# typical modelview/projection transform\n" + "DP4 o[HPOS].x, c[0], v[OPOS] ;\n" + "DP4 o[HPOS].y, c[1], v[OPOS] ;\n" + "DP4 o[HPOS].z, c[2], v[OPOS] ;\n" + "DP4 o[HPOS].w, c[3], v[OPOS] ;\n" + "# transform normal by inv transpose of modelview, put in tex0\n" + "DP3 o[TEX0].x, c[4], v[NRML] ;\n" + "DP3 o[TEX0].y, c[5], v[NRML] ;\n" + "DP3 o[TEX0].z, c[6], v[NRML] ;\n" + "DP3 o[TEX0].w, c[7], v[NRML] ;\n" + "END\n"; + ; + + if (!glutExtensionSupported("GL_NV_vertex_program")) { + printf("Sorry, this demo requires GL_NV_vertex_program\n"); + exit(1); + } + if (!glutExtensionSupported("GL_NV_fragment_program")) { + printf("Sorry, this demo requires GL_NV_fragment_program\n"); + exit(1); + } + +#if defined(GL_NV_fragment_program) + glGenProgramsNV(1, &FragProg); + assert(FragProg > 0); + glGenProgramsNV(1, &VertProg); + assert(VertProg > 0); + + /* + * Fragment program + */ + glLoadProgramNV(GL_FRAGMENT_PROGRAM_NV, FragProg, + strlen(fragProgramText), + (const GLubyte *) fragProgramText); + assert(glIsProgramNV(FragProg)); + glBindProgramNV(GL_FRAGMENT_PROGRAM_NV, FragProg); + + NAMED_PARAMETER4FV(FragProg, "Diffuse", Diffuse); + NAMED_PARAMETER4FV(FragProg, "Specular", Specular); + + /* + * Vertex program + */ + glLoadProgramNV(GL_VERTEX_PROGRAM_NV, VertProg, + strlen(vertProgramText), + (const GLubyte *) vertProgramText); + assert(glIsProgramNV(VertProg)); + glBindProgramNV(GL_VERTEX_PROGRAM_NV, VertProg); + glTrackMatrixNV(GL_VERTEX_PROGRAM_NV, 0, GL_MODELVIEW_PROJECTION_NV, GL_IDENTITY_NV); + glTrackMatrixNV(GL_VERTEX_PROGRAM_NV, 4, GL_MODELVIEW, GL_INVERSE_TRANSPOSE_NV); +#endif + + /* + * Misc init + */ + glClearColor(0.3, 0.3, 0.3, 0.0); + glEnable(GL_DEPTH_TEST); + glEnable(GL_LIGHT0); + glEnable(GL_LIGHTING); + glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, Diffuse); + glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, Specular); + glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 20.0); + + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + printf("Press p to toggle between per-pixel and per-vertex lighting\n"); +} + + +int main( int argc, char *argv[] ) +{ + glutInit( &argc, argv ); + glutInitWindowPosition( 0, 0 ); + glutInitWindowSize( 200, 200 ); + glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ); + glutCreateWindow(argv[0]); + glutReshapeFunc( Reshape ); + glutKeyboardFunc( Key ); + glutSpecialFunc( SpecialKey ); + glutDisplayFunc( Display ); + if (Anim) + glutIdleFunc(Idle); + Init(); + glutMainLoop(); + return 0; +} diff --git a/progs/demos/gamma.c b/progs/demos/gamma.c new file mode 100644 index 00000000000..9b2c3e1052b --- /dev/null +++ b/progs/demos/gamma.c @@ -0,0 +1,162 @@ + +/* Draw test patterns to help determine correct gamma value for a display. + When the intensities of the inner squares nearly match the intensities + of their frames (from some distance the borders should disappear) then + you've found the right gamma value. + + You can set Mesa's gamma values (for red, green and blue) with the + MESA_GAMMA environment variable. But only on X windows! + For example: + setenv MESA_GAMMA 1.5 1.6 1.4 + Sets the red gamma value to 1.5, green to 1.6 and blue to 1.4. + See the main README file for more information. + + For more info about gamma correction see: + http://www.inforamp.net/~poynton/notes/colour_and_gamma/GammaFAQ.html + + This program is in the public domain + + Brian Paul 19 Oct 1995 + Kai Schuetz 05 Jun 1999 */ + +/* Conversion to GLUT by Mark J. Kilgard */ + + +#include +#include +#include +#include + +static void +Reshape(int width, int height) +{ + glViewport(0, 0, (GLint) width, (GLint) height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0); + glMatrixMode(GL_MODELVIEW); + glShadeModel(GL_FLAT); +} + +/* ARGSUSED1 */ +static void +key_esc(unsigned char key, int x, int y) +{ + if(key == 27) exit(0); /* Exit on Escape */ +} + +static GLubyte p25[] = { + 0xaa, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0x00, 0x00, + 0xaa, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0x00, 0x00, + 0xaa, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0x00, 0x00, + 0xaa, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0x00, 0x00, + 0xaa, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0x00, 0x00, + 0xaa, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0x00, 0x00, + 0xaa, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0x00, 0x00, + 0xaa, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0x00, 0x00, + 0xaa, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0x00, 0x00, + 0xaa, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0x00, 0x00, + 0xaa, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0x00, 0x00, + 0xaa, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0x00, 0x00, + 0xaa, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0x00, 0x00, + 0xaa, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0x00, 0x00, + 0xaa, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0x00, 0x00, + 0xaa, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0x00, 0x00, +}; + +static GLubyte p50[] = { + 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, +}; + +static GLubyte p75[] = { + 0xaa, 0xaa, 0xaa, 0xaa, 0xff, 0xff, 0xff, 0xff, + 0xaa, 0xaa, 0xaa, 0xaa, 0xff, 0xff, 0xff, 0xff, + 0xaa, 0xaa, 0xaa, 0xaa, 0xff, 0xff, 0xff, 0xff, + 0xaa, 0xaa, 0xaa, 0xaa, 0xff, 0xff, 0xff, 0xff, + 0xaa, 0xaa, 0xaa, 0xaa, 0xff, 0xff, 0xff, 0xff, + 0xaa, 0xaa, 0xaa, 0xaa, 0xff, 0xff, 0xff, 0xff, + 0xaa, 0xaa, 0xaa, 0xaa, 0xff, 0xff, 0xff, 0xff, + 0xaa, 0xaa, 0xaa, 0xaa, 0xff, 0xff, 0xff, 0xff, + 0xaa, 0xaa, 0xaa, 0xaa, 0xff, 0xff, 0xff, 0xff, + 0xaa, 0xaa, 0xaa, 0xaa, 0xff, 0xff, 0xff, 0xff, + 0xaa, 0xaa, 0xaa, 0xaa, 0xff, 0xff, 0xff, 0xff, + 0xaa, 0xaa, 0xaa, 0xaa, 0xff, 0xff, 0xff, 0xff, + 0xaa, 0xaa, 0xaa, 0xaa, 0xff, 0xff, 0xff, 0xff, + 0xaa, 0xaa, 0xaa, 0xaa, 0xff, 0xff, 0xff, 0xff, + 0xaa, 0xaa, 0xaa, 0xaa, 0xff, 0xff, 0xff, 0xff, + 0xaa, 0xaa, 0xaa, 0xaa, 0xff, 0xff, 0xff, 0xff, +}; + +static GLubyte *stippletab[4] = {NULL, p25, p50, p75}; + +static void +gamma_ramp(GLfloat yoffs, GLfloat r, GLfloat g, GLfloat b) +{ + GLint d; + + glColor3f(0.0, 0.0, 0.0); /* solid black, no stipple */ + glRectf(-1.0, yoffs, -0.6, yoffs + 0.5); + + 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 */ + glRectf(xcoord, yoffs, xcoord+0.4, yoffs + 0.5); + + glColor3f(0.0, 0.0, 0.0); /* "clear" inner rect */ + glRectf(xcoord + 0.1, yoffs + 0.125, xcoord + 0.3, yoffs + 0.375); + + glColor3f(r, g, b); /* draw stippled inner rect */ + glEnable(GL_POLYGON_STIPPLE); + glPolygonStipple(stippletab[d]); + glRectf(xcoord + 0.1, yoffs + 0.125, xcoord + 0.3, yoffs + 0.375); + glDisable(GL_POLYGON_STIPPLE); + } + glColor3f(r, g, b); /* solid color, no stipple */ + glRectf(0.6, yoffs, 1.0, yoffs + 0.5); +} + +static void +display(void) +{ + gamma_ramp( 0.5, 1.0, 1.0, 1.0); /* white ramp */ + gamma_ramp( 0.0, 1.0, 0.0, 0.0); /* red ramp */ + gamma_ramp(-0.5, 0.0, 1.0, 0.0); /* green ramp */ + gamma_ramp(-1.0, 0.0, 0.0, 1.0); /* blue ramp */ + glFlush(); +} + +int +main(int argc, char **argv) +{ + glutInit(&argc, argv); + glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE); + + glutInitWindowPosition(50, 50); + glutInitWindowSize(500, 400); + + glutCreateWindow("gamma test patterns"); + glutReshapeFunc(Reshape); + glutDisplayFunc(display); + glutKeyboardFunc(key_esc); + + glutMainLoop(); + return 0; /* ANSI C requires main to return int. */ +} diff --git a/progs/demos/gearbox.c b/progs/demos/gearbox.c new file mode 100644 index 00000000000..3a1662cd625 --- /dev/null +++ b/progs/demos/gearbox.c @@ -0,0 +1,485 @@ +/* + * Use glCopyTexSubImage2D to draw animated gears on the sides of a box. + * + * Brian Paul + * 27 January 2006 + */ + +#include +#include +#include +#include +#include + +#ifndef M_PI +#define M_PI 3.14159265 +#endif + +static GLint WinWidth = 800, WinHeight = 500; +static GLint TexWidth, TexHeight; +static GLuint TexObj = 1; +static GLenum IntFormat = GL_RGB; + +static GLboolean WireFrame = GL_FALSE; + +static GLint T0 = 0; +static GLint Frames = 0; +static GLint Win = 0; + +static GLfloat ViewRotX = 20.0, ViewRotY = 30.0, ViewRotZ = 0.0; +static GLint Gear1, Gear2, Gear3; +static GLfloat GearRot = 0.0; +static GLfloat CubeRot = 0.0; + + +/** + Draw a gear wheel. You'll probably want to call this function when + building a display list since we do a lot of trig here. + + Input: inner_radius - radius of hole at center + outer_radius - radius at center of teeth + width - width of gear + teeth - number of teeth + tooth_depth - depth of tooth + **/ +static void +gear(GLfloat inner_radius, GLfloat outer_radius, GLfloat width, + GLint teeth, GLfloat tooth_depth) +{ + GLint i; + GLfloat r0, r1, r2; + GLfloat angle, da; + GLfloat u, v, len; + + r0 = inner_radius; + r1 = outer_radius - tooth_depth / 2.0; + r2 = outer_radius + tooth_depth / 2.0; + + da = 2.0 * M_PI / teeth / 4.0; + + glShadeModel(GL_FLAT); + + glNormal3f(0.0, 0.0, 1.0); + + /* draw front face */ + glBegin(GL_QUAD_STRIP); + for (i = 0; i <= teeth; i++) { + angle = i * 2.0 * M_PI / teeth; + glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5); + glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5); + if (i < teeth) { + glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5); + glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), width * 0.5); + } + } + glEnd(); + + /* draw front sides of teeth */ + glBegin(GL_QUADS); + da = 2.0 * M_PI / teeth / 4.0; + for (i = 0; i < teeth; i++) { + angle = i * 2.0 * M_PI / teeth; + + glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5); + glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), width * 0.5); + glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), width * 0.5); + glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), width * 0.5); + } + glEnd(); + + glNormal3f(0.0, 0.0, -1.0); + + /* draw back face */ + glBegin(GL_QUAD_STRIP); + for (i = 0; i <= teeth; i++) { + angle = i * 2.0 * M_PI / teeth; + glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5); + glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5); + if (i < teeth) { + glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), -width * 0.5); + glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5); + } + } + glEnd(); + + /* draw back sides of teeth */ + glBegin(GL_QUADS); + da = 2.0 * M_PI / teeth / 4.0; + for (i = 0; i < teeth; i++) { + angle = i * 2.0 * M_PI / teeth; + + glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), -width * 0.5); + glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), -width * 0.5); + glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), -width * 0.5); + glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5); + } + glEnd(); + + /* draw outward faces of teeth */ + glBegin(GL_QUAD_STRIP); + for (i = 0; i < teeth; i++) { + angle = i * 2.0 * M_PI / teeth; + + glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5); + glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5); + u = r2 * cos(angle + da) - r1 * cos(angle); + v = r2 * sin(angle + da) - r1 * sin(angle); + len = sqrt(u * u + v * v); + u /= len; + v /= len; + glNormal3f(v, -u, 0.0); + glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), width * 0.5); + glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), -width * 0.5); + glNormal3f(cos(angle), sin(angle), 0.0); + glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), width * 0.5); + glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), -width * 0.5); + u = r1 * cos(angle + 3 * da) - r2 * cos(angle + 2 * da); + v = r1 * sin(angle + 3 * da) - r2 * sin(angle + 2 * da); + glNormal3f(v, -u, 0.0); + glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), width * 0.5); + glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), -width * 0.5); + glNormal3f(cos(angle), sin(angle), 0.0); + } + + glVertex3f(r1 * cos(0), r1 * sin(0), width * 0.5); + glVertex3f(r1 * cos(0), r1 * sin(0), -width * 0.5); + + glEnd(); + + glShadeModel(GL_SMOOTH); + + /* draw inside radius cylinder */ + glBegin(GL_QUAD_STRIP); + for (i = 0; i <= teeth; i++) { + angle = i * 2.0 * M_PI / teeth; + glNormal3f(-cos(angle), -sin(angle), 0.0); + glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5); + glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5); + } + glEnd(); + +} + +static void +cleanup(void) +{ + glDeleteTextures(1, &TexObj); + glDeleteLists(Gear1, 1); + glDeleteLists(Gear2, 1); + glDeleteLists(Gear3, 1); + glutDestroyWindow(Win); +} + + +static void +DrawGears(void) +{ + if (WireFrame) { + glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); + } + + glPushMatrix(); + glRotatef(20/*ViewRotX*/, 1.0, 0.0, 0.0); + glRotatef(ViewRotY, 0.0, 1.0, 0.0); + glRotatef(ViewRotZ, 0.0, 0.0, 1.0); + + glPushMatrix(); + glTranslatef(-3.0, -2.0, 0.0); + glRotatef(GearRot, 0.0, 0.0, 1.0); + glCallList(Gear1); + glPopMatrix(); + + glPushMatrix(); + glTranslatef(3.1, -2.0, 0.0); + glRotatef(-2.0 * GearRot - 9.0, 0.0, 0.0, 1.0); + glCallList(Gear2); + glPopMatrix(); + + glPushMatrix(); + glTranslatef(-3.1, 4.2, 0.0); + glRotatef(-2.0 * GearRot - 25.0, 0.0, 0.0, 1.0); + glCallList(Gear3); + glPopMatrix(); + + glPopMatrix(); + + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); +} + + +static void +DrawCube(void) +{ + static const GLfloat texcoords[4][2] = { + { 0, 0 }, { 1, 0 }, { 1, 1 }, { 0, 1 } + }; + static const GLfloat vertices[4][2] = { + { -1, -1 }, { 1, -1 }, { 1, 1 }, { -1, 1 } + }; + static const GLfloat xforms[6][4] = { + { 0, 0, 1, 0 }, + { 90, 0, 1, 0 }, + { 180, 0, 1, 0 }, + { 270, 0, 1, 0 }, + { 90, 1, 0, 0 }, + { -90, 1, 0, 0 } + }; + static const GLfloat mat[4] = { 1.0, 1.0, 0.5, 1.0 }; + GLint i, j; + + glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat); + glEnable(GL_TEXTURE_2D); + + glPushMatrix(); + glRotatef(ViewRotX, 1.0, 0.0, 0.0); + glRotatef(15, 1, 0, 0); + glRotatef(CubeRot, 0, 1, 0); + glScalef(4, 4, 4); + + for (i = 0; i < 6; i++) { + glPushMatrix(); + glRotatef(xforms[i][0], xforms[i][1], xforms[i][2], xforms[i][3]); + glTranslatef(0, 0, 1.1); + glBegin(GL_POLYGON); + glNormal3f(0, 0, 1); + for (j = 0; j < 4; j++) { + glTexCoord2fv(texcoords[j]); + glVertex2fv(vertices[j]); + } + glEnd(); + glPopMatrix(); + } + glPopMatrix(); + + glDisable(GL_TEXTURE_2D); +} + + +static void +draw(void) +{ + float ar; + + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTranslatef(0.0, 0.0, -40.0); + + glDisable(GL_SCISSOR_TEST); + glClear(GL_DEPTH_BUFFER_BIT); + glEnable(GL_SCISSOR_TEST); + + /* draw gears */ + glViewport(0, 0, TexWidth, TexHeight); + glScissor(0, 0, TexWidth, TexHeight); + glClearColor(0.5, 0.5, 0.8, 0.0); + glClearColor(1, 1, 1, 0); + glClear(GL_COLOR_BUFFER_BIT); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glFrustum(-1.0, 1.0, -1.0, 1.0, 5.0, 60.0); + glMatrixMode(GL_MODELVIEW); + + DrawGears(); + + glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, TexWidth, TexHeight); + + /* draw textured cube */ + glViewport(TexWidth, 0, WinWidth - TexWidth, WinHeight); + glScissor(TexWidth, 0, WinWidth - TexWidth, WinHeight); + glClearColor(0.5, 0.5, 0.8, 0.0); + glClear(GL_COLOR_BUFFER_BIT); + + ar = (float) (WinWidth - TexWidth) / WinHeight; + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glFrustum(-ar, ar, -1.0, 1.0, 5.0, 60.0); + glMatrixMode(GL_MODELVIEW); + + DrawCube(); + + /* finish up */ + 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); + T0 = t; + Frames = 0; + } + } +} + + +static void +idle(void) +{ + static double t0 = -1.; + double dt, t = glutGet(GLUT_ELAPSED_TIME) / 1000.0; + if (t0 < 0.0) + t0 = t; + dt = t - t0; + t0 = t; + + /* fmod to prevent overflow */ + GearRot = fmod(GearRot + 70.0 * dt, 360.0); /* 70 deg/sec */ + CubeRot = fmod(CubeRot + 15.0 * dt, 360.0); /* 15 deg/sec */ + + glutPostRedisplay(); +} + + +/* change view angle, exit upon ESC */ +static void +key(unsigned char k, int x, int y) +{ + (void) x; + (void) y; + switch (k) { + case 'w': + WireFrame = !WireFrame; + break; + case 'z': + ViewRotZ += 5.0; + break; + case 'Z': + ViewRotZ -= 5.0; + break; + case 27: /* Escape */ + cleanup(); + exit(0); + break; + default: + return; + } + glutPostRedisplay(); +} + +/* change view angle */ +static void +special(int k, int x, int y) +{ + (void) x; + (void) y; + switch (k) { + case GLUT_KEY_UP: + ViewRotX += 5.0; + break; + case GLUT_KEY_DOWN: + ViewRotX -= 5.0; + break; + case GLUT_KEY_LEFT: + ViewRotY += 5.0; + break; + case GLUT_KEY_RIGHT: + ViewRotY -= 5.0; + break; + default: + return; + } + glutPostRedisplay(); +} + + +/* new window size or exposure */ +static void +reshape(int width, int height) +{ + WinWidth = width; + WinHeight = 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; + + glLightfv(GL_LIGHT0, GL_POSITION, pos); +#if 0 + glEnable(GL_CULL_FACE); +#endif + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + glEnable(GL_DEPTH_TEST); + + /* make the gears */ + Gear1 = glGenLists(1); + glNewList(Gear1, GL_COMPILE); + glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, red); + gear(1.0, 4.0, 1.0, 20, 0.7); + glEndList(); + + Gear2 = glGenLists(1); + glNewList(Gear2, GL_COMPILE); + glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, green); + gear(0.5, 2.0, 2.0, 10, 0.7); + glEndList(); + + Gear3 = glGenLists(1); + glNewList(Gear3, GL_COMPILE); + glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, blue); + gear(1.3, 2.0, 0.5, 10, 0.7); + glEndList(); + + glEnable(GL_NORMALIZE); + + /* xxx make size dynamic */ + TexWidth = 256; + TexHeight = 256; + + glBindTexture(GL_TEXTURE_2D, TexObj); + glTexImage2D(GL_TEXTURE_2D, 0, IntFormat, TexWidth, TexHeight, 0, + GL_RGBA, GL_UNSIGNED_BYTE, NULL); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + + for ( i=1; i +#include +#include +#include +#include + +#ifndef M_PI +#define M_PI 3.14159265 +#endif + +static GLint T0 = 0; +static GLint Frames = 0; +static GLint autoexit = 0; +static GLint win = 0; + + +/** + + Draw a gear wheel. You'll probably want to call this function when + building a display list since we do a lot of trig here. + + Input: inner_radius - radius of hole at center + outer_radius - radius at center of teeth + width - width of gear + teeth - number of teeth + tooth_depth - depth of tooth + + **/ + +static void +gear(GLfloat inner_radius, GLfloat outer_radius, GLfloat width, + GLint teeth, GLfloat tooth_depth) +{ + GLint i; + GLfloat r0, r1, r2; + GLfloat angle, da; + GLfloat u, v, len; + + r0 = inner_radius; + r1 = outer_radius - tooth_depth / 2.0; + r2 = outer_radius + tooth_depth / 2.0; + + da = 2.0 * M_PI / teeth / 4.0; + + glShadeModel(GL_FLAT); + + glNormal3f(0.0, 0.0, 1.0); + + /* draw front face */ + glBegin(GL_QUAD_STRIP); + for (i = 0; i <= teeth; i++) { + angle = i * 2.0 * M_PI / teeth; + glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5); + glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5); + if (i < teeth) { + glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5); + glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), width * 0.5); + } + } + glEnd(); + + /* draw front sides of teeth */ + glBegin(GL_QUADS); + da = 2.0 * M_PI / teeth / 4.0; + for (i = 0; i < teeth; i++) { + angle = i * 2.0 * M_PI / teeth; + + glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5); + glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), width * 0.5); + glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), width * 0.5); + glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), width * 0.5); + } + glEnd(); + + glNormal3f(0.0, 0.0, -1.0); + + /* draw back face */ + glBegin(GL_QUAD_STRIP); + for (i = 0; i <= teeth; i++) { + angle = i * 2.0 * M_PI / teeth; + glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5); + glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5); + if (i < teeth) { + glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), -width * 0.5); + glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5); + } + } + glEnd(); + + /* draw back sides of teeth */ + glBegin(GL_QUADS); + da = 2.0 * M_PI / teeth / 4.0; + for (i = 0; i < teeth; i++) { + angle = i * 2.0 * M_PI / teeth; + + glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), -width * 0.5); + glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), -width * 0.5); + glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), -width * 0.5); + glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5); + } + glEnd(); + + /* draw outward faces of teeth */ + glBegin(GL_QUAD_STRIP); + for (i = 0; i < teeth; i++) { + angle = i * 2.0 * M_PI / teeth; + + glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5); + glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5); + u = r2 * cos(angle + da) - r1 * cos(angle); + v = r2 * sin(angle + da) - r1 * sin(angle); + len = sqrt(u * u + v * v); + u /= len; + v /= len; + glNormal3f(v, -u, 0.0); + glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), width * 0.5); + glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), -width * 0.5); + glNormal3f(cos(angle), sin(angle), 0.0); + glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), width * 0.5); + glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), -width * 0.5); + u = r1 * cos(angle + 3 * da) - r2 * cos(angle + 2 * da); + v = r1 * sin(angle + 3 * da) - r2 * sin(angle + 2 * da); + glNormal3f(v, -u, 0.0); + glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), width * 0.5); + glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), -width * 0.5); + glNormal3f(cos(angle), sin(angle), 0.0); + } + + glVertex3f(r1 * cos(0), r1 * sin(0), width * 0.5); + glVertex3f(r1 * cos(0), r1 * sin(0), -width * 0.5); + + glEnd(); + + glShadeModel(GL_SMOOTH); + + /* draw inside radius cylinder */ + glBegin(GL_QUAD_STRIP); + for (i = 0; i <= teeth; i++) { + angle = i * 2.0 * M_PI / teeth; + glNormal3f(-cos(angle), -sin(angle), 0.0); + glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5); + glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5); + } + glEnd(); + +} + +static GLfloat view_rotx = 20.0, view_roty = 30.0, view_rotz = 0.0; +static GLint gear1, gear2, gear3; +static GLfloat angle = 0.0; + +static void +cleanup(void) +{ + glDeleteLists(gear1, 1); + glDeleteLists(gear2, 1); + glDeleteLists(gear3, 1); + glutDestroyWindow(win); +} + +static void +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); + + 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, 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); + T0 = t; + Frames = 0; + if ((t >= 999.0 * autoexit) && (autoexit)) { + cleanup(); + exit(0); + } + } + } +} + + +static void +idle(void) +{ + static double t0 = -1.; + double dt, t = glutGet(GLUT_ELAPSED_TIME) / 1000.0; + if (t0 < 0.0) + t0 = t; + dt = t - t0; + t0 = t; + + angle += 70.0 * dt; /* 70 degrees per second */ + angle = fmod(angle, 360.0); /* prevents eventual overflow */ + + glutPostRedisplay(); +} + +/* change view angle, exit upon ESC */ +/* ARGSUSED1 */ +static void +key(unsigned char k, int x, int y) +{ + switch (k) { + case 'z': + view_rotz += 5.0; + break; + case 'Z': + view_rotz -= 5.0; + break; + case 27: /* Escape */ + cleanup(); + exit(0); + break; + default: + return; + } + glutPostRedisplay(); +} + +/* change view angle */ +/* ARGSUSED1 */ +static void +special(int k, int x, int y) +{ + switch (k) { + case GLUT_KEY_UP: + view_rotx += 5.0; + break; + case GLUT_KEY_DOWN: + view_rotx -= 5.0; + break; + case GLUT_KEY_LEFT: + view_roty += 5.0; + break; + case GLUT_KEY_RIGHT: + view_roty -= 5.0; + break; + default: + return; + } + glutPostRedisplay(); +} + +/* new window size or exposure */ +static void +reshape(int width, int height) +{ + GLfloat h = (GLfloat) height / (GLfloat) width; + + glViewport(0, 0, (GLint) width, (GLint) height); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glFrustum(-1.0, 1.0, -h, h, 5.0, 60.0); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTranslatef(0.0, 0.0, -40.0); +} + +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; + + glLightfv(GL_LIGHT0, GL_POSITION, pos); + glEnable(GL_CULL_FACE); + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + glEnable(GL_DEPTH_TEST); + + /* make the gears */ + gear1 = glGenLists(1); + glNewList(gear1, GL_COMPILE); + glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, red); + gear(1.0, 4.0, 1.0, 20, 0.7); + glEndList(); + + gear2 = glGenLists(1); + glNewList(gear2, GL_COMPILE); + glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, green); + gear(0.5, 2.0, 2.0, 10, 0.7); + glEndList(); + + gear3 = glGenLists(1); + glNewList(gear3, GL_COMPILE); + glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, blue); + gear(1.3, 2.0, 0.5, 10, 0.7); + glEndList(); + + glEnable(GL_NORMALIZE); + + for ( i=1; i + * + * 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 + * SHOBHAN KUMAR DUTTA 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 +#include +#include +#include +#include + +#ifndef min +#define min(x, y) ( x < y ? x : y ) +#endif + +#ifndef M_PI +#define M_PI 3.14159265 +#endif /* */ +typedef GLfloat TDA[4]; + +TDA background; + + +struct AXLE + { + char name[20]; + GLint id; + GLfloat radius; + GLint axis; + TDA color; + TDA position; + GLfloat length; + GLint motored; + GLfloat angular_velocity; + GLint direction; + }; + + +struct GEAR + { + char name[20]; + char type[7]; + GLint face; + GLint id; + GLfloat radius; + GLfloat width; + GLint teeth; + GLfloat tooth_depth; + GLfloat angle; + GLfloat angular_velocity; + TDA color; + GLint relative_position; + TDA position; + char axle_name[20]; + GLint axis; + GLint direction; + GLint motored; + }; + + +struct BELT + { + char name[20]; + GLint id; + char gear1_name[20]; + char gear2_name[20]; + }; + + +FILE * mainfile; +struct GEAR g[10]; +struct AXLE a[10]; +struct BELT b[10]; +int number_of_gears; +int number_of_axles; +int number_of_belts; + + +char Buf1[256], Buf2[256], Buf3[256], Buf4[256], Buf5[256]; + +static GLint T0 = 0; +static GLint Frames = 0; + + +#ifndef _WIN32 +static void +strset (char buf[], char ch) +{ + int i; + for (i = 0; i < strlen (buf); i++) + buf[i] = ch; +} +#endif + + +static void +Clear_Buffers () +{ + strset (Buf1, 0); + strset (Buf2, 0); + strset (Buf3, 0); + strset (Buf4, 0); + strset (Buf5, 0); +} + + +static void +LoadTriplet (TDA A) +{ + Clear_Buffers (); + fscanf (mainfile, "%s %s %s %s", Buf1, Buf2, Buf3, Buf4); + A[0] = atof (Buf2); + A[1] = atof (Buf3); + A[2] = atof (Buf4); +} + + +static void +LoadReal (float *a) +{ + Clear_Buffers (); + fscanf (mainfile, "%s %s", Buf1, Buf2); + *a = atof (Buf2); +} + + +static void +LoadInteger (int *a) +{ + Clear_Buffers (); + fscanf (mainfile, "%s %s", Buf1, Buf2); + *a = atoi (Buf2); +} + + +static void +LoadText (char *a) +{ + Clear_Buffers (); + fscanf (mainfile, "%s %s", Buf1, Buf2); + strcpy (a, Buf2); +} + + +static void +getdata (char filename[]) +{ + int gear_count = 0, axle_count = 0, belt_count = 0, i; + + mainfile = fopen (filename, "r"); + if (!mainfile) { + printf("Error: couldn't open %s\n", filename); + exit(-1); + } + + do + { + Clear_Buffers (); + fscanf (mainfile, "%s", Buf1); + if (ferror (mainfile)) + { + printf ("\nError opening file !\n"); + exit (1); + } + + if (!(strcmp (Buf1, "BACKGROUND"))) + LoadTriplet (background); + + if (!(strcmp (Buf1, "ANAME"))) + { + LoadText (a[axle_count].name); + axle_count++; + } + + if (!(strcmp (Buf1, "ARADIUS"))) + LoadReal (&a[axle_count - 1].radius); + + if (!(strcmp (Buf1, "AAXIS"))) + LoadInteger (&a[axle_count - 1].axis); + + if (!(strcmp (Buf1, "ACOLOR"))) + LoadTriplet (a[axle_count - 1].color); + + if (!(strcmp (Buf1, "APOSITION"))) + LoadTriplet (a[axle_count - 1].position); + + if (!(strcmp (Buf1, "ALENGTH"))) + LoadReal (&a[axle_count - 1].length); + + if (!(strcmp (Buf1, "AMOTORED"))) + LoadInteger (&a[axle_count - 1].motored); + + if (!(strcmp (Buf1, "AANGULARVELOCITY"))) + LoadReal (&a[axle_count - 1].angular_velocity); + + if (!(strcmp (Buf1, "ADIRECTION"))) + LoadInteger (&a[axle_count - 1].direction); + + if (!(strcmp (Buf1, "GNAME"))) + { + LoadText (g[gear_count].name); + gear_count++; + } + + if (!(strcmp (Buf1, "GTYPE"))) + LoadText (g[gear_count - 1].type); + + if (!(strcmp (Buf1, "GFACE"))) + LoadInteger (&g[gear_count - 1].face); + + if (!(strcmp (Buf1, "GRADIUS"))) + LoadReal (&g[gear_count - 1].radius); + + if (!(strcmp (Buf1, "GWIDTH"))) + LoadReal (&g[gear_count - 1].width); + + if (!(strcmp (Buf1, "GTEETH"))) + LoadInteger (&g[gear_count - 1].teeth); + + if (!(strcmp (Buf1, "GTOOTHDEPTH"))) + LoadReal (&g[gear_count - 1].tooth_depth); + + if (!(strcmp (Buf1, "GCOLOR"))) + LoadTriplet (g[gear_count - 1].color); + + if (!(strcmp (Buf1, "GAXLE"))) + LoadText (g[gear_count - 1].axle_name); + + if (!(strcmp (Buf1, "GPOSITION"))) + LoadInteger (&g[gear_count - 1].relative_position); + + if (!(strcmp (Buf1, "BELTNAME"))) + { + LoadText (b[belt_count].name); + belt_count++; + } + + if (!(strcmp (Buf1, "GEAR1NAME"))) + LoadText (b[belt_count - 1].gear1_name); + + if (!(strcmp (Buf1, "GEAR2NAME"))) + LoadText (b[belt_count - 1].gear2_name); + } + + while (Buf1[0] != 0); + + for (i = 0; i < number_of_gears; i++) + { + g[i].axis = -1; + g[i].direction = 0; + g[i].angular_velocity = 0.0; + } + + number_of_gears = gear_count; + number_of_axles = axle_count; + number_of_belts = belt_count; + fclose (mainfile); +} + + +static void +axle (GLint j, GLfloat radius, GLfloat length) +{ + GLfloat angle, rad, incr = 10.0 * M_PI / 180.0; + + /* draw main cylinder */ + glBegin (GL_QUADS); + for (angle = 0.0; angle < 360.0; angle += 5.0) + { + rad = angle * M_PI / 180.0; + glNormal3f (cos (rad), sin (rad), 0.0); + glVertex3f (radius * cos (rad), radius * sin (rad), length / 2); + glVertex3f (radius * cos (rad), radius * sin (rad), -length / 2); + glVertex3f (radius * cos (rad + incr), radius * sin (rad + incr), -length / 2); + glVertex3f (radius * cos (rad + incr), radius * sin (rad + incr), length / 2); + } + glEnd (); + + /* draw front face */ + glNormal3f (0.0, 0.0, 1.0); + glBegin (GL_TRIANGLES); + for (angle = 0.0; angle < 360.0; angle += 5.0) + { + rad = angle * M_PI / 180.0; + glVertex3f (0.0, 0.0, length / 2); + glVertex3f (radius * cos (rad), radius * sin (rad), length / 2); + glVertex3f (radius * cos (rad + incr), radius * sin (rad + incr), length / 2); + glVertex3f (0.0, 0.0, length / 2); + } + glEnd (); + + /* draw back face */ + glNormal3f (0.0, 0.0, -1.0); + glBegin (GL_TRIANGLES); + for (angle = 0.0; angle <= 360.0; angle += 5.0) + { + rad = angle * M_PI / 180.0; + glVertex3f (0.0, 0.0, -length / 2); + glVertex3f (radius * cos (rad), radius * sin (rad), -length / 2); + glVertex3f (radius * cos (rad + incr), radius * sin (rad + incr), -length / 2); + glVertex3f (0.0, 0.0, -length / 2); + } + glEnd (); +} + + + +static void +gear (GLint j, char type[], GLfloat radius, GLfloat width, + GLint teeth, GLfloat tooth_depth) +{ + GLint i; + GLfloat r1, r2; + GLfloat angle, da; + GLfloat u, v, len, fraction = 0.5; + GLfloat n = 1.0; + + r1 = radius - tooth_depth; + r2 = radius; + + da = 2.0 * M_PI / teeth / 4.0; + if (!g[j].face) + { + fraction = -0.5; + n = -1.0; + } + if (!(strcmp (type, "NORMAL"))) + { + fraction = 0.5; + n = 1.0; + } + + /* draw front face */ + if (!(strcmp (type, "NORMAL"))) + { + glNormal3f (0.0, 0.0, 1.0 * n); + glBegin (GL_QUAD_STRIP); + for (i = 0; i <= teeth; i++) + { + angle = i * 2.0 * M_PI / teeth; + glVertex3f (0.0, 0.0, width * fraction); + glVertex3f (r1 * cos (angle), r1 * sin (angle), width * fraction); + glVertex3f (0.0, 0.0, width * fraction); + glVertex3f (r1 * cos (angle + 3 * da), r1 * sin (angle + 3 * da), width * fraction); + } + glEnd (); + } + else + { + glNormal3f (0.0, 0.0, 1.0 * n); + glBegin (GL_QUAD_STRIP); + for (i = 0; i <= teeth; i++) + { + angle = i * 2.0 * M_PI / teeth; + glVertex3f (0.0, 0.0, width * fraction); + glVertex3f ((r2 - width) * cos (angle), (r2 - width) * sin (angle), width * fraction); + glVertex3f (0.0, 0.0, width * fraction); + glVertex3f ((r2 - width) * cos (angle + 3 * da), (r2 - width) * sin (angle + 3 * da), width * fraction); + } + glEnd (); + } + + /* draw front sides of teeth */ + if (!(strcmp (type, "NORMAL"))) + { + glNormal3f (0.0, 0.0, 1.0 * n); + glBegin (GL_QUADS); + da = 2.0 * M_PI / teeth / 4.0; + for (i = 0; i < teeth; i++) + { + angle = i * 2.0 * M_PI / teeth; + glVertex3f (r1 * cos (angle), r1 * sin (angle), width * fraction); + glVertex3f (r2 * cos (angle + da), r2 * sin (angle + da), width * fraction); + glVertex3f (r2 * cos (angle + 2 * da), r2 * sin (angle + 2 * da), width * fraction); + glVertex3f (r1 * cos (angle + 3 * da), r1 * sin (angle + 3 * da), width * fraction); + } + glEnd (); + } + + glNormal3f (0.0, 0.0, -1.0 * n); + + /* draw back face */ + glBegin (GL_QUAD_STRIP); + for (i = 0; i <= teeth; i++) + { + angle = i * 2.0 * M_PI / teeth; + glVertex3f (r1 * cos (angle), r1 * sin (angle), -width * fraction); + glVertex3f (0.0, 0.0, -width * fraction); + glVertex3f (r1 * cos (angle + 3 * da), r1 * sin (angle + 3 * da), -width * fraction); + glVertex3f (0.0, 0.0, -width * fraction); + } + glEnd (); + + /* draw back sides of teeth */ + glNormal3f (0.0, 0.0, -1.0 * n); + glBegin (GL_QUADS); + da = 2.0 * M_PI / teeth / 4.0; + for (i = 0; i < teeth; i++) + { + angle = i * 2.0 * M_PI / teeth; + glVertex3f (r1 * cos (angle + 3 * da), r1 * sin (angle + 3 * da), -width * fraction); + glVertex3f (r2 * cos (angle + 2 * da), r2 * sin (angle + 2 * da), -width * fraction); + glVertex3f (r2 * cos (angle + da), r2 * sin (angle + da), -width * fraction); + glVertex3f (r1 * cos (angle), r1 * sin (angle), -width * fraction); + } + glEnd (); + + + /* draw outward faces of teeth */ + if (!(strcmp (type, "NORMAL"))) + { + glBegin (GL_QUAD_STRIP); + for (i = 0; i < teeth; i++) + { + angle = i * 2.0 * M_PI / teeth; + + glVertex3f (r1 * cos (angle), r1 * sin (angle), width * fraction); + glVertex3f (r1 * cos (angle), r1 * sin (angle), -width * fraction); + u = r2 * cos (angle + da) - r1 * cos (angle); + v = r2 * sin (angle + da) - r1 * sin (angle); + len = sqrt (u * u + v * v); + u /= len; + v /= len; + glNormal3f (v, -u, 0.0); + glVertex3f (r2 * cos (angle + da), r2 * sin (angle + da), width * fraction); + glVertex3f (r2 * cos (angle + da), r2 * sin (angle + da), -width * fraction); + glNormal3f (cos (angle), sin (angle), 0.0); + glVertex3f (r2 * cos (angle + 2 * da), r2 * sin (angle + 2 * da), width * fraction); + glVertex3f (r2 * cos (angle + 2 * da), r2 * sin (angle + 2 * da), -width * fraction); + u = r1 * cos (angle + 3 * da) - r2 * cos (angle + 2 * da); + v = r1 * sin (angle + 3 * da) - r2 * sin (angle + 2 * da); + glNormal3f (v, -u, 0.0); + glVertex3f (r1 * cos (angle + 3 * da), r1 * sin (angle + 3 * da), width * fraction); + glVertex3f (r1 * cos (angle + 3 * da), r1 * sin (angle + 3 * da), -width * fraction); + glNormal3f (cos (angle), sin (angle), 0.0); + } + } + else + { + glBegin (GL_QUAD_STRIP); + for (i = 0; i < teeth; i++) + { + angle = i * 2.0 * M_PI / teeth; + glVertex3f (r1 * cos (angle), r1 * sin (angle), width * fraction); + glVertex3f (r1 * cos (angle), r1 * sin (angle), -width * fraction); + u = r2 * cos (angle + da) - r1 * cos (angle); + v = r2 * sin (angle + da) - r1 * sin (angle); + len = sqrt (u * u + v * v); + u /= len; + v /= len; + glNormal3f (v, -u, 0.0); + glVertex3f ((r2 - width) * cos (angle + da), (r2 - width) * sin (angle + da), width * fraction); + glVertex3f (r2 * cos (angle + da), r2 * sin (angle + da), -width * fraction); + glNormal3f (cos (angle), sin (angle), n); + glVertex3f ((r2 - width) * cos (angle + 2 * da), (r2 - width) * sin (angle + 2 * da), width * fraction); + glVertex3f (r2 * cos (angle + 2 * da), r2 * sin (angle + 2 * da), -width * fraction); + u = r1 * cos (angle + 3 * da) - r2 * cos (angle + 2 * da); + v = r1 * sin (angle + 3 * da) - r2 * sin (angle + 2 * da); + glNormal3f (v, -u, 0.0); + glVertex3f (r1 * cos (angle + 3 * da), r1 * sin (angle + 3 * da), width * fraction); + glVertex3f (r1 * cos (angle + 3 * da), r1 * sin (angle + 3 * da), -width * fraction); + glNormal3f (cos (angle), sin (angle), n); + } + } + + glVertex3f (r1 * cos (0), r1 * sin (0), width * fraction); + glVertex3f (r1 * cos (0), r1 * sin (0), -width * fraction); + glEnd (); +} + + +static void +belt (struct GEAR g1, struct GEAR g2) +{ + GLfloat D, alpha, phi, angle, incr, width; + GLint indexes[3] = + { + 0, 0, 0 + }; + + GLfloat col[3] = + { + 0.0, 0.0, 0.0 + }; + + width = min (g1.width, g2.width); + D = sqrt (pow (g1.position[0] - g2.position[0], 2) + pow (g1.position[1] - g2.position[1], 2) + pow (g1.position[2] - g2.position[2], 2)); + alpha = acos ((g2.position[0] - g1.position[0]) / D); + phi = acos ((g1.radius - g2.radius) / D); + glBegin (GL_QUADS); + glColor3fv (col); + glMaterialiv (GL_FRONT, GL_COLOR_INDEXES, indexes); + incr = 1.2 * 360.0 / g1.teeth * M_PI / 180.00; + for (angle = alpha + phi; angle <= 2 * M_PI - phi + alpha; angle += 360.0 / g1.teeth * M_PI / 180.00) + { + glNormal3f (cos (angle), sin (angle), 0.0); + glVertex3f (g1.radius * cos (angle), g1.radius * sin (angle), width * 0.5); + glVertex3f (g1.radius * cos (angle), g1.radius * sin (angle), -width * 0.5); + glVertex3f (g1.radius * cos (angle + incr), g1.radius * sin (angle + incr), -width * 0.5); + glVertex3f (g1.radius * cos (angle + incr), g1.radius * sin (angle + incr), width * 0.5); + } + glEnd (); + glBegin (GL_QUADS); + glColor3fv (col); + glMaterialiv (GL_FRONT, GL_COLOR_INDEXES, indexes); + incr = 1.2 * 360.0 / g2.teeth * M_PI / 180.00; + for (angle = -phi + alpha; angle <= phi + alpha; angle += 360.0 / g1.teeth * M_PI / 180.0) + { + glNormal3f (cos (angle), sin (angle), 0.0); + glVertex3f (g2.radius * cos (angle) + g2.position[0] - g1.position[0], g2.radius * sin (angle) + g2.position[1] - g1.position[1], width * 0.5); + glVertex3f (g2.radius * cos (angle) + g2.position[0] - g1.position[0], g2.radius * sin (angle) + g2.position[1] - g1.position[1], width * -0.5); + glVertex3f (g2.radius * cos (angle + incr) + g2.position[0] - g1.position[0], g2.radius * sin (angle + incr) + g2.position[1] - g1.position[1], width * -0.5); + glVertex3f (g2.radius * cos (angle + incr) + g2.position[0] - g1.position[0], g2.radius * sin (angle + incr) + g2.position[1] - g1.position[1], width * 0.5); + } + glEnd (); + + glBegin (GL_QUADS); + glColor3fv (col); + glMaterialiv (GL_FRONT, GL_COLOR_INDEXES, indexes); + glVertex3f (g1.radius * cos (alpha + phi), g1.radius * sin (alpha + phi), width * 0.5); + glVertex3f (g1.radius * cos (alpha + phi), g1.radius * sin (alpha + phi), width * -0.5); + glVertex3f (g2.radius * cos (alpha + phi) + g2.position[0] - g1.position[0], g2.radius * sin (alpha + phi) + g2.position[1] - g1.position[1], width * -0.5); + glVertex3f (g2.radius * cos (alpha + phi) + g2.position[0] - g1.position[0], g2.radius * sin (alpha + phi) + g2.position[1] - g1.position[1], width * 0.5); + glVertex3f (g1.radius * cos (alpha - phi), g1.radius * sin (alpha - phi), width * 0.5); + glVertex3f (g1.radius * cos (alpha - phi), g1.radius * sin (alpha - phi), width * -0.5); + glVertex3f (g2.radius * cos (alpha - phi) + g2.position[0] - g1.position[0], g2.radius * sin (alpha - phi) + g2.position[1] - g1.position[1], width * -0.5); + glVertex3f (g2.radius * cos (alpha - phi) + g2.position[0] - g1.position[0], g2.radius * sin (alpha - phi) + g2.position[1] - g1.position[1], width * 0.5); + glEnd (); +} + + +static int +axle_find (char axle_name[]) +{ + int i; + + for (i = 0; i < number_of_axles; i++) + { + if (!(strcmp (axle_name, a[i].name))) + break; + } + return i; +} + + +static int +gear_find (char gear_name[]) +{ + int i; + + for (i = 0; i < number_of_gears; i++) + { + if (!(strcmp (gear_name, g[i].name))) + break; + } + return i; +} + + +static void +process () +{ + GLfloat x, y, z, D, dist; + GLint axle_index, i, j, g1, g2, k; + char error[80]; + + for (i = 0; i < number_of_gears; i++) + { + x = 0.0; + y = 0.0; + z = 0.0; + axle_index = axle_find (g[i].axle_name); + g[i].axis = a[axle_index].axis; + g[i].motored = a[axle_index].motored; + if (a[axle_index].motored) + { + g[i].direction = a[axle_index].direction; + g[i].angular_velocity = a[axle_index].angular_velocity; + } + if (g[i].axis == 0) + x = 1.0; + else if (g[i].axis == 1) + y = 1.0; + else + z = 1.0; + + g[i].position[0] = a[axle_index].position[0] + x * g[i].relative_position; + g[i].position[1] = a[axle_index].position[1] + y * g[i].relative_position; + g[i].position[2] = a[axle_index].position[2] + z * g[i].relative_position; + } + + for (k = 0; k < number_of_axles; k++) + { + for (i = 0; i < number_of_gears - 1; i++) + { + for (j = 0; j < number_of_gears; j++) + { + if (!(strcmp (g[i].type, g[j].type)) && (!(strcmp (g[i].type, "NORMAL"))) && ((strcmp (g[i].axle_name, g[j].axle_name) != 0)) && (g[i].axis == g[j].axis)) + { + D = sqrt (pow (g[i].position[0] - g[j].position[0], 2) + pow (g[i].position[1] - g[j].position[1], 2) + pow (g[i].position[2] - g[j].position[2], 2)); + if (D < 1.1 * (g[i].radius - g[i].tooth_depth + g[j].radius - g[j].tooth_depth)) + { + printf (error, "Gear %s and %s are too close to each other.", g[i].name, g[j].name); + + /*MessageBox(NULL,error,windowName,MB_ICONEXCLAMATION|MB_OK);*/ + exit (1); + } + + if (g[i].axis == 0) + { + dist = g[i].position[0] - g[j].position[0]; + } + else if (g[i].axis == 1) + { + dist = g[i].position[1] - g[j].position[1]; + } + else + dist = g[i].position[2] - g[j].position[2]; + + dist = fabs (dist); + + if (dist < (g[i].width / 2 + g[j].width / 2)) + { + if ((g[i].motored) && (!(g[j].motored)) && (D < 0.95 * (g[i].radius + g[j].radius))) + { + axle_index = axle_find (g[j].axle_name); + if ((a[axle_index].direction != 0) && (g[j].angular_velocity != g[i].angular_velocity * g[i].teeth / g[j].teeth * g[i].radius / g[j].radius)) + { + printf (error, "Error in tooth linkage of gears %s and %s.", g[i].name, g[j].name); + /*MessageBox(NULL,error,windowName,MB_ICONEXCLAMATION|MB_OK);*/ + exit (1); + } + + g[j].motored = (a[axle_index].motored = 1); + g[j].direction = (a[axle_index].direction = -g[i].direction); + a[axle_index].angular_velocity = g[i].angular_velocity * g[i].teeth / g[j].teeth; + g[j].angular_velocity = (a[axle_index].angular_velocity *= g[i].radius / g[j].radius); + } + + if ((!(g[i].motored)) && (g[j].motored) && (D < 0.95 * (g[i].radius + g[j].radius))) + { + axle_index = axle_find (g[i].axle_name); + if ((a[axle_index].direction != 0) && (g[i].angular_velocity != g[j].angular_velocity * g[j].teeth / g[i].teeth * g[j].radius / g[i].radius)) + { + printf (error, "Error in tooth linkage of gears %s and %s.", g[i].name, g[j].name); + /*MessageBox(NULL,error,windowName,MB_ICONEXCLAMATION|MB_OK);*/ + exit (1); + } + + g[i].motored = (a[axle_index].motored = 1); + g[i].direction = (a[axle_index].direction = -g[j].direction); + a[axle_index].angular_velocity = g[j].angular_velocity * g[j].teeth / g[i].teeth; + g[i].angular_velocity = (a[axle_index].angular_velocity *= g[j].radius / g[i].radius); + + } + } + } + + if (!(strcmp (g[i].type, g[j].type)) && (!(strcmp (g[i].type, "BEVEL"))) && ((strcmp (g[i].axle_name, g[j].axle_name) != 0)) && (g[i].axis != g[j].axis)) + { + D = sqrt (pow (g[i].position[0] - g[j].position[0], 2) + pow (g[i].position[1] - g[j].position[1], 2) + pow (g[i].position[2] - g[j].position[2], 2)); + if ((g[i].motored) && (!(g[j].motored)) && (D < 0.95 * sqrt (g[i].radius * g[i].radius + g[j].radius * g[j].radius))) + { + axle_index = axle_find (g[j].axle_name); + if ((a[axle_index].direction != 0) && (g[j].angular_velocity != g[i].angular_velocity * g[i].teeth / g[j].teeth * g[i].radius / g[j].radius)) + { + printf (error, "Error in tooth linkage of gears %s and %s.", g[i].name, g[j].name); + /*MessageBox(NULL,error,windowName,MB_ICONEXCLAMATION|MB_OK);*/ + exit (1); + } + g[j].motored = (a[axle_index].motored = 1); + g[j].direction = (a[axle_index].direction = -g[i].direction); + a[axle_index].angular_velocity = g[i].angular_velocity * g[i].teeth / g[j].teeth; + g[j].angular_velocity = (a[axle_index].angular_velocity *= g[i].radius / g[j].radius); + } + + + if ((!(g[i].motored)) && (g[j].motored) && (D < 0.95 * sqrt (g[i].radius * g[i].radius + g[j].radius * g[j].radius))) + { + axle_index = axle_find (g[i].axle_name); + if ((a[axle_index].direction != 0) && (g[i].angular_velocity != g[j].angular_velocity * g[j].teeth / g[i].teeth * g[j].radius / g[i].radius)) + { + printf (error, "Error in tooth linkage of gears %s and %s.", g[i].name, g[j].name); + /*MessageBox(NULL,error,windowName,MB_ICONEXCLAMATION|MB_OK);*/ + exit (1); + } + g[i].motored = (a[axle_index].motored = 1); + g[i].direction = (a[axle_index].direction = -g[j].direction); + a[axle_index].angular_velocity = g[j].angular_velocity * g[j].teeth / g[i].teeth; + g[i].angular_velocity = (a[axle_index].angular_velocity *= g[j].radius / g[i].radius); + } + } + } + } + + for (i = 0; i < number_of_gears; i++) + { + axle_index = axle_find (g[i].axle_name); + g[i].motored = a[axle_index].motored; + if (a[axle_index].motored) + { + g[i].direction = a[axle_index].direction; + g[i].angular_velocity = a[axle_index].angular_velocity; + } + } + + for (i = 0; i < number_of_belts; i++) + { + g1 = gear_find (b[i].gear1_name); + g2 = gear_find (b[i].gear2_name); + D = sqrt (pow (g[g1].position[0] - g[g2].position[0], 2) + pow (g[g1].position[1] - g[g2].position[1], 2) + pow (g[g1].position[2] - g[g2].position[2], 2)); + if (!((g[g1].axis == g[g2].axis) && (!strcmp (g[g1].type, g[g2].type)) && (!strcmp (g[g1].type, "NORMAL")))) + { + printf (error, "Belt %s invalid.", b[i].name); + /*MessageBox(NULL,error,windowName,MB_ICONEXCLAMATION|MB_OK);*/ + exit (1); + } + + if ((g[g1].axis == g[g2].axis) && (!strcmp (g[g1].type, g[g2].type)) && (!strcmp (g[g1].type, "NORMAL"))) + { + /* + if((g[g1].motored)&&(g[g2].motored)) + if(g[g2].angular_velocity!=(g[g1].angular_velocity*g[g1].radius/g[g2].radius)) + { + printf(error,"Error in belt linkage of gears %s and %s".,g[g1].name,g[g2].name); + MessageBox(NULL,error,windowName,MB_ICONEXCLAMATION|MB_OK); + exit(1); + } + */ + if (g[g1].axis == 0) + { + dist = g[g1].position[0] - g[g2].position[0]; + } + else if (g[i].axis == 1) + { + dist = g[g1].position[1] - g[g2].position[1]; + } + else + dist = g[g1].position[2] - g[g2].position[2]; + + dist = fabs (dist); + + if (dist > (g[g1].width / 2 + g[g2].width / 2)) + { + printf (error, "Belt %s invalid.", b[i].name); + /*MessageBox(NULL,error,windowName,MB_ICONEXCLAMATION|MB_OK);*/ + exit (1); + } + + if (dist < (g[g1].width / 2 + g[g2].width / 2)) + { + if (D < g[g1].radius + g[g2].radius) + { + printf (error, "Gears %s and %s too close to be linked with belts", g[g1].name, g[g2].name); + /*MessageBox(NULL,error,windowName,MB_ICONEXCLAMATION|MB_OK);*/ + exit (1); + } + + if ((g[g1].motored) && (!(g[g2].motored))) + { + axle_index = axle_find (g[g2].axle_name); + g[g2].motored = (a[axle_index].motored = 1); + g[g2].direction = (a[axle_index].direction = g[g1].direction); + g[g2].angular_velocity = (a[axle_index].angular_velocity = g[g1].angular_velocity * g[g1].radius / g[g2].radius); + } + + if ((!(g[g1].motored)) && (g[g2].motored)) + { + axle_index = axle_find (g[g1].axle_name); + g[g1].motored = (a[axle_index].motored = 1); + g[g1].direction = (a[axle_index].direction = g[g2].direction); + g[g1].angular_velocity = (a[axle_index].angular_velocity = g[g2].angular_velocity * g[g2].radius / g[g1].radius); + } + } + } + } + + for (i = 0; i < number_of_gears; i++) + { + axle_index = axle_find (g[i].axle_name); + g[i].motored = a[axle_index].motored; + if (a[axle_index].motored) + { + g[i].direction = a[axle_index].direction; + g[i].angular_velocity = a[axle_index].angular_velocity; + } + } + } +} + + + +GLfloat view_rotx = 20.0, view_roty = 30.0, view_rotz = 10.0; + + +static void +draw (void) +{ + int i; + GLfloat x, y, z; + int index; + + 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); + + for (i = 0; i < number_of_gears; i++) + { + x = 0.0; + y = 0.0; + z = 0.0; + glPushMatrix (); +/*glTranslatef( -3.0, -2.0, 0.0 );*/ + glTranslatef (g[i].position[0], g[i].position[1], g[i].position[2]); + if (g[i].axis == 0) + y = 1.0; + else if (g[i].axis == 1) + x = 1.0; + else + z = 1.0; + + if (z != 1.0) + glRotatef (90.0, x, y, z); + + glRotatef (g[i].direction * g[i].angle, 0.0, 0.0, 1.0); + glCallList (g[i].id); + glPopMatrix (); + } + + for (i = 0; i < number_of_axles; i++) + { + x = 0.0; + y = 0.0; + z = 0.0; + glPushMatrix (); + glTranslatef (a[i].position[0], a[i].position[1], a[i].position[2]); + if (a[i].axis == 0) + y = 1.0; + else if (a[i].axis == 1) + x = 1.0; + else + z = 1.0; + + if (z != 1.0) + glRotatef (90.0, x, y, z); + + glCallList (a[i].id); + glPopMatrix (); + } + + for (i = 0; i < number_of_belts; i++) + { + x = 0.0; + y = 0.0; + z = 0.0; + glPushMatrix (); + index = gear_find (b[i].gear1_name); + glTranslatef (g[index].position[0], g[index].position[1], g[index].position[2]); + if (g[index].axis == 0) + y = 1.0; + else if (g[index].axis == 1) + x = 1.0; + else + z = 1.0; + + if (z != 1.0) + glRotatef (90.0, x, y, z); + + glCallList (b[i].id); + glPopMatrix (); + } + + glPopMatrix (); + glutSwapBuffers (); + + { + GLint t = glutGet(GLUT_ELAPSED_TIME); + Frames++; + if (t - T0 >= 5000) { + GLfloat seconds = (t - T0) / 1000.0; + GLfloat fps = Frames / seconds; + printf("%d frames in %g seconds = %g FPS\n", Frames, seconds, fps); + T0 = t; + Frames = 0; + } + } +} + + +static void +idle (void) +{ + int i; + static double t0 = -1.; + double dt, t = glutGet(GLUT_ELAPSED_TIME) / 1000.0; + if (t0 < 0.0) + t0 = t; + dt = t - t0; + t0 = t; + for (i = 0; i < number_of_gears; i++) + g[i].angle += g[i].angular_velocity * dt; + glutPostRedisplay(); +} + + + + +/* change view angle, exit upon ESC */ +static void +key (unsigned char k, int x, int y) +{ + switch (k) + { + case 'x': + view_rotx += 5.0; + break; + case 'X': + view_rotx -= 5.0; + break; + case 'y': + view_roty += 5.0; + break; + case 'Y': + view_roty -= 5.0; + break; + case 'z': + view_rotz += 5.0; + break; + case 'Z': + view_rotz -= 5.0; + break; + case 0x1B: + exit(0); + } +} + + + + +/* new window size or exposure */ +static void +reshape (int width, int height) +{ + glViewport (0, 0, (GLint) width, (GLint) height); + glMatrixMode (GL_PROJECTION); + glLoadIdentity (); + if (width > height) + { + GLfloat w = (GLfloat) width / (GLfloat) height; + glFrustum (-w, w, -1.0, 1.0, 5.0, 60.0); + } + else + { + GLfloat h = (GLfloat) height / (GLfloat) width; + glFrustum (-1.0, 1.0, -h, h, 5.0, 60.0); + } + + glMatrixMode (GL_MODELVIEW); + glLoadIdentity (); + glTranslatef (0.0, 0.0, -40.0); + glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); +} + + + +static void +init (void) +{ + GLfloat matShine = 20.00F; + GLfloat light0Pos[4] = + { + 0.70F, 0.70F, 1.25F, 0.50F + }; + int i; + + glClearColor (background[0], background[1], background[2], 1.0F); + glClearIndex ((GLfloat) 0.0); + + glMaterialf (GL_FRONT_AND_BACK, GL_SHININESS, matShine); + glLightfv (GL_LIGHT0, GL_POSITION, light0Pos); + glEnable (GL_LIGHT0); + + glEnable (GL_LIGHTING); + glEnable (GL_DEPTH_TEST); + for (i = 0; i < number_of_gears; i++) + g[i].angle = 0.0; + + for (i = 0; i < number_of_gears; i++) + { + g[i].id = glGenLists (1); + glNewList (g[i].id, GL_COMPILE); + glColor3fv (g[i].color); + glMaterialfv (GL_FRONT, GL_SPECULAR, g[i].color); + gear (i, g[i].type, g[i].radius, g[i].width, g[i].teeth, g[i].tooth_depth); + glEndList (); + } + + for (i = 0; i < number_of_axles; i++) + { + a[i].id = glGenLists (1); + glNewList (a[i].id, GL_COMPILE); + glColor3fv (a[i].color); + glMaterialfv (GL_FRONT, GL_SPECULAR, a[i].color); + axle (i, a[i].radius, a[i].length); + glEndList (); + } + + for (i = 0; i < number_of_belts; i++) + { + b[i].id = glGenLists (1); + glNewList (b[i].id, GL_COMPILE); + belt (g[gear_find (b[i].gear1_name)], g[gear_find (b[i].gear2_name)]); + glEndList (); + } + + glEnable (GL_COLOR_MATERIAL); +} + + + +int +main (int argc, char *argv[]) +{ + char *file; + + if (argc < 2) + file = "geartrain.dat"; + else + file = argv[1]; + + glutInitWindowPosition (0, 0); + glutInitWindowSize(640,480); + glutInitDisplayMode (GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE ); + + if (glutCreateWindow ("Gear Train Simulation") == GL_FALSE) + exit (1); + + getdata (file); + process (); + init (); + + glutDisplayFunc (draw); + glutReshapeFunc (reshape); + glutKeyboardFunc (key); + glutIdleFunc (idle); + glutMainLoop (); + return 0; +} diff --git a/progs/demos/geartrain.dat b/progs/demos/geartrain.dat new file mode 100644 index 00000000000..374de48bd5e --- /dev/null +++ b/progs/demos/geartrain.dat @@ -0,0 +1,119 @@ +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 = 90.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 diff --git a/progs/demos/glinfo.c b/progs/demos/glinfo.c new file mode 100644 index 00000000000..a6a7478288e --- /dev/null +++ b/progs/demos/glinfo.c @@ -0,0 +1,32 @@ + +/* + * Print GL, GLU and GLUT version and extension info + * + * Brian Paul This file in public domain. + * October 3, 1997 + */ + + +#include +#include + + +int main( int argc, char *argv[] ) +{ + glutInit( &argc, argv ); + glutInitDisplayMode( GLUT_RGB ); + glutCreateWindow(argv[0]); + + 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)); + printf("GLUT_API_VERSION: %d\n", GLUT_API_VERSION); +#ifdef GLUT_XLIB_IMPLEMENTATION + printf("GLUT_XLIB_IMPLEMENTATION: %d\n", GLUT_XLIB_IMPLEMENTATION); +#endif + + return 0; +} diff --git a/progs/demos/gloss.c b/progs/demos/gloss.c new file mode 100644 index 00000000000..0b2e7426d53 --- /dev/null +++ b/progs/demos/gloss.c @@ -0,0 +1,483 @@ + +/* + * Specular reflection demo. The specular highlight is modulated by + * a sphere-mapped texture. The result is a high-gloss surface. + * NOTE: you really need hardware acceleration for this. + * Also note, this technique can't be implemented with multi-texture + * and separate specular color interpolation because there's no way + * to indicate that the second texture unit (the reflection map) + * should modulate the specular color and not the base color. + * A future multi-texture extension could fix that. + * + * Command line options: + * -info print GL implementation information + * + * + * Brian Paul October 22, 1999 This program is in the public domain. + */ + + +#include +#include +#include +#include +#include +#include + +#include "readtex.h" + +#define SPECULAR_TEXTURE_FILE "../images/reflect.rgb" +#define BASE_TEXTURE_FILE "../images/tile.rgb" + +/* Menu items */ +#define DO_SPEC_TEXTURE 1 +#define OBJECT 2 +#define ANIMATE 3 +#define QUIT 100 + +/* for convolution */ +#define FILTER_SIZE 7 + +static GLint WinWidth = 500, WinHeight = 500; +static GLuint CylinderObj = 0; +static GLuint TeapotObj = 0; +static GLuint Object = 0; +static GLboolean Animate = GL_TRUE; + +static GLfloat Xrot = 0.0, Yrot = 0.0, Zrot = 0.0; +static GLfloat DXrot = 20.0, DYrot = 50.; + +static GLfloat Black[4] = { 0, 0, 0, 0 }; +static GLfloat White[4] = { 1, 1, 1, 1 }; +static GLfloat Diffuse[4] = { .3, .3, 1.0, 1.0 }; /* blue */ +static GLfloat Shininess = 6; + +static GLuint BaseTexture, SpecularTexture; +static GLboolean DoSpecTexture = GL_TRUE; + +static GLboolean ButtonDown = GL_FALSE; +static GLint ButtonX, ButtonY; +static GLfloat Xrot0, Yrot0; + + +/* performance info */ +static GLint T0 = 0; +static GLint Frames = 0; + + +static void Idle( void ) +{ + static double t0 = -1.; + double dt, t = glutGet(GLUT_ELAPSED_TIME) / 1000.0; + if (t0 < 0.0) + t0 = t; + dt = t - t0; + t0 = t; + + if (Animate) { + Xrot += DXrot*dt; + Yrot += DYrot*dt; + glutPostRedisplay(); + } +} + + +static void Display( void ) +{ + glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); + + glPushMatrix(); + glRotatef(Xrot, 1.0, 0.0, 0.0); + glRotatef(Yrot, 0.0, 1.0, 0.0); + glRotatef(Zrot, 0.0, 0.0, 1.0); + + /* First pass: diffuse lighting with base texture */ + glMaterialfv(GL_FRONT, GL_DIFFUSE, Diffuse); + glMaterialfv(GL_FRONT, GL_SPECULAR, Black); + glEnable(GL_TEXTURE_2D); + glBindTexture(GL_TEXTURE_2D, BaseTexture); + glCallList(Object); + + /* Second pass: specular lighting with reflection texture */ + glEnable(GL_POLYGON_OFFSET_FILL); + glBlendFunc(GL_ONE, GL_ONE); /* add */ + glEnable(GL_BLEND); + glMaterialfv(GL_FRONT, GL_DIFFUSE, Black); + glMaterialfv(GL_FRONT, GL_SPECULAR, White); + if (DoSpecTexture) { + glBindTexture(GL_TEXTURE_2D, SpecularTexture); + glEnable(GL_TEXTURE_GEN_S); + glEnable(GL_TEXTURE_GEN_T); + } + else { + glDisable(GL_TEXTURE_2D); + } + glCallList(Object); + glDisable(GL_TEXTURE_GEN_S); + glDisable(GL_TEXTURE_GEN_T); + glDisable(GL_BLEND); + glDisable(GL_POLYGON_OFFSET_FILL); + + glPopMatrix(); + + glutSwapBuffers(); + + if (Animate) { + GLint t = glutGet(GLUT_ELAPSED_TIME); + Frames++; + if (t - T0 >= 5000) { + GLfloat seconds = (t - T0) / 1000.0; + GLfloat fps = Frames / seconds; + printf("%d frames in %g seconds = %g FPS\n", Frames, seconds, fps); + T0 = t; + Frames = 0; + } + } +} + + +static void Reshape( int width, int height ) +{ + GLfloat h = 30.0; + GLfloat w = h * width / height; + WinWidth = width; + WinHeight = height; + glViewport( 0, 0, width, height ); + glMatrixMode( GL_PROJECTION ); + glLoadIdentity(); + glFrustum( -w, w, -h, h, 150.0, 500.0 ); + glMatrixMode( GL_MODELVIEW ); + glLoadIdentity(); + glTranslatef( 0.0, 0.0, -380.0 ); +} + + +static void ToggleAnimate(void) +{ + Animate = !Animate; + if (Animate) { + glutIdleFunc( Idle ); + T0 = glutGet(GLUT_ELAPSED_TIME); + Frames = 0; + } + else { + glutIdleFunc( NULL ); + } +} + + +static void ModeMenu(int entry) +{ + if (entry==ANIMATE) { + ToggleAnimate(); + } + else if (entry==DO_SPEC_TEXTURE) { + DoSpecTexture = !DoSpecTexture; + } + else if (entry==OBJECT) { + if (Object == TeapotObj) + Object = CylinderObj; + else + Object = TeapotObj; + } + else if (entry==QUIT) { + exit(0); + } + glutPostRedisplay(); +} + + +static void Key( unsigned char key, int x, int y ) +{ + (void) x; + (void) y; + switch (key) { + case 's': + Shininess--; + if (Shininess < 0.0) + Shininess = 0.0; + glMaterialf(GL_FRONT, GL_SHININESS, Shininess); + printf("Shininess = %g\n", Shininess); + break; + case 'S': + Shininess++; + if (Shininess > 128.0) + Shininess = 128.0; + glMaterialf(GL_FRONT, GL_SHININESS, Shininess); + printf("Shininess = %g\n", Shininess); + break; + case 'a': + case ' ': + ToggleAnimate(); + break; + case 27: + exit(0); + break; + } + glutPostRedisplay(); +} + + +static void SpecialKey( int key, int x, int y ) +{ + float 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 +MouseMotion(int x, int y) +{ + const float k = 300.0; + if (ButtonDown) { + float dx = x - ButtonX; + float dy = y - ButtonY; + Xrot = Xrot0 + k * dy / WinWidth; + Yrot = Yrot0 + k * dx / WinHeight; + glutPostRedisplay(); + } +} + + +static void +MouseButton(int button, int state, int x, int y) +{ + if (button == GLUT_LEFT_BUTTON && state == GLUT_DOWN) { + ButtonDown = GL_TRUE; + ButtonX = x; + ButtonY = y; + Xrot0 = Xrot; + Yrot0 = Yrot; + } + else if (button == GLUT_LEFT_BUTTON && state == GLUT_UP) { + ButtonDown = GL_FALSE; + } +} + + +static void Init( int argc, char *argv[] ) +{ + GLboolean convolve = GL_FALSE; + GLboolean fullscreen = GL_FALSE; + int i; + + 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], "-c")==0) { + convolve = GL_TRUE; + } + else if (strcmp(argv[i], "-f")==0) { + fullscreen = GL_TRUE; + } + } + + if (fullscreen) + glutFullScreen(); + + /* Cylinder object */ + { + static GLfloat height = 100.0; + static GLfloat radius = 40.0; + static GLint slices = 24; /* pie slices around Z axis */ + static GLint stacks = 10; /* subdivisions along length of cylinder */ + static GLint rings = 4; /* rings in the end disks */ + GLUquadricObj *q = gluNewQuadric(); + assert(q); + gluQuadricTexture(q, GL_TRUE); + + CylinderObj = glGenLists(1); + glNewList(CylinderObj, GL_COMPILE); + + glPushMatrix(); + glTranslatef(0.0, 0.0, -0.5 * height); + + glMatrixMode(GL_TEXTURE); + glLoadIdentity(); + /*glScalef(8.0, 4.0, 2.0);*/ + glMatrixMode(GL_MODELVIEW); + + /* cylinder */ + gluQuadricNormals(q, GL_SMOOTH); + gluQuadricTexture(q, GL_TRUE); + gluCylinder(q, radius, radius, height, slices, stacks); + + /* end cap */ + glMatrixMode(GL_TEXTURE); + glLoadIdentity(); + glScalef(3.0, 3.0, 1.0); + glMatrixMode(GL_MODELVIEW); + + glTranslatef(0.0, 0.0, height); + gluDisk(q, 0.0, radius, slices, rings); + + /* other end cap */ + glTranslatef(0.0, 0.0, -height); + gluQuadricOrientation(q, GLU_INSIDE); + gluDisk(q, 0.0, radius, slices, rings); + + glPopMatrix(); + + glMatrixMode(GL_TEXTURE); + glLoadIdentity(); + glMatrixMode(GL_MODELVIEW); + + glEndList(); + gluDeleteQuadric(q); + } + + /* Teapot */ + { + TeapotObj = glGenLists(1); + glNewList(TeapotObj, GL_COMPILE); + + glFrontFace(GL_CW); + glutSolidTeapot(40.0); + glFrontFace(GL_CCW); + + glEndList(); + } + + /* show cylinder by default */ + Object = CylinderObj; + + + /* lighting */ + glEnable(GL_LIGHTING); + { + GLfloat pos[4] = { 3, 3, 3, 1 }; + glLightfv(GL_LIGHT0, GL_AMBIENT, Black); + glLightfv(GL_LIGHT0, GL_DIFFUSE, White); + glLightfv(GL_LIGHT0, GL_SPECULAR, White); + glLightfv(GL_LIGHT0, GL_POSITION, pos); + glEnable(GL_LIGHT0); + glMaterialfv(GL_FRONT, GL_AMBIENT, Black); + glMaterialf(GL_FRONT, GL_SHININESS, Shininess); + glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 1); + } + + /* Base texture */ + glGenTextures(1, &BaseTexture); + glBindTexture(GL_TEXTURE_2D, BaseTexture); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + if (!LoadRGBMipmaps(BASE_TEXTURE_FILE, GL_RGB)) { + printf("Error: couldn't load texture image file %s\n", BASE_TEXTURE_FILE); + exit(1); + } + + /* Specular texture */ + glGenTextures(1, &SpecularTexture); + 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); + glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); + glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); + if (convolve) { + /* use convolution to blur the texture to simulate a dull finish + * on the object. + */ + GLubyte *img; + GLenum format; + GLint w, h; + GLfloat filter[FILTER_SIZE][FILTER_SIZE][4]; + + for (h = 0; h < FILTER_SIZE; h++) { + for (w = 0; w < FILTER_SIZE; w++) { + const GLfloat k = 1.0 / (FILTER_SIZE * FILTER_SIZE); + filter[h][w][0] = k; + filter[h][w][1] = k; + filter[h][w][2] = k; + filter[h][w][3] = k; + } + } + + glEnable(GL_CONVOLUTION_2D); + glConvolutionParameteri(GL_CONVOLUTION_2D, + GL_CONVOLUTION_BORDER_MODE, GL_CONSTANT_BORDER); + glConvolutionFilter2D(GL_CONVOLUTION_2D, GL_RGBA, + FILTER_SIZE, FILTER_SIZE, + GL_RGBA, GL_FLOAT, filter); + + img = LoadRGBImage(SPECULAR_TEXTURE_FILE, &w, &h, &format); + if (!img) { + printf("Error: couldn't load texture image file %s\n", + SPECULAR_TEXTURE_FILE); + exit(1); + } + + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, w, h, 0, + format, GL_UNSIGNED_BYTE, img); + free(img); + } + else { + /* regular path */ + if (!LoadRGBMipmaps(SPECULAR_TEXTURE_FILE, GL_RGB)) { + printf("Error: couldn't load texture image file %s\n", + SPECULAR_TEXTURE_FILE); + exit(1); + } + } + + /* misc */ + glEnable(GL_CULL_FACE); + glEnable(GL_TEXTURE_2D); + glEnable(GL_DEPTH_TEST); + glEnable(GL_NORMALIZE); + + glPolygonOffset( -1, -1 ); +} + + +int main( int argc, char *argv[] ) +{ + glutInit( &argc, argv ); + glutInitWindowPosition(0, 0); + glutInitWindowSize(WinWidth, WinHeight); + + glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ); + + glutCreateWindow(argv[0] ); + + Init(argc, argv); + + glutReshapeFunc( Reshape ); + glutKeyboardFunc( Key ); + glutSpecialFunc( SpecialKey ); + glutDisplayFunc( Display ); + glutMotionFunc(MouseMotion); + glutMouseFunc(MouseButton); + if (Animate) + glutIdleFunc( Idle ); + + glutCreateMenu(ModeMenu); + glutAddMenuEntry("Toggle Highlight", DO_SPEC_TEXTURE); + glutAddMenuEntry("Toggle Object", OBJECT); + glutAddMenuEntry("Toggle Animate", ANIMATE); + glutAddMenuEntry("Quit", QUIT); + glutAttachMenu(GLUT_RIGHT_BUTTON); + + glutMainLoop(); + return 0; +} diff --git a/progs/demos/glslnoise.c b/progs/demos/glslnoise.c new file mode 100755 index 00000000000..2adb114e668 --- /dev/null +++ b/progs/demos/glslnoise.c @@ -0,0 +1,185 @@ +/* + * GLSL noise demo. + * + * Michal Krol + * 20 February 2006 + * + * Based on the original demo by: + * Stefan Gustavson (stegu@itn.liu.se) 2004, 2005 + */ + +#ifdef WIN32 +#include +#endif + +#include +#include +#include +#include +#include + +#ifdef WIN32 +#define GETPROCADDRESS(F) wglGetProcAddress(F) +#else +#define GETPROCADDRESS(F) glutGetProcAddress(F) +#endif + +static GLhandleARB fragShader; +static GLhandleARB vertShader; +static GLhandleARB program; + +static GLint uTime; + +static GLfloat u_time = 0.0f; + +static PFNGLCREATESHADEROBJECTARBPROC glCreateShaderObjectARB = NULL; +static PFNGLSHADERSOURCEARBPROC glShaderSourceARB = NULL; +static PFNGLCOMPILESHADERARBPROC glCompileShaderARB = NULL; +static PFNGLCREATEPROGRAMOBJECTARBPROC glCreateProgramObjectARB = NULL; +static PFNGLATTACHOBJECTARBPROC glAttachObjectARB = NULL; +static PFNGLLINKPROGRAMARBPROC glLinkProgramARB = NULL; +static PFNGLUSEPROGRAMOBJECTARBPROC glUseProgramObjectARB = NULL; +static PFNGLGETUNIFORMLOCATIONARBPROC glGetUniformLocationARB = NULL; +static PFNGLUNIFORM1FARBPROC glUniform1fARB = NULL; + +static void Redisplay (void) +{ + glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + glUniform1fARB (uTime, u_time); + + glPushMatrix (); + glutSolidSphere (2.0, 20, 10); + glPopMatrix (); + + glutSwapBuffers(); +} + +static void Idle (void) +{ + u_time += 0.1f; + glutPostRedisplay (); +} + +static void Reshape (int width, int height) +{ + glViewport (0, 0, width, height); + glMatrixMode (GL_PROJECTION); + glLoadIdentity (); + glFrustum (-1.0, 1.0, -1.0, 1.0, 5.0, 25.0); + glMatrixMode (GL_MODELVIEW); + glLoadIdentity (); + glTranslatef (0.0f, 0.0f, -15.0f); +} + +static void Key (unsigned char key, int x, int y) +{ + (void) x; + (void) y; + + switch (key) + { + case 27: + exit(0); + break; + } + glutPostRedisplay (); +} + +static void Init (void) +{ + static const char *fragShaderText = + "uniform float time;\n" + "void main () {\n" + " gl_FragColor = gl_Color * vec4 ((0.5 + 0.5 * vec3 (noise1 (\n" + " vec4 (4.0 * gl_TexCoord[0].xyz, 0.5 * time)))), 1.0);\n" + "}\n" + ; + static const char *vertShaderText = + "void main () {\n" + " gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n" + " gl_TexCoord[0] = gl_Vertex;\n" + " gl_FrontColor = gl_Color;\n" + "}\n" + ; + + if (!glutExtensionSupported ("GL_ARB_fragment_shader")) + { + printf ("Sorry, this demo requires GL_ARB_fragment_shader\n"); + exit(1); + } + if (!glutExtensionSupported ("GL_ARB_shader_objects")) + { + printf ("Sorry, this demo requires GL_ARB_shader_objects\n"); + exit(1); + } + if (!glutExtensionSupported ("GL_ARB_shading_language_100")) + { + printf ("Sorry, this demo requires GL_ARB_shading_language_100\n"); + exit(1); + } + if (!glutExtensionSupported ("GL_ARB_vertex_shader")) + { + printf ("Sorry, this demo requires GL_ARB_vertex_shader\n"); + exit(1); + } + + glCreateShaderObjectARB = (PFNGLCREATESHADEROBJECTARBPROC) + GETPROCADDRESS("glCreateShaderObjectARB"); + glShaderSourceARB = (PFNGLSHADERSOURCEARBPROC) + GETPROCADDRESS("glShaderSourceARB"); + glCompileShaderARB = (PFNGLCOMPILESHADERARBPROC) + GETPROCADDRESS("glCompileShaderARB"); + glCreateProgramObjectARB = (PFNGLCREATEPROGRAMOBJECTARBPROC) + GETPROCADDRESS("glCreateProgramObjectARB"); + glAttachObjectARB = (PFNGLATTACHOBJECTARBPROC) + GETPROCADDRESS("glAttachObjectARB"); + glLinkProgramARB = (PFNGLLINKPROGRAMARBPROC) + GETPROCADDRESS ("glLinkProgramARB"); + glUseProgramObjectARB = (PFNGLUSEPROGRAMOBJECTARBPROC) + GETPROCADDRESS("glUseProgramObjectARB"); + + glGetUniformLocationARB = (PFNGLGETUNIFORMLOCATIONARBPROC) + GETPROCADDRESS("glGetUniformLocationARB"); + glUniform1fARB = (PFNGLUNIFORM1FARBPROC) + GETPROCADDRESS("glUniform1fARB"); + + fragShader = glCreateShaderObjectARB (GL_FRAGMENT_SHADER_ARB); + glShaderSourceARB (fragShader, 1, &fragShaderText, NULL); + glCompileShaderARB (fragShader); + + vertShader = glCreateShaderObjectARB (GL_VERTEX_SHADER_ARB); + glShaderSourceARB (vertShader, 1, &vertShaderText, NULL); + glCompileShaderARB (vertShader); + + program = glCreateProgramObjectARB (); + glAttachObjectARB (program, fragShader); + glAttachObjectARB (program, vertShader); + glLinkProgramARB (program); + glUseProgramObjectARB (program); + + uTime = glGetUniformLocationARB (program, "time"); + + glClearColor (0.0f, 0.1f, 0.3f, 1.0f); + glEnable (GL_CULL_FACE); + glEnable (GL_DEPTH_TEST); + + printf ("GL_RENDERER = %s\n", (const char *) glGetString (GL_RENDERER)); +} + +int main (int argc, char *argv[]) +{ + glutInit (&argc, argv); + glutInitWindowPosition ( 0, 0); + glutInitWindowSize (200, 200); + glutInitDisplayMode (GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); + glutCreateWindow (argv[0]); + glutReshapeFunc (Reshape); + glutKeyboardFunc (Key); + glutDisplayFunc (Redisplay); + glutIdleFunc (Idle); + Init (); + glutMainLoop (); + return 0; +} + diff --git a/progs/demos/gltestperf.c b/progs/demos/gltestperf.c new file mode 100644 index 00000000000..be953901014 --- /dev/null +++ b/progs/demos/gltestperf.c @@ -0,0 +1,580 @@ +/* + * 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 +#include +#include +#include +#include + +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", (char *) 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", (char *) 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; +} diff --git a/progs/demos/glutfx.c b/progs/demos/glutfx.c new file mode 100644 index 00000000000..8bf55823897 --- /dev/null +++ b/progs/demos/glutfx.c @@ -0,0 +1,189 @@ + +/* + * Example of how one might use GLUT with the 3Dfx driver in full-screen mode. + * Note: this only works with X since we're using Mesa's GLX "hack" for + * using Glide. + * + * Goals: + * easy setup and input event handling with GLUT + * use 3Dfx hardware + * automatically set MESA environment variables + * don't lose mouse input focus + * + * Brian Paul This file is in the public domain. + */ + + +#include +#include +#include +#include + + +#define WIDTH 640 +#define HEIGHT 480 + + +static int Window = 0; +static int ScreenWidth, ScreenHeight; +static GLuint Torus = 0; +static GLfloat Xrot = 0.0, Yrot = 0.0; + + + +static void Display( void ) +{ + static GLfloat blue[4] = {0.2, 0.2, 1.0, 1.0}; + static GLfloat red[4] = {1.0, 0.2, 0.2, 1.0}; + static GLfloat green[4] = {0.2, 1.0, 0.2, 1.0}; + + glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); + + glPushMatrix(); + glRotatef(Xrot, 1, 0, 0); + glRotatef(Yrot, 0, 1, 0); + + glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, blue); + glCallList(Torus); + + glRotatef(90.0, 1, 0, 0); + glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, red); + glCallList(Torus); + + glRotatef(90.0, 0, 1, 0); + glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, green); + glCallList(Torus); + + glPopMatrix(); + + glutSwapBuffers(); +} + + +static void Reshape( int width, int height ) +{ + float ratio = (float) width / (float) height; + + ScreenWidth = width; + ScreenHeight = height; + + /* + * The 3Dfx driver is limited to 640 x 480 but the X window may be larger. + * Enforce that here. + */ + if (width > WIDTH) + width = WIDTH; + if (height > HEIGHT) + height = HEIGHT; + + glViewport( 0, 0, width, height ); + glMatrixMode( GL_PROJECTION ); + glLoadIdentity(); + glFrustum( -ratio, ratio, -1.0, 1.0, 5.0, 30.0 ); + glMatrixMode( GL_MODELVIEW ); + glLoadIdentity(); + glTranslatef( 0.0, 0.0, -20.0 ); +} + + +static void Key( unsigned char key, int x, int y ) +{ + (void) x; + (void) y; + switch (key) { + case 27: + glutDestroyWindow(Window); + exit(0); + break; + } + glutPostRedisplay(); +} + + +static void SpecialKey( int key, int x, int y ) +{ + (void) x; + (void) y; + switch (key) { + case GLUT_KEY_UP: + break; + case GLUT_KEY_DOWN: + break; + case GLUT_KEY_LEFT: + break; + case GLUT_KEY_RIGHT: + break; + } + glutPostRedisplay(); +} + + +static void MouseMove( int x, int y ) +{ + Xrot = y - ScreenWidth / 2; + Yrot = x - ScreenHeight / 2; + glutPostRedisplay(); +} + + +static void Init( void ) +{ + Torus = glGenLists(1); + glNewList(Torus, GL_COMPILE); + glutSolidTorus(0.5, 2.0, 10, 20); + glEndList(); + + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + + glEnable(GL_DEPTH_TEST); + glEnable(GL_CULL_FACE); +} + + +int main( int argc, char *argv[] ) +{ +#ifndef _WIN32 + 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"); +#endif + + /* Tell Mesa GLX to use 3Dfx driver in fullscreen mode. */ + putenv("MESA_GLX_FX=fullscreen"); + + /* Disable 3Dfx Glide splash screen */ + putenv("FX_GLIDE_NO_SPLASH="); + + /* Give an initial size and position so user doesn't have to place window */ + glutInitWindowPosition(0, 0); + glutInitWindowSize(WIDTH, HEIGHT); + glutInit( &argc, argv ); + + glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ); + + Window = glutCreateWindow(argv[0]); + if (!Window) { + printf("Error, couldn't open window\n"); + exit(1); + } + + /* + * Want the X window to fill the screen so that we don't have to + * worry about losing the mouse input focus. + * Note that we won't actually see the X window since we never draw + * to it, hence, the original X screen's contents aren't disturbed. + */ + glutFullScreen(); + + Init(); + + glutReshapeFunc( Reshape ); + glutKeyboardFunc( Key ); + glutSpecialFunc( SpecialKey ); + glutDisplayFunc( Display ); + glutPassiveMotionFunc( MouseMove ); + + glutMainLoop(); + return 0; +} diff --git a/progs/demos/ipers.c b/progs/demos/ipers.c new file mode 100644 index 00000000000..6e153c04e15 --- /dev/null +++ b/progs/demos/ipers.c @@ -0,0 +1,712 @@ +/* + * 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 +#include +#include +#include + +#if defined (WIN32)|| defined(_WIN32) +#include +#include +#endif + +#include + +#include "readtex.h" + +#ifdef XMESA +#include "GL/xmesa.h" +static int fullscreen = 1; +#endif + +static int WIDTH = 640; +static int HEIGHT = 480; + +static GLint T0; +static GLint Frames; + +#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", (char *) 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 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); + + if (dir[0] < 1.0e-5 && dir[0] > -1.0e-5) + dir[0] = 0; + if (dir[1] < 1.0e-5 && dir[1] > -1.0e-5) + dir[1] = 0; + if (dir[2] < 1.0e-5 && dir[2] > -1.0e-5) + dir[2] = 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, + "n - 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 char frbuf[80] = ""; + static GLfloat alpha = 0.0f; + static GLfloat beta = 0.0f; + static float fr = 0.0; + static double t0 = -1.; + double dt, t = glutGet(GLUT_ELAPSED_TIME) / 1000.0; + if (t0 < 0.0) + t0 = t; + dt = t - t0; + t0 = t; + + 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 += 4.f * dt; + beta += 2.4f * dt; + + 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 */ + + sprintf(frbuf, + "Frame rate: %0.2f LOD: %d Tot. poly.: %d Poly/sec: %.1f", + 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(); + + Frames++; + { + GLint t = glutGet(GLUT_ELAPSED_TIME); + if (t - T0 >= 2000) { + GLfloat seconds = (t - T0) / 1000.0; + fr = Frames / seconds; + T0 = t; + Frames = 0; + } + } +} + +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; +} diff --git a/progs/demos/isosurf.c b/progs/demos/isosurf.c new file mode 100644 index 00000000000..0710bc6047b --- /dev/null +++ b/progs/demos/isosurf.c @@ -0,0 +1,1125 @@ + +/* + * Display an isosurface of 3-D wind speed volume. + * + * Command line options: + * -info print GL implementation information + * + * Brian Paul This file in public domain. + */ + + +/* Keys: + * ===== + * + * - Arrow keys to rotate + * - 's' toggles smooth shading + * - 'l' toggles lighting + * - 'f' toggles fog + * - 'I' and 'i' zoom in and out + * - 'c' toggles a user clip plane + * - 'm' toggles colorful materials in GL_TRIANGLES modes. + * - '+' and '-' move the user clip plane + * + * Other options are available via the popup menu. + */ + +#include +#include +#include +#include +#include +#ifdef _WIN32 +#include +#undef CLIP_MASK +#endif +#define GL_GLEXT_PROTOTYPES +#include "GL/glut.h" + +#include "readtex.h" +#define TEXTURE_FILE "../images/reflect.rgb" + +#define LIT 0x00000001 +#define UNLIT 0x00000002 +#define REFLECT 0x00000004 +#define POINT_FILTER 0x00000008 +#define LINEAR_FILTER 0x00000010 +#define GLVERTEX 0x00000020 +#define DRAW_ELTS 0x00000040 +#define DRAW_ARRAYS 0x00000080 +#define ARRAY_ELT 0x00000100 +#define LOCKED 0x00000200 +#define UNLOCKED 0x00000400 +#define IMMEDIATE 0x00000800 +#define DISPLAYLIST 0x00001000 +#define SHADE_SMOOTH 0x00002000 +#define SHADE_FLAT 0x00004000 +#define TRIANGLES 0x00008000 +#define STRIPS 0x00010000 +#define POINTS 0x00020000 +#define USER_CLIP 0x00040000 +#define NO_USER_CLIP 0x00080000 +#define MATERIALS 0x00100000 +#define NO_MATERIALS 0x00200000 +#define FOG 0x00400000 +#define NO_FOG 0x00800000 +#define QUIT 0x01000000 +#define GLINFO 0x02000000 +#define STIPPLE 0x04000000 +#define NO_STIPPLE 0x08000000 +#define POLYGON_FILL 0x10000000 +#define POLYGON_LINE 0x20000000 + +#define LIGHT_MASK (LIT|UNLIT|REFLECT) +#define FILTER_MASK (POINT_FILTER|LINEAR_FILTER) +#define RENDER_STYLE_MASK (GLVERTEX|DRAW_ARRAYS|DRAW_ELTS|ARRAY_ELT) +#define DLIST_MASK (IMMEDIATE|DISPLAYLIST) +#define LOCK_MASK (LOCKED|UNLOCKED) +#define MATERIAL_MASK (MATERIALS|NO_MATERIALS) +#define PRIMITIVE_MASK (TRIANGLES|STRIPS|POINTS) +#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 POLYGON_MASK (POLYGON_FILL|POLYGON_LINE) + +#define MAXVERTS 10000 +static GLint maxverts = MAXVERTS; +static float data[MAXVERTS][6]; +static float compressed_data[MAXVERTS][6]; +static float expanded_data[MAXVERTS*3][6]; +static GLuint indices[MAXVERTS]; +static GLuint tri_indices[MAXVERTS*3]; +static GLuint strip_indices[MAXVERTS]; +static GLfloat col[100][4]; +static GLint numverts, num_tri_verts, numuniq; + +static GLfloat xrot; +static GLfloat yrot; +static GLfloat dist; +static GLint state, allowed = ~0; +static GLboolean doubleBuffer = GL_TRUE; +static GLdouble plane[4]; +static GLuint surf1, dlist_state; + +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}; + + +static void read_surface( char *filename ) +{ + FILE *f; + + f = fopen(filename,"r"); + if (!f) { + printf("couldn't read %s\n", filename); + exit(1); + } + + numverts = 0; + while (!feof(f) && numverts 0) return 1; \ + return 0; \ +} + +COMPARE_FUNC(0) +COMPARE_FUNC(1) +COMPARE_FUNC(2) +COMPARE_FUNC(3) +COMPARE_FUNC(4) +COMPARE_FUNC(5) +COMPARE_FUNC(6) + +int (*(compare[7]))( const void *a, const void *b ) = +{ + compare_axis_0, + compare_axis_1, + compare_axis_2, + compare_axis_3, + compare_axis_4, + compare_axis_5, + compare_axis_6, +}; + + +#define VEC_ELT(f, s, i) (float *)(((char *)f) + s * i) + +static int sort_axis( int axis, + int vec_size, + int vec_stride, + struct data_idx *indices, + int start, + int finish, + float *out, + int uniq, + const float fudge ) +{ + int i; + + if (finish-start > 2) + { + qsort( indices+start, finish-start, sizeof(*indices), compare[axis] ); + } + else if (indices[start].data[axis] > indices[start+1].data[axis]) + { + struct data_idx tmp = indices[start]; + indices[start] = indices[start+1]; + indices[start+1] = tmp; + } + + if (axis == vec_size-1) { + for (i = start ; i < finish ; ) { + float max = indices[i].data[axis] + fudge; + float *dest = VEC_ELT(out, vec_stride, uniq); + int j; + + for (j = 0 ; j < vec_size ; j++) + dest[j] = indices[i].data[j]; + + for ( ; i < finish && max >= indices[i].data[axis]; i++) + indices[i].uniq_idx = uniq; + + uniq++; + } + } else { + for (i = start ; i < finish ; ) { + int j = i + 1; + float max = indices[i].data[axis] + fudge; + while (j < finish && max >= indices[j].data[axis]) j++; + if (j == i+1) { + float *dest = VEC_ELT(out, vec_stride, uniq); + int k; + + indices[i].uniq_idx = uniq; + + for (k = 0 ; k < vec_size ; k++) + dest[k] = indices[i].data[k]; + + uniq++; + } else { + uniq = sort_axis( axis+1, vec_size, vec_stride, + indices, i, j, out, uniq, fudge ); + } + i = j; + } + } + + return uniq; +} + + +static void extract_indices1( const struct data_idx *in, unsigned int *out, + int n ) +{ + int i; + for ( i = 0 ; i < n ; i++ ) { + out[in[i].idx] = in[i].uniq_idx; + } +} + + +static void compactify_arrays(void) +{ + int i; + struct data_idx *ind; + + ind = (struct data_idx *) malloc( sizeof(struct data_idx) * numverts ); + + for (i = 0 ; i < numverts ; i++) { + ind[i].idx = i; + ind[i].data = data[i]; + } + + numuniq = sort_axis(0, + sizeof(compressed_data[0])/sizeof(float), + sizeof(compressed_data[0]), + ind, + 0, + numverts, + (float *)compressed_data, + 0, + 1e-6); + + printf("Nr unique vertex/normal pairs: %d\n", numuniq); + + extract_indices1( ind, indices, numverts ); + free( ind ); +} + +static void expand_arrays(void) +{ + int i; + int parity = 0; + for (i = 2 ; i < numverts ; i++, parity ^= 1) { + int v0 = i-2+parity; + int v1 = i-1-parity; + int v2 = i; + memcpy( expanded_data[(i-2)*3+0], data[v0], sizeof(data[0]) ); + memcpy( expanded_data[(i-2)*3+1], data[v1], sizeof(data[0]) ); + memcpy( expanded_data[(i-2)*3+2], data[v2], sizeof(data[0]) ); + } +} + +static float myrand( float max ) +{ + return max*rand()/(RAND_MAX+1.0); +} + + +static void make_tri_indices( void ) +{ + unsigned int *v = tri_indices; + unsigned int parity = 0; + int i, j; + + for (j=2;j Can't do strips here as ordering has been lost in + * compaction process... + */ + glVertexPointerEXT( 3, GL_FLOAT, sizeof(data[0]), numuniq, + compressed_data ); + glNormalPointerEXT( GL_FLOAT, sizeof(data[0]), numuniq, + &compressed_data[0][3]); +#ifdef GL_EXT_compiled_vertex_array + if (allowed & LOCKED) { + if (state & LOCKED) { + glLockArraysEXT( 0, numuniq ); + } else { + glUnlockArraysEXT(); + } + } +#endif + } + else if ((state & PRIMITIVE_MASK) == TRIANGLES && + (state & RENDER_STYLE_MASK) == DRAW_ARRAYS) { + fprintf(stderr, "enabling big arrays\n"); + /* Only get here for TRIANGLES and drawarrays + */ + glVertexPointerEXT( 3, GL_FLOAT, sizeof(data[0]), (numverts-2) * 3, + expanded_data ); + glNormalPointerEXT( GL_FLOAT, sizeof(data[0]), (numverts-2) * 3, + &expanded_data[0][3]); + +#ifdef GL_EXT_compiled_vertex_array + if (allowed & LOCKED) { + if (state & LOCKED) { + glLockArraysEXT( 0, (numverts-2)*3 ); + } else { + glUnlockArraysEXT(); + } + } +#endif + } + else { + fprintf(stderr, "enabling normal arrays\n"); + glVertexPointerEXT( 3, GL_FLOAT, sizeof(data[0]), numverts, data ); + glNormalPointerEXT( GL_FLOAT, sizeof(data[0]), numverts, &data[0][3]); +#ifdef GL_EXT_compiled_vertex_array + if (allowed & LOCKED) { + if (state & LOCKED) { + glLockArraysEXT( 0, numverts ); + } else { + glUnlockArraysEXT(); + } + } +#endif + } + + } +#endif + + + if (m & DLIST_MASK) { + UPDATE(state, m, DLIST_MASK); + } + + if (m & MATERIAL_MASK) { + UPDATE(state, m, MATERIAL_MASK); + } + + print_flags("new flags", state); + + glutPostRedisplay(); +} + + + +static void Init(int argc, char *argv[]) +{ + GLfloat fogColor[4] = {0.5,1.0,0.5,1.0}; + + xrot = 0; + yrot = 0; + dist = -6; + plane[0] = 1.0; + plane[1] = 0.0; + plane[2] = -1.0; + plane[3] = 0.0; + + glClearColor(0.0, 0.0, 1.0, 0.0); + glEnable( GL_DEPTH_TEST ); + glEnable( GL_VERTEX_ARRAY_EXT ); + glEnable( GL_NORMAL_ARRAY_EXT ); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glFrustum( -1.0, 1.0, -1.0, 1.0, 5, 25 ); + + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glClipPlane(GL_CLIP_PLANE0, plane); + + InitMaterials(); + + set_matrix(); + + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); + glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST); + + glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); + glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); + + + /* Green fog is easy to see */ + glFogi(GL_FOG_MODE,GL_EXP2); + glFogfv(GL_FOG_COLOR,fogColor); + glFogf(GL_FOG_DENSITY,0.15); + glHint(GL_FOG_HINT,GL_DONT_CARE); + + { + static int firsttime = 1; + if (firsttime) { + firsttime = 0; + compactify_arrays(); + expand_arrays(); + make_tri_indices(); + + if (!LoadRGBMipmaps(TEXTURE_FILE, GL_RGB)) { + printf("Error: couldn't load texture image\n"); + exit(1); + } + } + } + + ModeMenu(SHADE_SMOOTH| + LIT| + POINT_FILTER| + NO_USER_CLIP| + NO_MATERIALS| + NO_FOG| + NO_STIPPLE| + IMMEDIATE| + STRIPS| + UNLOCKED| + GLVERTEX); + + if (PrintInfo) { + 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 Reshape(int width, int height) +{ + glViewport(0, 0, (GLint)width, (GLint)height); +} + + + +static void Key( unsigned char key, int x, int y ) +{ + (void) x; + (void) y; + switch (key) { + case 27: + exit(0); + case 'f': + ModeMenu((state ^ FOG_MASK) & FOG_MASK); + break; + case 's': + ModeMenu((state ^ SHADE_MASK) & SHADE_MASK); + break; + case 't': + ModeMenu((state ^ STIPPLE_MASK) & STIPPLE_MASK); + break; + case 'l': + ModeMenu((state ^ LIGHT_MASK) & (LIT|UNLIT)); + break; + case 'm': + ModeMenu((state ^ MATERIAL_MASK) & MATERIAL_MASK); + break; + case 'c': + ModeMenu((state ^ CLIP_MASK) & CLIP_MASK); + break; + case 'v': + ModeMenu((LOCKED|IMMEDIATE|DRAW_ELTS|TRIANGLES) & allowed); + break; + case 'V': + ModeMenu(UNLOCKED|IMMEDIATE|GLVERTEX|STRIPS); + break; + case 'b': + Benchmark(5.0, 0); + break; + case 'B': + Benchmark(0, 5.0); + break; + case 'i': + dist += .25; + set_matrix(); + glutPostRedisplay(); + break; + case 'I': + dist -= .25; + set_matrix(); + glutPostRedisplay(); + break; + case '-': + case '_': + plane[3] += 2.0; + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glClipPlane(GL_CLIP_PLANE0, plane); + set_matrix(); + glutPostRedisplay(); + break; + case '+': + case '=': + plane[3] -= 2.0; + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glClipPlane(GL_CLIP_PLANE0, plane); + set_matrix(); + glutPostRedisplay(); + break; + case ' ': + Init(0,0); + break; + } +} + + +static void SpecialKey( int key, int x, int y ) +{ + (void) x; + (void) y; + switch (key) { + case GLUT_KEY_LEFT: + yrot -= 15.0; + break; + case GLUT_KEY_RIGHT: + yrot += 15.0; + break; + case GLUT_KEY_UP: + xrot += 15.0; + break; + case GLUT_KEY_DOWN: + xrot -= 15.0; + break; + default: + return; + } + set_matrix(); + glutPostRedisplay(); +} + + + +static GLint Args(int argc, char **argv) +{ + GLint i; + GLint mode = 0; + + 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 if (strcmp(argv[i], "-info") == 0) { + PrintInfo = GL_TRUE; + } + else if (strcmp(argv[i], "-10") == 0) { + maxverts = 10; + } + else if (strcmp(argv[i], "-100") == 0) { + maxverts = 100; + } + else if (strcmp(argv[i], "-1000") == 0) { + maxverts = 1000; + } + else { + printf("%s (Bad option).\n", argv[i]); + return QUIT; + } + } + + return mode; +} + +int main(int argc, char **argv) +{ + GLenum type; + char *extensions; + + GLuint arg_mode = Args(argc, argv); + + if (arg_mode & QUIT) + exit(0); + + read_surface( "isosurf.dat" ); + + glutInitWindowPosition(0, 0); + glutInitWindowSize(400, 400); + + type = GLUT_DEPTH; + type |= GLUT_RGB; + type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("Isosurface") <= 0) { + exit(0); + } + + /* Make sure server supports the vertex array extension */ + extensions = (char *) glGetString( GL_EXTENSIONS ); + + if (!strstr( extensions, "GL_EXT_vertex_array" )) + { + printf("Vertex arrays not supported by this renderer\n"); + allowed &= ~(LOCKED|DRAW_ARRAYS|DRAW_ELTS|ARRAY_ELT); + } + else if (!strstr( extensions, "GL_EXT_compiled_vertex_array" )) + { + printf("Compiled vertex arrays not supported by this renderer\n"); + allowed &= ~LOCKED; + } + + Init(argc, argv); + ModeMenu(arg_mode); + + glutCreateMenu(ModeMenu); + glutAddMenuEntry("GL info", GLINFO); + glutAddMenuEntry("", 0); + glutAddMenuEntry("Lit", LIT); + glutAddMenuEntry("Unlit", UNLIT); + glutAddMenuEntry("Reflect", REFLECT); + glutAddMenuEntry("", 0); + glutAddMenuEntry("Smooth", SHADE_SMOOTH); + glutAddMenuEntry("Flat", SHADE_FLAT); + glutAddMenuEntry("", 0); + glutAddMenuEntry("Fog", FOG); + glutAddMenuEntry("No Fog", NO_FOG); + glutAddMenuEntry("", 0); + glutAddMenuEntry("Stipple", STIPPLE); + glutAddMenuEntry("No Stipple", NO_STIPPLE); + glutAddMenuEntry("", 0); + glutAddMenuEntry("Polygon Mode Fill", POLYGON_FILL); + glutAddMenuEntry("Polygon Mode Line", POLYGON_LINE); + glutAddMenuEntry("", 0); + glutAddMenuEntry("Point Filtered", POINT_FILTER); + glutAddMenuEntry("Linear Filtered", LINEAR_FILTER); + glutAddMenuEntry("", 0); + glutAddMenuEntry("GL_TRIANGLES", TRIANGLES); + glutAddMenuEntry("GL_TRIANGLE_STRIPS", STRIPS); + glutAddMenuEntry("GL_POINTS", POINTS); + glutAddMenuEntry("", 0); + glutAddMenuEntry("Displaylist", DISPLAYLIST); + glutAddMenuEntry("Immediate", IMMEDIATE); + glutAddMenuEntry("", 0); + if (allowed & LOCKED) { + glutAddMenuEntry("Locked Arrays (CVA)", LOCKED); + glutAddMenuEntry("Unlocked Arrays", UNLOCKED); + glutAddMenuEntry("", 0); + } + glutAddMenuEntry("glVertex", GLVERTEX); + if (allowed & DRAW_ARRAYS) { + glutAddMenuEntry("glDrawElements", DRAW_ELTS); + glutAddMenuEntry("glDrawArrays", DRAW_ARRAYS); + glutAddMenuEntry("glArrayElement", ARRAY_ELT); + } + glutAddMenuEntry("", 0); + glutAddMenuEntry("Quit", QUIT); + glutAttachMenu(GLUT_RIGHT_BUTTON); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutSpecialFunc(SpecialKey); + glutDisplayFunc(Display); + + glutMainLoop(); + return 0; +} diff --git a/progs/demos/isosurf.dat b/progs/demos/isosurf.dat new file mode 100644 index 00000000000..5cadecdb430 --- /dev/null +++ b/progs/demos/isosurf.dat @@ -0,0 +1,7179 @@ +-1.000000 0.050200 0.254800 0.280000 0.504000 0.808000 +-1.000000 0.061400 0.243900 0.248000 0.608000 0.744000 +-0.973900 0.050200 0.243900 0.312000 0.448000 0.832000 +-1.000000 0.100400 0.207000 0.040000 0.608000 0.784000 +-0.950000 0.050200 0.232900 0.312000 0.424000 0.840000 +-0.950000 0.100400 0.204500 0.176000 0.504000 0.840000 +-0.900000 0.050200 0.202100 0.368000 0.256000 0.888000 +-0.900000 0.100400 0.184100 0.296000 0.408000 0.856000 +-0.865600 0.050200 0.182900 0.480000 0.256000 0.832000 +-0.897500 0.100400 0.182900 0.392000 0.408000 0.816000 +-0.850000 0.050200 0.170400 0.488000 0.296000 0.816000 +-0.850000 0.100400 0.150400 0.488000 0.512000 0.696000 +-0.800000 0.050200 0.139800 0.504000 0.392000 0.760000 +-0.820700 0.100400 0.121900 0.496000 0.488000 0.704000 +-0.800000 0.077200 0.121900 0.512000 0.416000 0.744000 +-0.800000 0.100400 0.105500 0.480000 0.456000 0.736000 +-0.781300 0.050200 0.121900 0.536000 0.400000 0.736000 +-0.750000 0.100400 0.065100 0.488000 0.448000 0.736000 +-0.750000 0.050200 0.097600 0.464000 0.408000 0.776000 +-0.744800 0.100400 0.060900 0.496000 0.456000 0.728000 +-0.700000 0.050200 0.061900 0.536000 0.368000 0.752000 +-0.700000 0.051600 0.060900 0.528000 0.416000 0.728000 +-0.699000 0.050200 0.060900 0.608000 0.360000 0.696000 +-0.700000 0.100400 0.019100 0.504000 0.504000 0.688000 +-0.650000 0.050200 0.008200 0.568000 0.384000 0.720000 +-0.680200 0.100400 0.000000 0.600000 0.440000 0.656000 +-0.650000 0.063100 0.000000 0.592000 0.392000 0.696000 +-0.650000 0.100400 -0.043200 0.600000 0.608000 0.496000 +-0.641800 0.050200 0.000000 0.616000 0.400000 0.664000 +-0.638000 0.100400 -0.060900 0.672000 0.632000 0.368000 +-0.600000 0.050200 -0.054100 0.640000 0.448000 0.616000 +-0.600000 0.057600 -0.060900 0.728000 0.536000 0.408000 +-0.594700 0.050200 -0.060900 0.744000 0.504000 0.416000 +-0.600000 0.050200 -0.083400 0.800000 0.528000 -0.248000 +-0.573200 0.000000 -0.060900 0.920000 0.296000 -0.248000 +-0.600000 0.000000 -0.117700 0.848000 0.200000 -0.488000 +-0.554400 -0.050200 -0.060900 0.944000 0.280000 0.128000 +-0.600000 -0.008200 -0.121900 0.848000 0.208000 -0.472000 +-0.586600 -0.050200 -0.121900 0.872000 0.224000 -0.424000 +-0.600000 -0.050200 -0.162700 0.904000 0.232000 -0.344000 +-0.578300 -0.100400 -0.121900 0.848000 0.312000 -0.424000 +-0.600000 -0.077900 -0.182900 0.856000 0.208000 -0.464000 +-0.594100 -0.100400 -0.182900 0.816000 0.296000 -0.480000 +-0.600000 -0.100400 -0.193800 0.776000 0.296000 -0.544000 +-0.561800 -0.150600 -0.182900 0.544000 0.784000 -0.280000 +-0.600000 -0.150600 -0.229400 0.416000 0.744000 -0.512000 +-0.550000 -0.155500 -0.182900 0.296000 0.920000 -0.232000 +-0.600000 -0.160400 -0.243900 0.432000 0.688000 -0.576000 +-0.550000 -0.172700 -0.243900 0.008000 0.856000 -0.512000 +-0.600000 -0.200800 -0.299500 0.000000 0.872000 -0.480000 +-0.550000 -0.200800 -0.303600 -0.040000 0.880000 -0.464000 +-0.600000 -0.203400 -0.304800 0.008000 0.768000 -0.632000 +-0.550000 -0.201300 -0.304800 -0.032000 0.864000 -0.488000 +-0.600000 -0.251000 -0.360600 -0.120000 0.624000 -0.760000 +-0.550000 -0.245600 -0.365800 -0.104000 0.680000 -0.720000 +-0.576800 -0.251000 -0.365800 -0.136000 0.624000 -0.760000 +-0.550000 -0.251000 -0.371400 -0.120000 0.616000 -0.768000 +-0.600000 -0.256300 -0.365800 -0.112000 0.608000 -0.776000 +-0.550000 -0.301200 -0.401000 0.000000 0.424000 -0.904000 +-0.600000 -0.301200 -0.399100 0.008000 0.480000 -0.872000 +-0.550000 -0.349500 -0.426800 0.056000 0.416000 -0.904000 +-0.600000 -0.340300 -0.426800 0.032000 0.512000 -0.848000 +-0.600000 -0.301200 -0.399100 0.008000 0.480000 -0.872000 +-0.650000 -0.337200 -0.426800 0.016000 0.520000 -0.848000 +-0.650000 -0.301200 -0.398600 0.000000 0.528000 -0.840000 +-0.700000 -0.338200 -0.426800 -0.192000 0.592000 -0.776000 +-0.700000 -0.301200 -0.401600 0.016000 0.504000 -0.856000 +-0.736800 -0.351500 -0.426800 -0.240000 0.480000 -0.832000 +-0.750000 -0.301200 -0.392900 -0.104000 0.352000 -0.928000 +-0.750000 -0.351500 -0.422100 -0.312000 0.448000 -0.824000 +-0.800000 -0.301200 -0.380800 -0.264000 0.104000 -0.952000 +-0.800000 -0.351500 -0.388300 -0.664000 -0.152000 -0.728000 +-0.826000 -0.301200 -0.365800 -0.648000 -0.448000 -0.600000 +-0.812200 -0.351500 -0.365800 -0.856000 -0.296000 -0.408000 +-0.850000 -0.301200 -0.321900 -0.728000 -0.616000 -0.280000 +-0.821000 -0.351500 -0.304800 -0.824000 -0.504000 0.232000 +-0.850000 -0.306900 -0.304800 -0.768000 -0.624000 0.072000 +-0.807300 -0.351500 -0.243900 -0.864000 -0.472000 0.152000 +-0.850000 -0.301200 -0.293400 -0.744000 -0.560000 0.336000 +-0.834700 -0.301200 -0.243900 -0.840000 -0.504000 0.184000 +-0.850000 -0.276800 -0.243900 -0.792000 -0.552000 0.248000 +-0.831100 -0.301200 -0.182900 -0.848000 -0.520000 0.016000 +-0.850000 -0.271300 -0.182900 -0.816000 -0.568000 0.032000 +-0.832400 -0.301200 -0.121900 -0.840000 -0.528000 0.048000 +-0.850000 -0.274400 -0.121900 -0.816000 -0.568000 0.008000 +-0.826600 -0.301200 -0.060900 -0.824000 -0.544000 0.120000 +-0.850000 -0.265600 -0.060900 -0.808000 -0.568000 0.104000 +-0.817700 -0.301200 0.000000 -0.808000 -0.560000 0.168000 +-0.850000 -0.254700 0.000000 -0.800000 -0.568000 0.168000 +-0.805900 -0.301200 0.060900 -0.800000 -0.536000 0.232000 +-0.850000 -0.251000 0.014600 -0.800000 -0.560000 0.176000 +-0.838400 -0.251000 0.060900 -0.808000 -0.528000 0.248000 +-0.850000 -0.233200 0.060900 -0.816000 -0.512000 0.248000 +-0.819200 -0.251000 0.121900 -0.760000 -0.496000 0.400000 +-0.850000 -0.203500 0.121900 -0.792000 -0.528000 0.288000 +-0.800000 -0.251000 0.157900 -0.576000 -0.400000 0.696000 +-0.850000 -0.200800 0.125700 -0.776000 -0.360000 0.504000 +-0.800000 -0.206500 0.182900 -0.304000 -0.264000 0.912000 +-0.803100 -0.200800 0.182900 -0.456000 -0.168000 0.864000 +-0.800000 -0.200800 0.184500 -0.256000 -0.128000 0.952000 +-0.836800 -0.150600 0.182900 -0.304000 -0.304000 0.896000 +-0.800000 -0.150600 0.189500 -0.240000 -0.056000 0.960000 +-0.850000 -0.137400 0.182900 -0.304000 -0.312000 0.896000 +-0.800000 -0.100400 0.186900 0.104000 0.048000 0.992000 +-0.850000 -0.100400 0.192600 -0.136000 -0.312000 0.936000 +-0.800000 -0.063400 0.182900 0.240000 0.160000 0.952000 +-0.850000 -0.050200 0.193400 0.200000 0.072000 0.968000 +-0.809300 -0.050200 0.182900 0.232000 0.160000 0.952000 +-0.850000 0.000000 0.186200 0.256000 0.144000 0.952000 +-0.839600 0.000000 0.182900 0.264000 0.152000 0.944000 +-0.850000 0.016800 0.182900 0.328000 0.184000 0.920000 +-0.800000 0.000000 0.163200 0.400000 0.288000 0.864000 +-0.850000 0.050200 0.170400 0.488000 0.296000 0.816000 +-0.800000 0.050200 0.139800 0.504000 0.392000 0.760000 +-0.800000 0.000000 0.163200 0.400000 0.288000 0.864000 +-0.781300 0.050200 0.121900 0.536000 0.400000 0.736000 +-0.750000 0.000000 0.129400 0.496000 0.360000 0.776000 +-0.750000 0.012900 0.121900 0.496000 0.384000 0.768000 +-0.740500 0.000000 0.121900 0.504000 0.352000 0.784000 +-0.750000 0.050200 0.097600 0.464000 0.408000 0.776000 +-0.700000 0.000000 0.089700 0.584000 0.336000 0.736000 +-0.700000 0.050200 0.061900 0.536000 0.368000 0.752000 +-0.666100 0.000000 0.060900 0.560000 0.376000 0.728000 +-0.699000 0.050200 0.060900 0.608000 0.360000 0.696000 +-0.650000 0.000000 0.045200 0.576000 0.400000 0.704000 +-0.650000 0.050200 0.008200 0.568000 0.384000 0.720000 +-0.609800 0.000000 0.000000 0.696000 0.384000 0.592000 +-0.641800 0.050200 0.000000 0.616000 0.400000 0.664000 +-0.600000 0.000000 -0.017800 0.736000 0.384000 0.544000 +-0.600000 0.050200 -0.054100 0.640000 0.448000 0.616000 +-0.573200 0.000000 -0.060900 0.920000 0.296000 -0.248000 +-0.594700 0.050200 -0.060900 0.744000 0.504000 0.416000 +-0.594700 0.050200 -0.060900 0.744000 0.504000 0.416000 +-1.000000 0.050200 0.254800 0.280000 0.504000 0.808000 +-1.000000 0.050200 0.254800 0.280000 0.504000 0.808000 +-1.000000 0.000000 0.260200 0.424000 -0.312000 0.840000 +-0.973900 0.050200 0.243900 0.312000 0.448000 0.832000 +-0.976100 0.000000 0.243900 0.464000 -0.432000 0.768000 +-0.950000 0.050200 0.232900 0.312000 0.424000 0.840000 +-0.950000 0.000000 0.224500 0.344000 -0.144000 0.920000 +-0.900000 0.050200 0.202100 0.368000 0.256000 0.888000 +-0.900000 0.000000 0.204000 0.296000 0.088000 0.944000 +-0.865600 0.050200 0.182900 0.480000 0.256000 0.832000 +-0.850000 0.000000 0.186200 0.256000 0.144000 0.952000 +-0.850000 0.016800 0.182900 0.328000 0.184000 0.920000 +-0.865600 0.050200 0.182900 0.480000 0.256000 0.832000 +-0.850000 0.050200 0.170400 0.488000 0.296000 0.816000 +-0.850000 0.050200 0.170400 0.488000 0.296000 0.816000 +-1.000000 0.000000 0.260200 0.424000 -0.312000 0.840000 +-1.000000 0.000000 0.260200 0.424000 -0.312000 0.840000 +-0.976100 0.000000 0.243900 0.464000 -0.432000 0.768000 +-1.000000 -0.016700 0.243900 0.424000 -0.608000 0.656000 +-0.950000 0.000000 0.224500 0.344000 -0.144000 0.920000 +-1.000000 -0.050200 0.185900 -0.256000 -0.768000 0.576000 +-0.950000 -0.050200 0.212200 0.160000 -0.384000 0.904000 +-1.000000 -0.052000 0.182900 -0.336000 -0.760000 0.544000 +-0.950000 -0.074300 0.182900 -0.344000 -0.776000 0.520000 +-1.000000 -0.075600 0.121900 -0.328000 -0.896000 0.264000 +-0.950000 -0.095300 0.121900 -0.400000 -0.864000 0.280000 +-1.000000 -0.090800 0.060900 -0.320000 -0.912000 0.248000 +-0.950000 -0.100400 0.101700 -0.400000 -0.872000 0.264000 +-0.973400 -0.100400 0.060900 -0.344000 -0.904000 0.240000 +-0.950000 -0.110600 0.060900 -0.432000 -0.856000 0.248000 +-1.000000 -0.100400 0.014600 -0.304000 -0.920000 0.208000 +-0.950000 -0.123700 0.000000 -0.488000 -0.840000 0.216000 +-1.000000 -0.103100 0.000000 -0.304000 -0.920000 0.208000 +-0.950000 -0.136200 -0.060900 -0.528000 -0.832000 0.152000 +-1.000000 -0.112800 -0.060900 -0.376000 -0.912000 0.144000 +-0.950000 -0.144800 -0.121900 -0.536000 -0.832000 0.120000 +-1.000000 -0.120900 -0.121900 -0.400000 -0.904000 0.136000 +-0.950000 -0.150600 -0.169000 -0.584000 -0.792000 0.136000 +-1.000000 -0.129600 -0.182900 -0.400000 -0.904000 0.136000 +-0.952800 -0.150600 -0.182900 -0.568000 -0.808000 0.136000 +-1.000000 -0.135800 -0.243900 -0.400000 -0.904000 0.096000 +-0.966700 -0.150600 -0.243900 -0.472000 -0.864000 0.152000 +-1.000000 -0.142300 -0.304800 -0.328000 -0.456000 -0.824000 +-0.989000 -0.150600 -0.304800 -0.440000 -0.624000 -0.640000 +-1.000000 -0.100400 -0.332000 -0.256000 -0.392000 -0.880000 +-0.950000 -0.150600 -0.330800 -0.416000 -0.432000 -0.792000 +-0.950000 -0.100400 -0.349400 -0.088000 -0.160000 -0.976000 +-0.900000 -0.150600 -0.338300 -0.216000 -0.104000 -0.968000 +-0.900000 -0.100400 -0.346700 0.112000 -0.048000 -0.984000 +-0.850000 -0.150600 -0.349400 0.072000 0.056000 -0.992000 +-0.850000 -0.100400 -0.332400 0.280000 0.112000 -0.952000 +-0.800000 -0.150600 -0.340500 0.312000 0.288000 -0.896000 +-0.800000 -0.100400 -0.313000 0.368000 0.216000 -0.896000 +-0.750000 -0.150600 -0.317800 0.416000 0.384000 -0.816000 +-0.785000 -0.100400 -0.304800 0.328000 0.224000 -0.912000 +-0.750000 -0.129200 -0.304800 0.392000 0.376000 -0.832000 +-0.750000 -0.100400 -0.291100 0.336000 0.256000 -0.896000 +-0.731900 -0.150600 -0.304800 0.424000 0.400000 -0.808000 +-0.700000 -0.100400 -0.274700 0.392000 0.112000 -0.904000 +-0.700000 -0.150600 -0.284500 0.376000 0.392000 -0.832000 +-0.650000 -0.100400 -0.251900 0.448000 0.224000 -0.856000 +-0.650000 -0.150600 -0.267500 0.376000 0.464000 -0.792000 +-0.638400 -0.100400 -0.243900 0.560000 0.160000 -0.808000 +-0.612700 -0.150600 -0.243900 0.496000 0.576000 -0.640000 +-0.600000 -0.100400 -0.193800 0.776000 0.296000 -0.544000 +-0.600000 -0.150600 -0.229400 0.416000 0.744000 -0.512000 +-0.612700 -0.150600 -0.243900 0.496000 0.576000 -0.640000 +-0.600000 -0.160400 -0.243900 0.432000 0.688000 -0.576000 +-0.650000 -0.150600 -0.267500 0.376000 0.464000 -0.792000 +-0.600000 -0.200800 -0.299500 0.000000 0.872000 -0.480000 +-0.650000 -0.200800 -0.303800 0.136000 0.680000 -0.712000 +-0.600000 -0.203400 -0.304800 0.008000 0.768000 -0.632000 +-0.650000 -0.201600 -0.304800 0.104000 0.688000 -0.704000 +-0.600000 -0.251000 -0.360600 -0.120000 0.624000 -0.760000 +-0.650000 -0.251000 -0.354800 0.152000 0.632000 -0.752000 +-0.600000 -0.256300 -0.365800 -0.112000 0.608000 -0.776000 +-0.650000 -0.261300 -0.365800 0.088000 0.568000 -0.808000 +-0.600000 -0.301200 -0.399100 0.008000 0.480000 -0.872000 +-0.650000 -0.301200 -0.398600 0.000000 0.528000 -0.840000 +-0.650000 -0.261300 -0.365800 0.088000 0.568000 -0.808000 +-0.700000 -0.301200 -0.401600 0.016000 0.504000 -0.856000 +-0.700000 -0.252100 -0.365800 0.096000 0.552000 -0.824000 +-0.750000 -0.301200 -0.392900 -0.104000 0.352000 -0.928000 +-0.707800 -0.251000 -0.365800 0.064000 0.432000 -0.896000 +-0.750000 -0.251000 -0.369800 0.056000 0.280000 -0.952000 +-0.750000 -0.240500 -0.365800 0.056000 0.272000 -0.952000 +-0.800000 -0.251000 -0.370300 -0.064000 0.200000 -0.976000 +-0.800000 -0.234100 -0.365800 -0.112000 0.264000 -0.952000 +-0.828000 -0.251000 -0.365800 -0.248000 0.216000 -0.936000 +-0.800000 -0.200800 -0.355700 0.080000 0.256000 -0.960000 +-0.850000 -0.251000 -0.359600 -0.320000 0.248000 -0.912000 +-0.850000 -0.200800 -0.351200 -0.168000 0.112000 -0.976000 +-0.891700 -0.251000 -0.304800 -0.808000 -0.512000 -0.264000 +-0.900000 -0.200800 -0.331500 -0.576000 -0.328000 -0.736000 +-0.900000 -0.236500 -0.304800 -0.680000 -0.456000 -0.560000 +-0.931500 -0.200800 -0.304800 -0.648000 -0.520000 -0.544000 +-0.900000 -0.212400 -0.243900 -0.672000 -0.712000 0.176000 +-0.914100 -0.200800 -0.243900 -0.664000 -0.728000 0.128000 +-0.900000 -0.206900 -0.182900 -0.648000 -0.752000 0.056000 +-0.907400 -0.200800 -0.182900 -0.688000 -0.712000 0.072000 +-0.900000 -0.204500 -0.121900 -0.688000 -0.712000 0.104000 +-0.903800 -0.200800 -0.121900 -0.696000 -0.704000 0.120000 +-0.900000 -0.200800 -0.096200 -0.752000 -0.632000 0.128000 +-0.943100 -0.150600 -0.121900 -0.672000 -0.720000 0.120000 +-0.900000 -0.192500 -0.060900 -0.856000 -0.488000 0.144000 +-0.932400 -0.150600 -0.060900 -0.688000 -0.696000 0.176000 +-0.900000 -0.169600 0.000000 -0.800000 -0.552000 0.224000 +-0.915700 -0.150600 0.000000 -0.696000 -0.672000 0.232000 +-0.900000 -0.150600 0.057700 -0.744000 -0.616000 0.232000 +-0.950000 -0.123700 0.000000 -0.488000 -0.840000 0.216000 +-0.900000 -0.149700 0.060900 -0.696000 -0.664000 0.232000 +-0.950000 -0.110600 0.060900 -0.432000 -0.856000 0.248000 +-0.900000 -0.127600 0.121900 -0.608000 -0.704000 0.344000 +-0.950000 -0.100400 0.101700 -0.400000 -0.872000 0.264000 +-0.939400 -0.100400 0.121900 -0.456000 -0.816000 0.336000 +-0.950000 -0.095300 0.121900 -0.400000 -0.864000 0.280000 +-0.900000 -0.100400 0.174900 -0.400000 -0.624000 0.656000 +-0.950000 -0.074300 0.182900 -0.344000 -0.776000 0.520000 +-0.900000 -0.094400 0.182900 -0.312000 -0.608000 0.720000 +-0.950000 -0.050200 0.212200 0.160000 -0.384000 0.904000 +-0.900000 -0.050200 0.208600 0.200000 -0.168000 0.960000 +-0.950000 0.000000 0.224500 0.344000 -0.144000 0.920000 +-0.900000 0.000000 0.204000 0.296000 0.088000 0.944000 +-0.900000 -0.050200 0.208600 0.200000 -0.168000 0.960000 +-0.850000 0.000000 0.186200 0.256000 0.144000 0.952000 +-0.850000 -0.050200 0.193400 0.200000 0.072000 0.968000 +-0.900000 -0.050200 0.208600 0.200000 -0.168000 0.960000 +-0.850000 -0.100400 0.192600 -0.136000 -0.312000 0.936000 +-0.900000 -0.094400 0.182900 -0.312000 -0.608000 0.720000 +-0.886800 -0.100400 0.182900 -0.288000 -0.576000 0.752000 +-0.900000 -0.100400 0.174900 -0.400000 -0.624000 0.656000 +-0.850000 -0.137400 0.182900 -0.304000 -0.312000 0.896000 +-0.900000 -0.127600 0.121900 -0.608000 -0.704000 0.344000 +-0.850000 -0.150600 0.175600 -0.632000 -0.392000 0.664000 +-0.878400 -0.150600 0.121900 -0.736000 -0.560000 0.368000 +-0.850000 -0.200800 0.125700 -0.776000 -0.360000 0.504000 +-0.851500 -0.200800 0.121900 -0.832000 -0.360000 0.408000 +-0.850000 -0.203500 0.121900 -0.792000 -0.528000 0.288000 +-0.869300 -0.200800 0.060900 -0.824000 -0.496000 0.248000 +-0.850000 -0.233200 0.060900 -0.816000 -0.512000 0.248000 +-0.882700 -0.200800 0.000000 -0.840000 -0.496000 0.192000 +-0.850000 -0.251000 0.014600 -0.800000 -0.560000 0.176000 +-0.852600 -0.251000 0.000000 -0.800000 -0.568000 0.168000 +-0.850000 -0.254700 0.000000 -0.800000 -0.568000 0.168000 +-0.860100 -0.251000 -0.060900 -0.808000 -0.568000 0.112000 +-0.850000 -0.265600 -0.060900 -0.808000 -0.568000 0.104000 +-0.866600 -0.251000 -0.121900 -0.808000 -0.576000 0.072000 +-0.850000 -0.274400 -0.121900 -0.816000 -0.568000 0.008000 +-0.864200 -0.251000 -0.182900 -0.800000 -0.592000 0.000000 +-0.850000 -0.271300 -0.182900 -0.816000 -0.568000 0.032000 +-0.869200 -0.251000 -0.243900 -0.768000 -0.600000 0.200000 +-0.850000 -0.276800 -0.243900 -0.792000 -0.552000 0.248000 +-0.891700 -0.251000 -0.304800 -0.808000 -0.512000 -0.264000 +-0.850000 -0.301200 -0.293400 -0.744000 -0.560000 0.336000 +-0.854400 -0.301200 -0.304800 -0.776000 -0.608000 0.112000 +-0.850000 -0.306900 -0.304800 -0.768000 -0.624000 0.072000 +-0.850000 -0.301200 -0.321900 -0.728000 -0.616000 -0.280000 +-0.854400 -0.301200 -0.304800 -0.776000 -0.608000 0.112000 +-0.850000 -0.251000 -0.359600 -0.320000 0.248000 -0.912000 +-0.891700 -0.251000 -0.304800 -0.808000 -0.512000 -0.264000 +-0.891700 -0.251000 -0.304800 -0.808000 -0.512000 -0.264000 +-1.000000 0.100400 0.207000 0.040000 0.608000 0.784000 +-1.000000 0.100400 0.207000 0.040000 0.608000 0.784000 +-0.950000 0.100400 0.204500 0.176000 0.504000 0.840000 +-1.000000 0.136100 0.182900 0.152000 0.600000 0.776000 +-0.950000 0.127100 0.182900 0.248000 0.536000 0.800000 +-1.000000 0.150600 0.170300 0.208000 0.568000 0.792000 +-0.950000 0.150600 0.154300 0.208000 0.640000 0.736000 +-1.000000 0.192500 0.121900 0.192000 0.664000 0.720000 +-0.950000 0.178500 0.121900 0.272000 0.648000 0.704000 +-1.000000 0.200800 0.112700 0.192000 0.656000 0.720000 +-0.950000 0.200800 0.096100 0.208000 0.672000 0.704000 +-1.000000 0.241600 0.060900 0.248000 0.768000 0.584000 +-0.950000 0.226300 0.060900 0.264000 0.760000 0.584000 +-1.000000 0.251000 0.045400 0.264000 0.768000 0.568000 +-0.950000 0.251000 0.016800 0.288000 0.808000 0.504000 +-1.000000 0.274600 0.000000 0.264000 0.848000 0.448000 +-0.950000 0.258900 0.000000 0.296000 0.848000 0.432000 +-1.000000 0.294800 -0.060900 0.312000 0.944000 0.080000 +-0.950000 0.277400 -0.060900 0.336000 0.928000 0.080000 +-1.000000 0.286500 -0.121900 0.328000 0.872000 -0.344000 +-0.950000 0.267200 -0.121900 0.344000 0.864000 -0.336000 +-1.000000 0.256900 -0.182900 0.288000 0.752000 -0.584000 +-0.950000 0.251000 -0.157200 0.320000 0.808000 -0.480000 +-0.985000 0.251000 -0.182900 0.288000 0.752000 -0.576000 +-0.950000 0.237800 -0.182900 0.296000 0.760000 -0.568000 +-1.000000 0.251000 -0.191500 0.280000 0.728000 -0.616000 +-0.950000 0.200800 -0.231900 0.272000 0.640000 -0.704000 +-1.000000 0.207900 -0.243900 0.232000 0.640000 -0.728000 +-0.980800 0.200800 -0.243900 0.232000 0.632000 -0.736000 +-1.000000 0.200800 -0.251300 0.232000 0.624000 -0.736000 +-0.950000 0.189400 -0.243900 0.264000 0.616000 -0.728000 +-1.000000 0.150600 -0.296000 0.168000 0.544000 -0.816000 +-0.950000 0.150600 -0.281200 0.240000 0.600000 -0.752000 +-1.000000 0.137800 -0.304800 0.104000 0.472000 -0.872000 +-0.950000 0.126000 -0.304800 0.168000 0.528000 -0.824000 +-1.000000 0.100400 -0.326700 0.072000 0.384000 -0.912000 +-0.950000 0.100400 -0.325900 0.192000 0.384000 -0.896000 +-1.000000 0.050200 -0.349300 0.080000 0.216000 -0.968000 +-0.950000 0.050200 -0.340200 0.184000 0.072000 -0.976000 +-1.000000 0.000000 -0.357700 0.216000 -0.064000 -0.968000 +-0.950000 0.000000 -0.337100 0.184000 -0.088000 -0.976000 +-1.000000 -0.050200 -0.339100 0.152000 -0.176000 -0.968000 +-0.950000 -0.050200 -0.337400 0.088000 0.008000 -0.992000 +-1.000000 -0.100400 -0.332000 -0.256000 -0.392000 -0.880000 +-0.950000 -0.100400 -0.349400 -0.088000 -0.160000 -0.976000 +-0.950000 -0.050200 -0.337400 0.088000 0.008000 -0.992000 +-0.900000 -0.100400 -0.346700 0.112000 -0.048000 -0.984000 +-0.900000 -0.050200 -0.330000 0.160000 0.128000 -0.976000 +-0.850000 -0.100400 -0.332400 0.280000 0.112000 -0.952000 +-0.850000 -0.050200 -0.323400 0.248000 0.176000 -0.944000 +-0.800000 -0.100400 -0.313000 0.368000 0.216000 -0.896000 +-0.808200 -0.050200 -0.304800 0.280000 0.136000 -0.944000 +-0.800000 -0.066700 -0.304800 0.296000 0.144000 -0.936000 +-0.800000 -0.050200 -0.302200 0.264000 0.120000 -0.952000 +-0.785000 -0.100400 -0.304800 0.328000 0.224000 -0.912000 +-0.750000 -0.050200 -0.287100 0.288000 0.040000 -0.952000 +-0.750000 -0.100400 -0.291100 0.336000 0.256000 -0.896000 +-0.700000 -0.050200 -0.272000 0.360000 0.104000 -0.920000 +-0.700000 -0.100400 -0.274700 0.392000 0.112000 -0.904000 +-0.650000 -0.050200 -0.249300 0.496000 0.208000 -0.840000 +-0.650000 -0.100400 -0.251900 0.448000 0.224000 -0.856000 +-0.642900 -0.050200 -0.243900 0.560000 0.208000 -0.792000 +-0.638400 -0.100400 -0.243900 0.560000 0.160000 -0.808000 +-0.606100 -0.050200 -0.182900 0.864000 0.248000 -0.424000 +-0.600000 -0.100400 -0.193800 0.776000 0.296000 -0.544000 +-0.600000 -0.077900 -0.182900 0.856000 0.208000 -0.464000 +-0.606100 -0.050200 -0.182900 0.864000 0.248000 -0.424000 +-0.600000 -0.050200 -0.162700 0.904000 0.232000 -0.344000 +-0.621400 0.000000 -0.182900 0.848000 0.280000 -0.440000 +-0.600000 -0.008200 -0.121900 0.848000 0.208000 -0.472000 +-0.601900 0.000000 -0.121900 0.848000 0.208000 -0.472000 +-0.600000 0.000000 -0.117700 0.848000 0.200000 -0.488000 +-0.614300 0.050200 -0.121900 0.720000 0.480000 -0.480000 +-0.600000 0.050200 -0.083400 0.800000 0.528000 -0.248000 +-0.650000 0.089500 -0.121900 0.728000 0.552000 -0.384000 +-0.600000 0.057600 -0.060900 0.728000 0.536000 0.408000 +-0.650000 0.100400 -0.098000 0.720000 0.624000 -0.288000 +-0.638000 0.100400 -0.060900 0.672000 0.632000 0.368000 +-0.650000 0.112000 -0.060900 0.672000 0.704000 0.200000 +-0.650000 0.100400 -0.043200 0.600000 0.608000 0.496000 +-0.689800 0.150600 -0.060900 0.640000 0.736000 0.192000 +-0.680200 0.100400 0.000000 0.600000 0.440000 0.656000 +-0.700000 0.150600 -0.043600 0.552000 0.712000 0.424000 +-0.700000 0.121800 0.000000 0.536000 0.544000 0.632000 +-0.734000 0.150600 0.000000 0.496000 0.640000 0.576000 +-0.700000 0.100400 0.019100 0.504000 0.504000 0.688000 +-0.750000 0.150600 0.014500 0.472000 0.624000 0.608000 +-0.744800 0.100400 0.060900 0.496000 0.456000 0.728000 +-0.750000 0.106000 0.060900 0.496000 0.464000 0.728000 +-0.750000 0.100400 0.065100 0.488000 0.448000 0.736000 +-0.796300 0.150600 0.060900 0.512000 0.584000 0.616000 +-0.800000 0.100400 0.105500 0.480000 0.456000 0.736000 +-0.800000 0.150600 0.064100 0.424000 0.560000 0.704000 +-0.820700 0.100400 0.121900 0.496000 0.488000 0.704000 +-0.850000 0.150600 0.098600 0.360000 0.600000 0.704000 +-0.850000 0.127100 0.121900 0.424000 0.560000 0.704000 +-0.892900 0.150600 0.121900 0.360000 0.624000 0.680000 +-0.850000 0.100400 0.150400 0.488000 0.512000 0.696000 +-0.900000 0.150600 0.126400 0.344000 0.632000 0.688000 +-0.897500 0.100400 0.182900 0.392000 0.408000 0.816000 +-0.900000 0.101900 0.182900 0.304000 0.552000 0.768000 +-0.900000 0.100400 0.184100 0.296000 0.408000 0.856000 +-0.950000 0.127100 0.182900 0.248000 0.536000 0.800000 +-0.950000 0.100400 0.204500 0.176000 0.504000 0.840000 +-0.950000 0.100400 0.204500 0.176000 0.504000 0.840000 +-0.886800 -0.100400 0.182900 -0.288000 -0.576000 0.752000 +-0.886800 -0.100400 0.182900 -0.288000 -0.576000 0.752000 +-0.850000 -0.100400 0.192600 -0.136000 -0.312000 0.936000 +-0.850000 -0.137400 0.182900 -0.304000 -0.312000 0.896000 +-0.850000 -0.137400 0.182900 -0.304000 -0.312000 0.896000 +-0.800000 -0.100400 0.186900 0.104000 0.048000 0.992000 +-0.800000 -0.100400 0.186900 0.104000 0.048000 0.992000 +-0.800000 -0.063400 0.182900 0.240000 0.160000 0.952000 +-0.776900 -0.100400 0.182900 0.184000 0.120000 0.968000 +-0.800000 -0.050200 0.179900 0.264000 0.176000 0.944000 +-0.750000 -0.100400 0.174700 0.320000 0.192000 0.920000 +-0.750000 -0.050200 0.155100 0.464000 0.288000 0.832000 +-0.700000 -0.100400 0.138900 0.488000 0.288000 0.816000 +-0.708600 -0.050200 0.121900 0.496000 0.344000 0.784000 +-0.700000 -0.062200 0.121900 0.504000 0.344000 0.784000 +-0.700000 -0.050200 0.115300 0.496000 0.344000 0.792000 +-0.677900 -0.100400 0.121900 0.528000 0.328000 0.776000 +-0.650000 -0.050200 0.076400 0.576000 0.320000 0.744000 +-0.650000 -0.100400 0.096100 0.592000 0.288000 0.744000 +-0.635700 -0.050200 0.060900 0.640000 0.304000 0.696000 +-0.612900 -0.100400 0.060900 0.624000 0.376000 0.672000 +-0.600000 -0.050200 0.018400 0.648000 0.320000 0.688000 +-0.600000 -0.100400 0.044600 0.672000 0.336000 0.656000 +-0.584800 -0.050200 0.000000 0.744000 0.336000 0.568000 +-0.565600 -0.100400 0.000000 0.744000 0.440000 0.496000 +-0.554400 -0.050200 -0.060900 0.944000 0.280000 0.128000 +-0.550000 -0.100400 -0.036900 0.792000 0.376000 0.464000 +-0.550000 -0.066800 -0.060900 0.944000 0.320000 -0.008000 +-0.533200 -0.100400 -0.060900 0.712000 0.696000 -0.024000 +-0.550000 -0.100400 -0.079500 0.552000 0.552000 -0.616000 +-0.500000 -0.119500 -0.060900 -0.160000 0.976000 0.112000 +-0.550000 -0.145600 -0.121900 0.512000 0.792000 -0.312000 +-0.500000 -0.144400 -0.121900 -0.376000 0.880000 -0.280000 +-0.550000 -0.150600 -0.142400 0.376000 0.896000 -0.200000 +-0.500000 -0.150600 -0.154000 -0.424000 0.880000 -0.160000 +-0.550000 -0.155500 -0.182900 0.296000 0.920000 -0.232000 +-0.500000 -0.154300 -0.182900 -0.320000 0.920000 -0.176000 +-0.550000 -0.172700 -0.243900 0.008000 0.856000 -0.512000 +-0.500000 -0.169200 -0.243900 -0.328000 0.880000 -0.312000 +-0.550000 -0.200800 -0.303600 -0.040000 0.880000 -0.464000 +-0.500000 -0.196700 -0.304800 -0.120000 0.848000 -0.504000 +-0.544700 -0.200800 -0.304800 -0.080000 0.824000 -0.552000 +-0.500000 -0.200800 -0.313000 -0.112000 0.824000 -0.544000 +-0.550000 -0.201300 -0.304800 -0.032000 0.864000 -0.488000 +-0.500000 -0.238600 -0.365800 -0.072000 0.656000 -0.744000 +-0.550000 -0.245600 -0.365800 -0.104000 0.680000 -0.720000 +-0.500000 -0.251000 -0.377000 -0.032000 0.528000 -0.840000 +-0.550000 -0.251000 -0.371400 -0.120000 0.616000 -0.768000 +-0.500000 -0.301200 -0.402500 0.040000 0.344000 -0.936000 +-0.550000 -0.301200 -0.401000 0.000000 0.424000 -0.904000 +-0.500000 -0.351500 -0.423900 0.056000 0.504000 -0.856000 +-0.550000 -0.349500 -0.426800 0.056000 0.416000 -0.904000 +-0.538500 -0.351500 -0.426800 0.048000 0.480000 -0.872000 +-0.500000 -0.351500 -0.423900 0.056000 0.504000 -0.856000 +-0.500000 -0.355300 -0.426800 0.056000 0.520000 -0.848000 +-0.450000 -0.351500 -0.418600 0.080000 0.512000 -0.848000 +-0.450000 -0.362400 -0.426800 0.064000 0.520000 -0.848000 +-0.400000 -0.351500 -0.411400 0.000000 0.616000 -0.784000 +-0.400000 -0.368700 -0.426800 0.024000 0.560000 -0.824000 +-0.350000 -0.351500 -0.416300 -0.176000 0.600000 -0.768000 +-0.350000 -0.360100 -0.426800 -0.128000 0.680000 -0.712000 +-0.319100 -0.351500 -0.426800 -0.216000 0.568000 -0.784000 +-0.350000 -0.351500 -0.416300 -0.176000 0.600000 -0.768000 +-0.300000 -0.341100 -0.426800 -0.128000 0.536000 -0.832000 +-0.350000 -0.301200 -0.377400 0.232000 0.208000 -0.944000 +-0.300000 -0.301200 -0.369600 0.320000 0.544000 -0.768000 +-0.350000 -0.251000 -0.367200 0.240000 0.168000 -0.952000 +-0.300000 -0.296900 -0.365800 0.296000 0.528000 -0.784000 +-0.345700 -0.251000 -0.365800 0.320000 0.336000 -0.880000 +-0.300000 -0.251000 -0.348000 0.192000 0.248000 -0.944000 +-0.350000 -0.248400 -0.365800 0.184000 0.424000 -0.880000 +-0.300000 -0.200800 -0.340600 0.016000 0.280000 -0.952000 +-0.350000 -0.200800 -0.339000 0.200000 0.416000 -0.880000 +-0.300000 -0.150600 -0.319300 -0.256000 0.480000 -0.832000 +-0.350000 -0.159400 -0.304800 -0.248000 0.528000 -0.808000 +-0.331500 -0.150600 -0.304800 -0.256000 0.464000 -0.840000 +-0.350000 -0.150600 -0.298700 -0.264000 0.464000 -0.840000 +-0.300000 -0.118900 -0.304800 -0.376000 0.264000 -0.880000 +-0.350000 -0.100400 -0.248500 -0.576000 0.440000 -0.680000 +-0.300000 -0.100400 -0.298100 -0.480000 0.288000 -0.824000 +-0.350000 -0.093900 -0.243900 -0.600000 0.408000 -0.680000 +-0.300000 -0.050200 -0.270300 -0.824000 0.232000 -0.512000 +-0.321700 -0.050200 -0.243900 -0.656000 0.344000 -0.656000 +-0.300000 0.000000 -0.248500 -0.656000 0.560000 -0.488000 +-0.301700 0.000000 -0.243900 -0.744000 0.392000 -0.536000 +-0.300000 0.001800 -0.243900 -0.496000 0.680000 -0.520000 +-0.340600 0.000000 -0.182900 -0.696000 0.480000 -0.520000 +-0.300000 0.050200 -0.185100 -0.648000 0.560000 -0.504000 +-0.301000 0.050200 -0.182900 -0.704000 0.472000 -0.512000 +-0.300000 0.052000 -0.182900 -0.664000 0.464000 -0.568000 +-0.335400 0.050200 -0.121900 -0.752000 0.472000 -0.456000 +-0.300000 0.100400 -0.141500 -0.560000 0.512000 -0.640000 +-0.317300 0.100400 -0.121900 -0.712000 0.264000 -0.640000 +-0.300000 0.144000 -0.121900 -0.728000 0.496000 -0.456000 +-0.350000 0.100400 -0.076700 -0.736000 0.256000 -0.616000 +-0.300000 0.150600 -0.105900 -0.768000 0.536000 -0.320000 +-0.350000 0.148000 -0.060900 -0.504000 0.552000 0.656000 +-0.346000 0.150600 -0.060900 -0.768000 -0.144000 0.616000 +-0.350000 0.100400 -0.017600 -0.744000 0.352000 0.552000 +-0.300000 0.150600 -0.036000 -0.360000 0.064000 0.920000 +-0.321000 0.100400 0.000000 -0.264000 0.416000 0.864000 +-0.300000 0.112500 0.000000 -0.064000 0.472000 0.872000 +-0.300000 0.100400 0.006400 -0.200000 0.408000 0.880000 +-0.250000 0.104200 0.000000 0.144000 0.480000 0.856000 +-0.250000 0.100400 0.002600 0.144000 0.496000 0.848000 +-0.238500 0.100400 0.000000 0.152000 0.496000 0.848000 +-0.250000 0.050200 0.048300 0.000000 0.552000 0.832000 +-0.200000 0.089800 0.000000 0.216000 0.544000 0.800000 +-0.200000 0.050200 0.037800 0.512000 0.448000 0.720000 +-0.163800 0.050200 0.000000 0.704000 0.216000 0.664000 +-0.200000 0.020500 0.060900 0.664000 0.440000 0.600000 +-0.150800 0.000000 0.000000 0.744000 0.072000 0.656000 +-0.190300 0.000000 0.060900 0.816000 0.200000 0.536000 +-0.152800 -0.050200 0.000000 0.848000 0.032000 0.520000 +-0.193200 -0.050200 0.060900 0.808000 0.008000 0.584000 +-0.150600 -0.100400 0.000000 0.800000 0.040000 0.592000 +-0.190200 -0.100400 0.060900 0.752000 -0.248000 0.600000 +-0.150000 -0.104300 0.000000 0.496000 0.120000 0.848000 +-0.200000 -0.121800 0.060900 0.728000 -0.328000 0.592000 +-0.150000 -0.150600 0.010200 0.376000 0.208000 0.896000 +-0.200000 -0.150600 0.042600 0.640000 -0.096000 0.752000 +-0.150000 -0.200800 0.013600 0.104000 0.200000 0.968000 +-0.200000 -0.200800 0.045500 0.568000 -0.152000 0.808000 +-0.150000 -0.251000 0.002400 -0.056000 -0.176000 0.976000 +-0.200000 -0.251000 0.018200 0.408000 -0.392000 0.816000 +-0.150000 -0.301200 0.010200 -0.304000 -0.280000 0.904000 +-0.200000 -0.279600 0.000000 -0.016000 -0.496000 0.864000 +-0.169100 -0.301200 0.000000 -0.376000 -0.392000 0.832000 +-0.200000 -0.301200 -0.017500 -0.064000 -0.432000 0.896000 +-0.150000 -0.346200 0.000000 -0.392000 -0.160000 0.904000 +-0.200000 -0.351500 -0.031500 -0.320000 -0.128000 0.936000 +-0.150000 -0.351500 -0.001100 -0.192000 -0.352000 0.912000 +-0.200000 -0.401700 -0.023400 -0.056000 -0.008000 0.992000 +-0.150000 -0.401700 -0.019000 0.408000 -0.232000 0.880000 +-0.200000 -0.451900 -0.018000 0.376000 -0.112000 0.912000 +-0.150000 -0.451900 -0.041900 0.560000 -0.440000 0.696000 +-0.200000 -0.502100 -0.039000 0.512000 -0.608000 0.592000 +-0.150000 -0.470000 -0.060900 0.568000 -0.552000 0.600000 +-0.181900 -0.502100 -0.060900 0.504000 -0.680000 0.520000 +-0.150000 -0.502100 -0.111600 0.592000 -0.752000 0.280000 +-0.200000 -0.511900 -0.060900 0.416000 -0.800000 0.424000 +-0.150000 -0.505100 -0.121900 0.584000 -0.768000 0.240000 +-0.200000 -0.534300 -0.121900 0.456000 -0.832000 0.296000 +-0.150000 -0.510100 -0.182900 0.616000 -0.760000 0.168000 +-0.200000 -0.549300 -0.182900 0.504000 -0.784000 0.344000 +-0.150000 -0.530700 -0.243900 0.632000 -0.664000 0.392000 +-0.200000 -0.552300 -0.190900 0.520000 -0.768000 0.360000 +-0.172800 -0.552300 -0.243900 0.592000 -0.568000 0.560000 +-0.200000 -0.579600 -0.243900 0.568000 -0.648000 0.496000 +-0.150000 -0.552300 -0.270100 0.544000 -0.504000 0.656000 +-0.200000 -0.602500 -0.268600 0.488000 -0.432000 0.752000 +-0.150000 -0.602500 -0.302600 0.392000 -0.240000 0.880000 +-0.200000 -0.652700 -0.286600 0.488000 -0.272000 0.824000 +-0.150000 -0.609400 -0.304800 0.840000 -0.512000 0.152000 +-0.171500 -0.652700 -0.304800 0.576000 -0.304000 0.752000 +-0.150000 -0.602500 -0.307600 0.456000 -0.280000 -0.840000 +-0.200000 -0.652700 -0.326500 0.488000 -0.272000 -0.824000 +-0.200000 -0.602500 -0.345500 0.488000 -0.272000 -0.824000 +-0.250000 -0.652700 -0.361600 0.240000 -0.216000 -0.944000 +-0.229500 -0.602500 -0.365800 0.408000 -0.240000 -0.872000 +-0.250000 -0.639500 -0.365800 0.216000 -0.224000 -0.944000 +-0.250000 -0.602500 -0.376000 0.360000 -0.328000 -0.872000 +-0.282800 -0.652700 -0.365800 0.080000 -0.160000 -0.976000 +-0.300000 -0.602500 -0.397300 -0.248000 -0.488000 -0.832000 +-0.300000 -0.652700 -0.367500 0.064000 -0.112000 -0.984000 +-0.328400 -0.602500 -0.365800 -0.832000 -0.248000 -0.488000 +-0.350000 -0.652700 -0.376000 0.560000 0.160000 -0.808000 +-0.350000 -0.629600 -0.365800 0.056000 0.640000 -0.760000 +-0.400000 -0.652700 -0.368100 -0.128000 -0.872000 -0.456000 +-0.357100 -0.602500 -0.365800 0.904000 0.256000 -0.312000 +-0.400000 -0.621700 -0.426800 0.392000 -0.856000 -0.304000 +-0.370300 -0.602500 -0.426800 0.624000 -0.760000 -0.160000 +-0.357100 -0.602500 -0.365800 0.904000 0.256000 -0.312000 +-0.350000 -0.582100 -0.426800 0.344000 -0.808000 -0.456000 +-0.350000 -0.585900 -0.365800 0.168000 -0.792000 -0.576000 +-0.300000 -0.582000 -0.426800 0.336000 -0.608000 -0.712000 +-0.328400 -0.602500 -0.365800 -0.832000 -0.248000 -0.488000 +-0.300000 -0.602500 -0.397300 -0.248000 -0.488000 -0.832000 +-0.300000 -0.582000 -0.426800 0.336000 -0.608000 -0.712000 +-0.250000 -0.602500 -0.376000 0.360000 -0.328000 -0.872000 +-0.275900 -0.552300 -0.426800 0.528000 -0.480000 -0.696000 +-0.250000 -0.552300 -0.402600 0.504000 -0.312000 -0.792000 +-0.250000 -0.526200 -0.426800 0.576000 -0.448000 -0.672000 +-0.200000 -0.552300 -0.367100 0.360000 -0.232000 -0.896000 +-0.235700 -0.502100 -0.426800 0.696000 -0.464000 -0.536000 +-0.200000 -0.502100 -0.370700 0.184000 -0.352000 -0.912000 +-0.200000 -0.459900 -0.426800 0.560000 -0.592000 -0.576000 +-0.150000 -0.502100 -0.367300 0.088000 -0.320000 -0.936000 +-0.191200 -0.451900 -0.426800 0.664000 -0.480000 -0.560000 +-0.150000 -0.451900 -0.368100 0.456000 -0.056000 -0.880000 +-0.194300 -0.401700 -0.426800 0.792000 0.416000 -0.432000 +-0.150000 -0.417500 -0.365800 0.544000 0.056000 -0.832000 +-0.151700 -0.401700 -0.365800 0.568000 0.104000 -0.808000 +-0.150000 -0.401700 -0.364300 0.552000 0.080000 -0.824000 +-0.200000 -0.365300 -0.365800 0.504000 0.768000 -0.376000 +-0.150000 -0.351500 -0.350300 0.512000 0.192000 -0.832000 +-0.200000 -0.351500 -0.343300 0.312000 0.640000 -0.696000 +-0.150000 -0.301200 -0.318500 -0.024000 0.504000 -0.856000 +-0.200000 -0.301200 -0.313400 0.328000 0.152000 -0.928000 +-0.150000 -0.286300 -0.304800 -0.184000 0.480000 -0.848000 +-0.200000 -0.251000 -0.307600 0.408000 0.096000 -0.904000 +-0.195100 -0.251000 -0.304800 0.376000 0.112000 -0.912000 +-0.200000 -0.200800 -0.306700 0.368000 -0.184000 -0.904000 +-0.196100 -0.200800 -0.304800 0.360000 -0.200000 -0.904000 +-0.200000 -0.150600 -0.333300 0.216000 -0.272000 -0.936000 +-0.150000 -0.159100 -0.304800 0.152000 -0.400000 -0.896000 +-0.150000 -0.150600 -0.309500 -0.032000 -0.400000 -0.912000 +-0.108400 -0.200800 -0.304800 -0.496000 -0.048000 -0.856000 +-0.100000 -0.150600 -0.315000 -0.456000 -0.064000 -0.880000 +-0.100000 -0.200800 -0.311700 -0.496000 0.128000 -0.856000 +-0.050000 -0.150600 -0.332400 0.016000 -0.080000 -0.992000 +-0.050000 -0.200800 -0.320900 -0.056000 0.280000 -0.952000 +0.000000 -0.150600 -0.318000 0.160000 0.016000 -0.984000 +0.000000 -0.200800 -0.332000 -0.296000 0.528000 -0.784000 +0.050000 -0.150600 -0.318000 0.352000 0.312000 -0.872000 +0.050000 -0.200800 -0.360800 -0.016000 0.576000 -0.808000 +0.096000 -0.150600 -0.304800 0.176000 0.336000 -0.920000 +0.100000 -0.200800 -0.352600 0.240000 0.528000 -0.800000 +0.100000 -0.151600 -0.304800 -0.176000 0.536000 -0.816000 +0.150000 -0.200800 -0.325200 0.160000 0.176000 -0.968000 +0.101900 -0.150600 -0.304800 -0.296000 0.368000 -0.872000 +0.150000 -0.150600 -0.323600 -0.232000 0.464000 -0.848000 +0.114400 -0.100400 -0.304800 -0.344000 0.128000 -0.928000 +0.150000 -0.100400 -0.322200 0.000000 0.224000 -0.968000 +0.150000 -0.064700 -0.304800 -0.200000 0.328000 -0.912000 +0.185500 -0.100400 -0.304800 0.296000 0.104000 -0.944000 +0.150000 -0.050200 -0.298400 -0.176000 0.328000 -0.920000 +0.200000 -0.100400 -0.298900 0.088000 0.040000 -0.992000 +0.188500 -0.050200 -0.304800 -0.128000 0.184000 -0.968000 +0.200000 -0.061600 -0.304800 0.000000 -0.144000 -0.984000 +0.200000 -0.050200 -0.307000 0.000000 0.192000 -0.976000 +0.211400 -0.050200 -0.304800 0.152000 0.184000 -0.968000 +0.200000 -0.045300 -0.304800 -0.008000 0.344000 -0.936000 +0.250000 -0.050200 -0.297000 0.000000 0.040000 -0.992000 +0.200000 0.000000 -0.277300 0.080000 0.528000 -0.840000 +0.250000 0.000000 -0.271900 -0.336000 0.528000 -0.776000 +0.200000 0.025700 -0.243900 0.016000 0.752000 -0.648000 +0.250000 0.018500 -0.243900 -0.144000 0.856000 -0.480000 +0.200000 0.019700 -0.182900 0.160000 0.648000 0.736000 +0.250000 0.002800 -0.182900 0.128000 0.640000 0.752000 +0.200000 0.000000 -0.161400 0.032000 0.656000 0.752000 +0.250000 0.000000 -0.180400 0.176000 0.568000 0.792000 +0.200000 -0.041200 -0.121900 0.160000 0.488000 0.856000 +0.250000 -0.050200 -0.132500 0.192000 0.528000 0.816000 +0.222300 -0.050200 -0.121900 0.200000 0.432000 0.872000 +0.250000 -0.068700 -0.121900 0.096000 0.400000 0.904000 +0.200000 -0.050200 -0.116900 0.136000 0.368000 0.912000 +0.250000 -0.100400 -0.106800 0.080000 0.336000 0.936000 +0.200000 -0.100400 -0.095800 0.064000 0.272000 0.952000 +0.250000 -0.150600 -0.087200 0.040000 0.104000 0.992000 +0.200000 -0.150600 -0.099300 0.040000 0.104000 0.992000 +0.250000 -0.200800 -0.084100 0.120000 -0.168000 0.976000 +0.200000 -0.200800 -0.086600 0.112000 -0.336000 0.928000 +0.250000 -0.237200 -0.121900 0.048000 -0.656000 0.744000 +0.200000 -0.240500 -0.121900 0.152000 -0.656000 0.728000 +0.250000 -0.251000 -0.140300 -0.072000 -0.512000 0.848000 +0.200000 -0.251000 -0.134700 0.128000 -0.784000 0.600000 +0.250000 -0.301200 -0.149400 -0.376000 -0.584000 0.712000 +0.200000 -0.290700 -0.182900 -0.520000 -0.680000 0.512000 +0.211500 -0.301200 -0.182900 -0.568000 -0.672000 0.464000 +0.200000 -0.301200 -0.206400 -0.600000 -0.688000 0.384000 +0.250000 -0.319600 -0.182900 -0.280000 -0.832000 0.472000 +0.200000 -0.319700 -0.243900 -0.624000 -0.696000 0.328000 +0.250000 -0.343100 -0.243900 -0.320000 -0.920000 0.208000 +0.200000 -0.340400 -0.304800 -0.480000 -0.448000 -0.744000 +0.250000 -0.348300 -0.304800 -0.128000 -0.736000 -0.656000 +0.200000 -0.301200 -0.321600 -0.488000 -0.368000 -0.784000 +0.250000 -0.313600 -0.365800 -0.336000 -0.640000 -0.680000 +0.236200 -0.301200 -0.365800 -0.608000 -0.320000 -0.712000 +0.250000 -0.301200 -0.379400 -0.536000 -0.264000 -0.792000 +0.250000 -0.271800 -0.365800 -0.320000 0.360000 -0.872000 +0.300000 -0.301200 -0.372900 0.128000 -0.472000 -0.864000 +0.300000 -0.284400 -0.365800 0.136000 0.360000 -0.920000 +0.333500 -0.301200 -0.365800 0.208000 -0.080000 -0.968000 +0.300000 -0.251000 -0.347800 0.304000 0.384000 -0.864000 +0.350000 -0.301200 -0.360500 0.376000 0.184000 -0.904000 +0.350000 -0.251000 -0.329500 0.536000 0.472000 -0.688000 +0.400000 -0.301200 -0.307300 0.704000 0.496000 -0.496000 +0.366700 -0.251000 -0.304800 0.704000 0.488000 -0.496000 +0.400000 -0.299100 -0.304800 0.736000 0.472000 -0.472000 +0.399000 -0.251000 -0.243900 0.912000 -0.008000 -0.392000 +0.400000 -0.252300 -0.243900 0.744000 0.488000 -0.440000 +0.398900 -0.251000 -0.182900 0.896000 -0.160000 0.400000 +0.400000 -0.252800 -0.182900 0.760000 0.464000 0.440000 +0.354900 -0.251000 -0.121900 0.704000 -0.304000 0.632000 +0.400000 -0.301200 -0.149800 0.528000 0.376000 0.752000 +0.350000 -0.260400 -0.121900 0.448000 -0.472000 0.752000 +0.350000 -0.301200 -0.148100 0.392000 -0.048000 0.912000 +0.328900 -0.251000 -0.121900 -0.264000 -0.304000 0.912000 +0.300000 -0.301200 -0.149800 -0.024000 -0.480000 0.872000 +0.300000 -0.251000 -0.132800 -0.224000 -0.464000 0.856000 +0.250000 -0.301200 -0.149400 -0.376000 -0.584000 0.712000 +0.250000 -0.251000 -0.140300 -0.072000 -0.512000 0.848000 +0.300000 -0.251000 -0.132800 -0.224000 -0.464000 0.856000 +0.250000 -0.237200 -0.121900 0.048000 -0.656000 0.744000 +0.300000 -0.234400 -0.121900 0.104000 -0.472000 0.872000 +0.250000 -0.200800 -0.084100 0.120000 -0.168000 0.976000 +0.300000 -0.200800 -0.101500 0.424000 -0.216000 0.872000 +0.250000 -0.150600 -0.087200 0.040000 0.104000 0.992000 +0.300000 -0.150600 -0.090800 0.240000 -0.024000 0.968000 +0.250000 -0.100400 -0.106800 0.080000 0.336000 0.936000 +0.300000 -0.100400 -0.098900 -0.360000 0.344000 0.856000 +0.250000 -0.068700 -0.121900 0.096000 0.400000 0.904000 +0.300000 -0.060700 -0.121900 -0.512000 0.456000 0.720000 +0.250000 -0.050200 -0.132500 0.192000 0.528000 0.816000 +0.300000 -0.050200 -0.130700 -0.504000 0.472000 0.720000 +0.250000 0.000000 -0.180400 0.176000 0.568000 0.792000 +0.300000 0.000000 -0.166100 -0.488000 0.464000 0.728000 +0.250000 0.002800 -0.182900 0.128000 0.640000 0.752000 +0.300000 0.018000 -0.182900 -0.296000 0.768000 0.552000 +0.250000 0.018500 -0.243900 -0.144000 0.856000 -0.480000 +0.300000 0.032100 -0.243900 -0.576000 0.680000 -0.432000 +0.250000 0.000000 -0.271900 -0.336000 0.528000 -0.776000 +0.300000 0.000000 -0.302400 -0.544000 0.608000 -0.568000 +0.250000 -0.050200 -0.297000 0.000000 0.040000 -0.992000 +0.300000 -0.003100 -0.304800 -0.376000 0.424000 -0.816000 +0.266500 -0.050200 -0.304800 -0.280000 0.064000 -0.952000 +0.300000 -0.050200 -0.319900 -0.536000 0.224000 -0.808000 +0.278900 -0.100400 -0.304800 -0.176000 0.256000 -0.944000 +0.300000 -0.100400 -0.310000 -0.248000 0.072000 -0.960000 +0.250000 -0.114900 -0.304800 -0.104000 0.280000 -0.952000 +0.300000 -0.150600 -0.312600 0.312000 -0.200000 -0.920000 +0.250000 -0.150600 -0.317700 0.024000 0.336000 -0.936000 +0.300000 -0.200800 -0.324200 0.480000 0.248000 -0.832000 +0.250000 -0.200800 -0.343100 0.104000 0.232000 -0.960000 +0.300000 -0.251000 -0.347800 0.304000 0.384000 -0.864000 +0.250000 -0.251000 -0.353900 0.064000 0.384000 -0.920000 +0.300000 -0.284400 -0.365800 0.136000 0.360000 -0.920000 +0.250000 -0.271800 -0.365800 -0.320000 0.360000 -0.872000 +0.250000 -0.251000 -0.353900 0.064000 0.384000 -0.920000 +0.236200 -0.301200 -0.365800 -0.608000 -0.320000 -0.712000 +0.200000 -0.251000 -0.346500 -0.184000 0.088000 -0.976000 +0.200000 -0.301200 -0.321600 -0.488000 -0.368000 -0.784000 +0.150000 -0.251000 -0.336000 0.080000 -0.336000 -0.928000 +0.170700 -0.301200 -0.304800 -0.520000 -0.608000 -0.592000 +0.150000 -0.287400 -0.304800 0.000000 -0.712000 -0.688000 +0.176900 -0.301200 -0.243900 -0.504000 -0.800000 0.304000 +0.150000 -0.287700 -0.243900 -0.208000 -0.968000 0.064000 +0.200000 -0.301200 -0.206400 -0.600000 -0.688000 0.384000 +0.150000 -0.278000 -0.182900 -0.064000 -0.936000 0.328000 +0.200000 -0.290700 -0.182900 -0.520000 -0.680000 0.512000 +0.150000 -0.253200 -0.121900 0.192000 -0.808000 0.552000 +0.200000 -0.251000 -0.134700 0.128000 -0.784000 0.600000 +0.161400 -0.251000 -0.121900 0.152000 -0.792000 0.576000 +0.200000 -0.240500 -0.121900 0.152000 -0.656000 0.728000 +0.150000 -0.251000 -0.118100 0.224000 -0.792000 0.560000 +0.200000 -0.200800 -0.086600 0.112000 -0.336000 0.928000 +0.150000 -0.200800 -0.071800 0.312000 -0.208000 0.920000 +0.200000 -0.150600 -0.099300 0.040000 0.104000 0.992000 +0.150000 -0.150600 -0.071000 0.136000 0.176000 0.968000 +0.200000 -0.100400 -0.095800 0.064000 0.272000 0.952000 +0.150000 -0.100400 -0.080500 0.184000 0.336000 0.920000 +0.200000 -0.050200 -0.116900 0.136000 0.368000 0.912000 +0.150000 -0.050200 -0.113700 0.032000 0.448000 0.888000 +0.200000 -0.041200 -0.121900 0.160000 0.488000 0.856000 +0.150000 -0.036300 -0.121900 0.008000 0.488000 0.864000 +0.200000 0.000000 -0.161400 0.032000 0.656000 0.752000 +0.150000 0.000000 -0.166100 -0.096000 0.688000 0.712000 +0.200000 0.019700 -0.182900 0.160000 0.648000 0.736000 +0.150000 0.016800 -0.182900 -0.152000 0.840000 0.520000 +0.200000 0.025700 -0.243900 0.016000 0.752000 -0.648000 +0.150000 0.015400 -0.243900 -0.208000 0.728000 -0.640000 +0.200000 0.000000 -0.277300 0.080000 0.528000 -0.840000 +0.150000 0.000000 -0.257100 -0.208000 0.552000 -0.800000 +0.200000 -0.045300 -0.304800 -0.008000 0.344000 -0.936000 +0.150000 -0.050200 -0.298400 -0.176000 0.328000 -0.920000 +0.188500 -0.050200 -0.304800 -0.128000 0.184000 -0.968000 +0.200000 -0.045300 -0.304800 -0.008000 0.344000 -0.936000 +0.200000 -0.050200 -0.307000 0.000000 0.192000 -0.976000 +0.200000 -0.050200 -0.307000 0.000000 0.192000 -0.976000 +-0.800000 -0.100400 0.186900 0.104000 0.048000 0.992000 +-0.800000 -0.100400 0.186900 0.104000 0.048000 0.992000 +-0.776900 -0.100400 0.182900 0.184000 0.120000 0.968000 +-0.800000 -0.150600 0.189500 -0.240000 -0.056000 0.960000 +-0.750000 -0.136500 0.182900 0.216000 0.112000 0.968000 +-0.750000 -0.150600 0.184600 0.192000 0.080000 0.976000 +-0.743500 -0.150600 0.182900 0.192000 0.096000 0.968000 +-0.750000 -0.200800 0.187200 0.064000 -0.048000 0.992000 +-0.703900 -0.200800 0.182900 0.128000 0.064000 0.984000 +-0.750000 -0.251000 0.186100 -0.160000 -0.136000 0.976000 +-0.700000 -0.208700 0.182900 0.176000 0.120000 0.968000 +-0.700000 -0.251000 0.184700 0.008000 -0.024000 0.992000 +-0.650000 -0.249200 0.182900 0.176000 0.464000 0.864000 +-0.650000 -0.251000 0.183700 0.152000 0.272000 0.944000 +-0.638500 -0.251000 0.182900 0.072000 0.424000 0.896000 +-0.650000 -0.301200 0.185200 -0.152000 0.008000 0.984000 +-0.600000 -0.260000 0.182900 0.056000 0.320000 0.944000 +-0.600000 -0.301200 0.196400 -0.152000 0.176000 0.968000 +-0.550000 -0.264400 0.182900 -0.072000 0.456000 0.880000 +-0.550000 -0.301200 0.200100 -0.040000 0.312000 0.944000 +-0.512000 -0.251000 0.182900 -0.112000 0.632000 0.760000 +-0.500000 -0.301200 0.199600 -0.128000 0.216000 0.960000 +-0.500000 -0.251000 0.185100 -0.112000 0.632000 0.760000 +-0.450000 -0.301200 0.203900 0.032000 0.168000 0.984000 +-0.450000 -0.251000 0.195400 -0.152000 0.392000 0.904000 +-0.400000 -0.301200 0.211000 0.416000 0.000000 0.904000 +-0.400000 -0.251000 0.203200 0.024000 0.208000 0.976000 +-0.369700 -0.301200 0.182900 0.552000 -0.328000 0.752000 +-0.350000 -0.251000 0.206900 0.584000 -0.272000 0.760000 +-0.350000 -0.276800 0.182900 0.600000 -0.432000 0.664000 +-0.334800 -0.251000 0.182900 0.672000 -0.480000 0.552000 +-0.350000 -0.301200 0.167500 0.592000 -0.368000 0.712000 +-0.300000 -0.251000 0.131000 0.632000 -0.616000 0.464000 +-0.327200 -0.301200 0.121900 0.792000 -0.368000 0.472000 +-0.300000 -0.256400 0.121900 0.624000 -0.624000 0.456000 +-0.300000 -0.301200 0.065200 0.504000 -0.568000 0.640000 +-0.294600 -0.251000 0.121900 0.616000 -0.600000 0.488000 +-0.295000 -0.301200 0.060900 0.472000 -0.584000 0.648000 +-0.250000 -0.251000 0.071500 0.528000 -0.408000 0.736000 +-0.250000 -0.262800 0.060900 0.496000 -0.520000 0.688000 +-0.236900 -0.251000 0.060900 0.464000 -0.480000 0.728000 +-0.250000 -0.301200 0.006000 0.344000 -0.608000 0.704000 +-0.200000 -0.251000 0.018200 0.408000 -0.392000 0.816000 +-0.235900 -0.301200 0.000000 0.272000 -0.568000 0.768000 +-0.200000 -0.279600 0.000000 -0.016000 -0.496000 0.864000 +-0.200000 -0.301200 -0.017500 -0.064000 -0.432000 0.896000 +-0.235900 -0.301200 0.000000 0.272000 -0.568000 0.768000 +-0.200000 -0.351500 -0.031500 -0.320000 -0.128000 0.936000 +-0.250000 -0.307700 0.000000 0.288000 -0.576000 0.760000 +-0.250000 -0.351500 -0.038300 0.104000 -0.504000 0.848000 +-0.300000 -0.343500 0.000000 0.832000 -0.408000 0.360000 +-0.300000 -0.351500 -0.012600 0.872000 -0.352000 0.320000 +-0.303300 -0.351500 0.000000 0.888000 -0.344000 0.288000 +-0.300000 -0.401700 -0.045100 0.792000 -0.248000 0.544000 +-0.319500 -0.401700 0.000000 0.536000 -0.584000 0.592000 +-0.300000 -0.435300 -0.060900 -0.192000 -0.360000 0.912000 +-0.350000 -0.427600 0.000000 0.560000 -0.752000 0.336000 +-0.338500 -0.451900 -0.060900 0.112000 -0.632000 0.760000 +-0.350000 -0.451900 -0.058800 0.248000 -0.624000 0.728000 +-0.350000 -0.453900 -0.060900 0.248000 -0.624000 0.728000 +-0.400000 -0.451900 -0.009600 0.744000 -0.536000 0.376000 +-0.380200 -0.502100 -0.060900 0.648000 -0.616000 0.432000 +-0.400000 -0.502100 -0.024700 0.848000 -0.224000 0.464000 +-0.400000 -0.527700 -0.060900 0.080000 -0.768000 0.624000 +-0.450000 -0.502100 -0.045100 0.560000 -0.696000 0.432000 +-0.450000 -0.512800 -0.060900 0.208000 -0.760000 0.608000 +-0.466200 -0.502100 0.000000 0.712000 -0.616000 0.320000 +-0.478800 -0.552300 -0.060900 0.704000 -0.592000 0.376000 +-0.500000 -0.548400 0.000000 0.368000 -0.816000 0.432000 +-0.500000 -0.552300 -0.009400 0.352000 -0.840000 0.400000 +-0.509600 -0.552300 0.000000 0.320000 -0.840000 0.424000 +-0.500000 -0.570000 -0.060900 0.480000 -0.800000 0.328000 +-0.550000 -0.565800 0.000000 0.224000 -0.872000 0.424000 +-0.550000 -0.588500 -0.060900 0.224000 -0.888000 0.384000 +-0.600000 -0.566300 0.000000 -0.184000 -0.816000 0.544000 +-0.600000 -0.601900 -0.060900 -0.072000 -0.808000 0.568000 +-0.633400 -0.552300 0.000000 -0.384000 -0.672000 0.624000 +-0.650000 -0.594800 -0.060900 -0.368000 -0.640000 0.664000 +-0.650000 -0.552300 -0.012600 -0.496000 -0.592000 0.624000 +-0.685200 -0.552300 -0.060900 -0.696000 -0.384000 0.592000 +-0.650000 -0.541900 0.000000 -0.528000 -0.600000 0.592000 +-0.700000 -0.507800 -0.060900 -0.864000 -0.200000 0.448000 +-0.674300 -0.502100 0.000000 -0.656000 -0.632000 0.384000 +-0.700000 -0.502100 -0.057900 -0.752000 -0.512000 0.400000 +-0.700000 -0.478200 0.000000 -0.704000 -0.632000 0.312000 +-0.701200 -0.502100 -0.060900 -0.816000 -0.416000 0.392000 +-0.719800 -0.451900 0.000000 -0.816000 -0.520000 0.240000 +-0.735400 -0.451900 -0.060900 -0.768000 -0.512000 0.360000 +-0.750000 -0.403200 0.000000 -0.832000 -0.504000 0.216000 +-0.750000 -0.426100 -0.060900 -0.864000 -0.448000 0.200000 +-0.750800 -0.401700 0.000000 -0.816000 -0.520000 0.208000 +-0.762700 -0.401700 -0.060900 -0.840000 -0.496000 0.168000 +-0.782800 -0.351500 0.000000 -0.816000 -0.536000 0.208000 +-0.794800 -0.351500 -0.060900 -0.816000 -0.552000 0.144000 +-0.800000 -0.327900 0.000000 -0.800000 -0.560000 0.176000 +-0.800000 -0.343900 -0.060900 -0.816000 -0.552000 0.128000 +-0.817700 -0.301200 0.000000 -0.808000 -0.560000 0.168000 +-0.826600 -0.301200 -0.060900 -0.824000 -0.544000 0.120000 +-0.800000 -0.343900 -0.060900 -0.816000 -0.552000 0.128000 +-0.832400 -0.301200 -0.121900 -0.840000 -0.528000 0.048000 +-0.800000 -0.351500 -0.101400 -0.840000 -0.528000 0.104000 +-0.802000 -0.351500 -0.121900 -0.840000 -0.520000 0.096000 +-0.800000 -0.354700 -0.121900 -0.848000 -0.512000 0.080000 +-0.802200 -0.351500 -0.182900 -0.872000 -0.480000 0.016000 +-0.800000 -0.355500 -0.182900 -0.872000 -0.472000 0.032000 +-0.807300 -0.351500 -0.243900 -0.864000 -0.472000 0.152000 +-0.800000 -0.365300 -0.243900 -0.880000 -0.440000 0.160000 +-0.821000 -0.351500 -0.304800 -0.824000 -0.504000 0.232000 +-0.800000 -0.395700 -0.304800 -0.920000 -0.376000 0.000000 +-0.812200 -0.351500 -0.365800 -0.856000 -0.296000 -0.408000 +-0.800000 -0.388500 -0.365800 -0.864000 -0.288000 -0.400000 +-0.800000 -0.351500 -0.388300 -0.664000 -0.152000 -0.728000 +-0.796500 -0.401700 -0.365800 -0.952000 -0.168000 -0.232000 +-0.750000 -0.351500 -0.422100 -0.312000 0.448000 -0.824000 +-0.777800 -0.401700 -0.426800 -0.928000 0.040000 -0.360000 +-0.750000 -0.359700 -0.426800 -0.368000 0.408000 -0.832000 +-0.750000 -0.351500 -0.422100 -0.312000 0.448000 -0.824000 +-0.736800 -0.351500 -0.426800 -0.240000 0.480000 -0.832000 +-0.736800 -0.351500 -0.426800 -0.240000 0.480000 -0.832000 +-0.750000 -0.150600 0.184600 0.192000 0.080000 0.976000 +-0.750000 -0.150600 0.184600 0.192000 0.080000 0.976000 +-0.800000 -0.150600 0.189500 -0.240000 -0.056000 0.960000 +-0.750000 -0.200800 0.187200 0.064000 -0.048000 0.992000 +-0.800000 -0.200800 0.184500 -0.256000 -0.128000 0.952000 +-0.750000 -0.251000 0.186100 -0.160000 -0.136000 0.976000 +-0.800000 -0.206500 0.182900 -0.304000 -0.264000 0.912000 +-0.762000 -0.251000 0.182900 -0.256000 -0.192000 0.936000 +-0.800000 -0.251000 0.157900 -0.576000 -0.400000 0.696000 +-0.750000 -0.267900 0.182900 -0.232000 -0.192000 0.944000 +-0.800000 -0.280700 0.121900 -0.736000 -0.528000 0.408000 +-0.750000 -0.301200 0.168400 -0.360000 -0.432000 0.816000 +-0.783300 -0.301200 0.121900 -0.688000 -0.568000 0.440000 +-0.750000 -0.342500 0.121900 -0.536000 -0.592000 0.592000 +-0.800000 -0.301200 0.085900 -0.768000 -0.544000 0.304000 +-0.750000 -0.351500 0.110100 -0.600000 -0.584000 0.536000 +-0.800000 -0.310100 0.060900 -0.800000 -0.544000 0.224000 +-0.767900 -0.351500 0.060900 -0.760000 -0.568000 0.296000 +-0.800000 -0.327900 0.000000 -0.800000 -0.560000 0.176000 +-0.782800 -0.351500 0.000000 -0.816000 -0.536000 0.208000 +-0.767900 -0.351500 0.060900 -0.760000 -0.568000 0.296000 +-0.750800 -0.401700 0.000000 -0.816000 -0.520000 0.208000 +-0.750000 -0.377100 0.060900 -0.760000 -0.552000 0.320000 +-0.750000 -0.401700 0.004100 -0.816000 -0.520000 0.232000 +-0.731300 -0.401700 0.060900 -0.784000 -0.496000 0.344000 +-0.750000 -0.403200 0.000000 -0.832000 -0.504000 0.216000 +-0.701000 -0.451900 0.060900 -0.792000 -0.480000 0.344000 +-0.719800 -0.451900 0.000000 -0.816000 -0.520000 0.240000 +-0.700000 -0.453200 0.060900 -0.560000 -0.720000 0.392000 +-0.700000 -0.478200 0.000000 -0.704000 -0.632000 0.312000 +-0.650000 -0.495900 0.060900 -0.528000 -0.720000 0.432000 +-0.674300 -0.502100 0.000000 -0.656000 -0.632000 0.384000 +-0.650000 -0.502100 0.048300 -0.536000 -0.712000 0.440000 +-0.650000 -0.541900 0.000000 -0.528000 -0.600000 0.592000 +-0.640700 -0.502100 0.060900 -0.496000 -0.728000 0.456000 +-0.633400 -0.552300 0.000000 -0.384000 -0.672000 0.624000 +-0.600000 -0.531600 0.060900 -0.448000 -0.736000 0.496000 +-0.600000 -0.552300 0.023900 -0.224000 -0.776000 0.584000 +-0.550000 -0.532000 0.060900 0.080000 -0.776000 0.624000 +-0.550000 -0.552300 0.031000 0.256000 -0.800000 0.528000 +-0.500000 -0.517700 0.060900 0.632000 -0.632000 0.440000 +-0.509600 -0.552300 0.000000 0.320000 -0.840000 0.424000 +-0.500000 -0.548400 0.000000 0.368000 -0.816000 0.432000 +-0.500000 -0.517700 0.060900 0.632000 -0.632000 0.440000 +-0.466200 -0.502100 0.000000 0.712000 -0.616000 0.320000 +-0.489100 -0.502100 0.060900 0.704000 -0.616000 0.328000 +-0.450000 -0.489500 0.000000 0.584000 -0.760000 0.264000 +-0.450000 -0.471900 0.060900 0.592000 -0.752000 0.272000 +-0.403800 -0.451900 0.000000 0.744000 -0.560000 0.352000 +-0.425300 -0.451900 0.060900 0.696000 -0.640000 0.304000 +-0.400000 -0.447100 0.000000 0.720000 -0.584000 0.344000 +-0.400000 -0.423000 0.060900 0.616000 -0.696000 0.360000 +-0.350000 -0.427600 0.000000 0.560000 -0.752000 0.336000 +-0.350000 -0.406300 0.060900 0.592000 -0.728000 0.320000 +-0.319500 -0.401700 0.000000 0.536000 -0.584000 0.592000 +-0.344500 -0.401700 0.060900 0.632000 -0.688000 0.328000 +-0.303300 -0.351500 0.000000 0.888000 -0.344000 0.288000 +-0.319700 -0.351500 0.060900 0.864000 -0.376000 0.328000 +-0.300000 -0.343500 0.000000 0.832000 -0.408000 0.360000 +-0.300000 -0.305300 0.060900 0.512000 -0.568000 0.632000 +-0.250000 -0.307700 0.000000 0.288000 -0.576000 0.760000 +-0.295000 -0.301200 0.060900 0.472000 -0.584000 0.648000 +-0.250000 -0.301200 0.006000 0.344000 -0.608000 0.704000 +-0.250000 -0.262800 0.060900 0.496000 -0.520000 0.688000 +-0.250000 -0.262800 0.060900 0.496000 -0.520000 0.688000 +-0.762000 -0.251000 0.182900 -0.256000 -0.192000 0.936000 +-0.762000 -0.251000 0.182900 -0.256000 -0.192000 0.936000 +-0.750000 -0.251000 0.186100 -0.160000 -0.136000 0.976000 +-0.750000 -0.267900 0.182900 -0.232000 -0.192000 0.944000 +-0.700000 -0.251000 0.184700 0.008000 -0.024000 0.992000 +-0.700000 -0.272200 0.182900 -0.072000 -0.128000 0.984000 +-0.650000 -0.251000 0.183700 0.152000 0.272000 0.944000 +-0.671000 -0.301200 0.182900 -0.120000 -0.104000 0.984000 +-0.650000 -0.301200 0.185200 -0.152000 0.008000 0.984000 +-0.663400 -0.351500 0.182900 -0.304000 -0.080000 0.944000 +-0.650000 -0.351500 0.187800 -0.272000 -0.048000 0.952000 +-0.650000 -0.385200 0.182900 -0.496000 -0.152000 0.848000 +-0.600000 -0.351500 0.201700 -0.216000 0.016000 0.968000 +-0.644900 -0.401700 0.182900 -0.528000 -0.240000 0.808000 +-0.600000 -0.401700 0.205900 -0.320000 -0.144000 0.928000 +-0.600000 -0.446800 0.182900 -0.240000 -0.464000 0.848000 +-0.550000 -0.401700 0.218500 0.000000 -0.272000 0.960000 +-0.583500 -0.451900 0.182900 -0.128000 -0.544000 0.824000 +-0.550000 -0.451900 0.188900 -0.024000 -0.624000 0.776000 +-0.550000 -0.456500 0.182900 0.056000 -0.736000 0.672000 +-0.523100 -0.451900 0.182900 0.136000 -0.648000 0.744000 +-0.550000 -0.494000 0.121900 0.024000 -0.832000 0.536000 +-0.500000 -0.451900 0.177400 0.160000 -0.648000 0.736000 +-0.500000 -0.486900 0.121900 0.296000 -0.800000 0.504000 +-0.450000 -0.451900 0.126400 0.752000 -0.472000 0.448000 +-0.450000 -0.453600 0.121900 0.584000 -0.744000 0.288000 +-0.447800 -0.451900 0.121900 0.672000 -0.648000 0.344000 +-0.450000 -0.471900 0.060900 0.592000 -0.752000 0.272000 +-0.425300 -0.451900 0.060900 0.696000 -0.640000 0.304000 +-0.447800 -0.451900 0.121900 0.672000 -0.648000 0.344000 +-0.400000 -0.423000 0.060900 0.616000 -0.696000 0.360000 +-0.404400 -0.401700 0.121900 0.648000 -0.656000 0.368000 +-0.400000 -0.401700 0.111300 0.640000 -0.680000 0.336000 +-0.400000 -0.397400 0.121900 0.632000 -0.672000 0.368000 +-0.350000 -0.401700 0.073400 0.632000 -0.688000 0.344000 +-0.350000 -0.369000 0.121900 0.736000 -0.464000 0.480000 +-0.344500 -0.401700 0.060900 0.632000 -0.688000 0.328000 +-0.341600 -0.351500 0.121900 0.808000 -0.352000 0.456000 +-0.319700 -0.351500 0.060900 0.864000 -0.376000 0.328000 +-0.327200 -0.301200 0.121900 0.792000 -0.368000 0.472000 +-0.300000 -0.305300 0.060900 0.512000 -0.568000 0.632000 +-0.300000 -0.301200 0.065200 0.504000 -0.568000 0.640000 +-0.295000 -0.301200 0.060900 0.472000 -0.584000 0.648000 +-0.295000 -0.301200 0.060900 0.472000 -0.584000 0.648000 +-0.650000 -0.301200 0.185200 -0.152000 0.008000 0.984000 +-0.650000 -0.301200 0.185200 -0.152000 0.008000 0.984000 +-0.650000 -0.351500 0.187800 -0.272000 -0.048000 0.952000 +-0.600000 -0.301200 0.196400 -0.152000 0.176000 0.968000 +-0.600000 -0.351500 0.201700 -0.216000 0.016000 0.968000 +-0.550000 -0.301200 0.200100 -0.040000 0.312000 0.944000 +-0.550000 -0.351500 0.211500 0.000000 0.128000 0.984000 +-0.500000 -0.301200 0.199600 -0.128000 0.216000 0.960000 +-0.500000 -0.351500 0.209200 0.072000 0.104000 0.984000 +-0.450000 -0.301200 0.203900 0.032000 0.168000 0.984000 +-0.450000 -0.351500 0.215900 0.592000 -0.216000 0.768000 +-0.400000 -0.301200 0.211000 0.416000 0.000000 0.904000 +-0.400000 -0.351500 0.196700 0.560000 -0.576000 0.584000 +-0.369700 -0.301200 0.182900 0.552000 -0.328000 0.752000 +-0.389000 -0.351500 0.182900 0.544000 -0.632000 0.536000 +-0.350000 -0.301200 0.167500 0.592000 -0.368000 0.712000 +-0.350000 -0.351500 0.138600 0.680000 -0.440000 0.568000 +-0.327200 -0.301200 0.121900 0.792000 -0.368000 0.472000 +-0.341600 -0.351500 0.121900 0.808000 -0.352000 0.456000 +-0.350000 -0.351500 0.138600 0.680000 -0.440000 0.568000 +-0.350000 -0.369000 0.121900 0.736000 -0.464000 0.480000 +-0.389000 -0.351500 0.182900 0.544000 -0.632000 0.536000 +-0.400000 -0.397400 0.121900 0.632000 -0.672000 0.368000 +-0.400000 -0.359600 0.182900 0.520000 -0.680000 0.496000 +-0.404400 -0.401700 0.121900 0.648000 -0.656000 0.368000 +-0.445800 -0.401700 0.182900 0.648000 -0.488000 0.568000 +-0.447800 -0.451900 0.121900 0.672000 -0.648000 0.344000 +-0.450000 -0.407300 0.182900 0.664000 -0.488000 0.552000 +-0.450000 -0.451900 0.126400 0.752000 -0.472000 0.448000 +-0.500000 -0.444100 0.182900 0.168000 -0.480000 0.848000 +-0.500000 -0.451900 0.177400 0.160000 -0.648000 0.736000 +-0.523100 -0.451900 0.182900 0.136000 -0.648000 0.744000 +-0.500000 -0.444100 0.182900 0.168000 -0.480000 0.848000 +-0.550000 -0.451900 0.188900 -0.024000 -0.624000 0.776000 +-0.500000 -0.401700 0.210500 0.208000 -0.296000 0.928000 +-0.550000 -0.401700 0.218500 0.000000 -0.272000 0.960000 +-0.500000 -0.351500 0.209200 0.072000 0.104000 0.984000 +-0.550000 -0.351500 0.211500 0.000000 0.128000 0.984000 +-0.550000 -0.401700 0.218500 0.000000 -0.272000 0.960000 +-0.600000 -0.351500 0.201700 -0.216000 0.016000 0.968000 +-0.600000 -0.401700 0.205900 -0.320000 -0.144000 0.928000 +-0.600000 -0.401700 0.205900 -0.320000 -0.144000 0.928000 +-0.512000 -0.251000 0.182900 -0.112000 0.632000 0.760000 +-0.512000 -0.251000 0.182900 -0.112000 0.632000 0.760000 +-0.500000 -0.249000 0.182900 -0.112000 0.656000 0.744000 +-0.500000 -0.251000 0.185100 -0.112000 0.632000 0.760000 +-0.450000 -0.233700 0.182900 -0.216000 0.472000 0.848000 +-0.450000 -0.251000 0.195400 -0.152000 0.392000 0.904000 +-0.400000 -0.206800 0.182900 -0.168000 0.424000 0.880000 +-0.400000 -0.251000 0.203200 0.024000 0.208000 0.976000 +-0.383500 -0.200800 0.182900 -0.152000 0.448000 0.872000 +-0.350000 -0.251000 0.206900 0.584000 -0.272000 0.760000 +-0.350000 -0.200800 0.190300 -0.112000 0.384000 0.912000 +-0.334800 -0.251000 0.182900 0.672000 -0.480000 0.552000 +-0.300000 -0.200800 0.189700 0.744000 -0.432000 0.496000 +-0.300000 -0.205800 0.182900 0.768000 -0.472000 0.416000 +-0.296900 -0.200800 0.182900 0.792000 -0.440000 0.408000 +-0.300000 -0.251000 0.131000 0.632000 -0.616000 0.464000 +-0.278100 -0.200800 0.121900 0.816000 -0.432000 0.368000 +-0.294600 -0.251000 0.121900 0.616000 -0.600000 0.488000 +-0.250000 -0.200800 0.078600 0.664000 -0.312000 0.672000 +-0.250000 -0.251000 0.071500 0.528000 -0.408000 0.736000 +-0.222100 -0.200800 0.060900 0.488000 -0.184000 0.848000 +-0.236900 -0.251000 0.060900 0.464000 -0.480000 0.728000 +-0.200000 -0.200800 0.045500 0.568000 -0.152000 0.808000 +-0.200000 -0.251000 0.018200 0.408000 -0.392000 0.816000 +-0.200000 -0.251000 0.018200 0.408000 -0.392000 0.816000 +-0.450000 -0.351500 0.215900 0.592000 -0.216000 0.768000 +-0.450000 -0.351500 0.215900 0.592000 -0.216000 0.768000 +-0.500000 -0.351500 0.209200 0.072000 0.104000 0.984000 +-0.450000 -0.401700 0.188700 0.656000 -0.464000 0.584000 +-0.500000 -0.401700 0.210500 0.208000 -0.296000 0.928000 +-0.450000 -0.407300 0.182900 0.664000 -0.488000 0.552000 +-0.500000 -0.444100 0.182900 0.168000 -0.480000 0.848000 +-0.500000 -0.444100 0.182900 0.168000 -0.480000 0.848000 +-0.400000 -0.351500 0.196700 0.560000 -0.576000 0.584000 +-0.400000 -0.351500 0.196700 0.560000 -0.576000 0.584000 +-0.400000 -0.359600 0.182900 0.520000 -0.680000 0.496000 +-0.450000 -0.351500 0.215900 0.592000 -0.216000 0.768000 +-0.445800 -0.401700 0.182900 0.648000 -0.488000 0.568000 +-0.450000 -0.401700 0.188700 0.656000 -0.464000 0.584000 +-0.450000 -0.407300 0.182900 0.664000 -0.488000 0.552000 +-0.450000 -0.407300 0.182900 0.664000 -0.488000 0.552000 +-0.383500 -0.200800 0.182900 -0.152000 0.448000 0.872000 +-0.383500 -0.200800 0.182900 -0.152000 0.448000 0.872000 +-0.350000 -0.189600 0.182900 -0.288000 0.472000 0.824000 +-0.350000 -0.200800 0.190300 -0.112000 0.384000 0.912000 +-0.311100 -0.150600 0.182900 -0.424000 0.464000 0.768000 +-0.300000 -0.200800 0.189700 0.744000 -0.432000 0.496000 +-0.300000 -0.150600 0.190700 0.000000 0.520000 0.848000 +-0.296900 -0.200800 0.182900 0.792000 -0.440000 0.408000 +-0.288800 -0.150600 0.182900 0.600000 0.360000 0.712000 +-0.278100 -0.200800 0.121900 0.816000 -0.432000 0.368000 +-0.252800 -0.150600 0.121900 0.720000 -0.296000 0.616000 +-0.250000 -0.200800 0.078600 0.664000 -0.312000 0.672000 +-0.250000 -0.150600 0.117900 0.712000 -0.320000 0.616000 +-0.222100 -0.200800 0.060900 0.488000 -0.184000 0.848000 +-0.212600 -0.150600 0.060900 0.712000 -0.216000 0.664000 +-0.200000 -0.200800 0.045500 0.568000 -0.152000 0.808000 +-0.200000 -0.150600 0.042600 0.640000 -0.096000 0.752000 +-0.212600 -0.150600 0.060900 0.712000 -0.216000 0.664000 +-0.200000 -0.121800 0.060900 0.728000 -0.328000 0.592000 +-0.250000 -0.150600 0.117900 0.712000 -0.320000 0.616000 +-0.200000 -0.100400 0.076800 0.784000 -0.136000 0.600000 +-0.250000 -0.144000 0.121900 0.720000 -0.312000 0.608000 +-0.230200 -0.100400 0.121900 0.776000 -0.176000 0.600000 +-0.250000 -0.100400 0.155000 0.480000 0.160000 0.856000 +-0.247100 -0.050200 0.121900 0.488000 0.512000 0.696000 +-0.250000 -0.050200 0.123600 0.200000 0.440000 0.864000 +-0.250000 -0.048000 0.121900 0.272000 0.640000 0.704000 +-0.255700 -0.050200 0.121900 -0.192000 0.512000 0.832000 +-0.250000 0.000000 0.079500 -0.144000 0.552000 0.816000 +-0.300000 -0.050200 0.104800 -0.312000 0.512000 0.792000 +-0.300000 0.000000 0.088800 -0.240000 0.432000 0.864000 +-0.350000 -0.050200 0.083200 -0.416000 0.344000 0.832000 +-0.348200 0.000000 0.060900 -0.376000 0.448000 0.800000 +-0.350000 -0.001900 0.060900 -0.656000 0.280000 0.688000 +-0.350000 0.000000 0.059800 -0.688000 0.400000 0.592000 +-0.367400 -0.050200 0.060900 -0.696000 0.408000 0.584000 +-0.373100 0.000000 0.000000 -0.880000 0.240000 0.392000 +-0.399300 -0.050200 0.000000 -0.696000 0.680000 0.184000 +-0.377800 0.000000 -0.060900 -0.864000 0.424000 -0.248000 +-0.400000 -0.050200 -0.003200 -0.712000 0.672000 0.168000 +-0.400000 -0.037800 -0.060900 -0.728000 0.664000 0.152000 +-0.406900 -0.050200 -0.060900 -0.848000 0.520000 0.000000 +-0.400000 -0.050200 -0.118700 -0.832000 0.528000 -0.160000 +-0.450000 -0.099400 -0.060900 -0.760000 0.616000 0.160000 +-0.400000 -0.050900 -0.121900 -0.736000 0.536000 -0.408000 +-0.450000 -0.100400 -0.065100 -0.512000 0.824000 -0.200000 +-0.434900 -0.100400 -0.121900 -0.608000 0.744000 -0.256000 +-0.450000 -0.111500 -0.121900 -0.376000 0.896000 -0.224000 +-0.403600 -0.100400 -0.182900 -0.616000 0.592000 -0.512000 +-0.450000 -0.128500 -0.182900 -0.504000 0.800000 -0.296000 +-0.400000 -0.100400 -0.188300 -0.616000 0.576000 -0.520000 +-0.450000 -0.150600 -0.239400 -0.408000 0.792000 -0.448000 +-0.400000 -0.131400 -0.243900 -0.384000 0.744000 -0.536000 +-0.444500 -0.150600 -0.243900 -0.312000 0.784000 -0.528000 +-0.400000 -0.150600 -0.272200 -0.312000 0.624000 -0.704000 +-0.450000 -0.152500 -0.243900 -0.384000 0.800000 -0.448000 +-0.400000 -0.174400 -0.304800 -0.224000 0.736000 -0.632000 +-0.450000 -0.186700 -0.304800 -0.216000 0.808000 -0.528000 +-0.400000 -0.200800 -0.333600 -0.064000 0.568000 -0.816000 +-0.450000 -0.200800 -0.327900 -0.112000 0.704000 -0.696000 +-0.400000 -0.239300 -0.365800 0.048000 0.512000 -0.848000 +-0.450000 -0.235000 -0.365800 -0.016000 0.592000 -0.800000 +-0.400000 -0.251000 -0.373300 0.080000 0.400000 -0.904000 +-0.450000 -0.251000 -0.376500 0.032000 0.432000 -0.896000 +-0.400000 -0.301200 -0.390900 0.144000 0.296000 -0.936000 +-0.450000 -0.301200 -0.399100 0.080000 0.320000 -0.936000 +-0.400000 -0.351500 -0.411400 0.000000 0.616000 -0.784000 +-0.450000 -0.351500 -0.418600 0.080000 0.512000 -0.848000 +-0.450000 -0.301200 -0.399100 0.080000 0.320000 -0.936000 +-0.500000 -0.351500 -0.423900 0.056000 0.504000 -0.856000 +-0.500000 -0.301200 -0.402500 0.040000 0.344000 -0.936000 +-0.450000 -0.301200 -0.399100 0.080000 0.320000 -0.936000 +-0.500000 -0.251000 -0.377000 -0.032000 0.528000 -0.840000 +-0.450000 -0.251000 -0.376500 0.032000 0.432000 -0.896000 +-0.500000 -0.238600 -0.365800 -0.072000 0.656000 -0.744000 +-0.450000 -0.235000 -0.365800 -0.016000 0.592000 -0.800000 +-0.500000 -0.200800 -0.313000 -0.112000 0.824000 -0.544000 +-0.450000 -0.200800 -0.327900 -0.112000 0.704000 -0.696000 +-0.500000 -0.196700 -0.304800 -0.120000 0.848000 -0.504000 +-0.450000 -0.186700 -0.304800 -0.216000 0.808000 -0.528000 +-0.500000 -0.169200 -0.243900 -0.328000 0.880000 -0.312000 +-0.450000 -0.152500 -0.243900 -0.384000 0.800000 -0.448000 +-0.500000 -0.154300 -0.182900 -0.320000 0.920000 -0.176000 +-0.450000 -0.150600 -0.239400 -0.408000 0.792000 -0.448000 +-0.491700 -0.150600 -0.182900 -0.448000 0.848000 -0.264000 +-0.450000 -0.128500 -0.182900 -0.504000 0.800000 -0.296000 +-0.500000 -0.150600 -0.154000 -0.424000 0.880000 -0.160000 +-0.450000 -0.111500 -0.121900 -0.376000 0.896000 -0.224000 +-0.500000 -0.144400 -0.121900 -0.376000 0.880000 -0.280000 +-0.450000 -0.100400 -0.065100 -0.512000 0.824000 -0.200000 +-0.500000 -0.119500 -0.060900 -0.160000 0.976000 0.112000 +-0.452400 -0.100400 -0.060900 -0.344000 0.936000 -0.016000 +-0.500000 -0.141000 0.000000 -0.040000 0.880000 0.456000 +-0.450000 -0.100400 -0.057100 -0.400000 0.872000 0.264000 +-0.450000 -0.112700 0.000000 -0.520000 0.784000 0.320000 +-0.434300 -0.100400 0.000000 -0.648000 0.720000 0.208000 +-0.450000 -0.136300 0.060900 -0.512000 0.720000 0.448000 +-0.405500 -0.100400 0.060900 -0.712000 0.456000 0.520000 +-0.450000 -0.150600 0.089400 -0.440000 0.744000 0.496000 +-0.400000 -0.100400 0.069600 -0.688000 0.456000 0.552000 +-0.414900 -0.150600 0.121900 -0.424000 0.616000 0.648000 +-0.400000 -0.140400 0.121900 -0.448000 0.624000 0.632000 +-0.400000 -0.150600 0.133500 -0.392000 0.600000 0.688000 +-0.351400 -0.100400 0.121900 -0.608000 0.368000 0.696000 +-0.350000 -0.150600 0.151300 -0.584000 0.352000 0.720000 +-0.350000 -0.100400 0.123500 -0.608000 0.328000 0.712000 +-0.311100 -0.150600 0.182900 -0.424000 0.464000 0.768000 +-0.300000 -0.100400 0.149000 -0.304000 0.432000 0.840000 +-0.300000 -0.142200 0.182900 0.000000 0.616000 0.776000 +-0.250000 -0.100400 0.155000 0.480000 0.160000 0.856000 +-0.288800 -0.150600 0.182900 0.600000 0.360000 0.712000 +-0.250000 -0.144000 0.121900 0.720000 -0.312000 0.608000 +-0.252800 -0.150600 0.121900 0.720000 -0.296000 0.616000 +-0.250000 -0.150600 0.117900 0.712000 -0.320000 0.616000 +-0.250000 -0.150600 0.117900 0.712000 -0.320000 0.616000 +-0.400000 -0.351500 0.196700 0.560000 -0.576000 0.584000 +-0.400000 -0.351500 0.196700 0.560000 -0.576000 0.584000 +-0.389000 -0.351500 0.182900 0.544000 -0.632000 0.536000 +-0.400000 -0.359600 0.182900 0.520000 -0.680000 0.496000 +-0.400000 -0.359600 0.182900 0.520000 -0.680000 0.496000 +-0.311100 -0.150600 0.182900 -0.424000 0.464000 0.768000 +-0.311100 -0.150600 0.182900 -0.424000 0.464000 0.768000 +-0.300000 -0.142200 0.182900 0.000000 0.616000 0.776000 +-0.300000 -0.150600 0.190700 0.000000 0.520000 0.848000 +-0.288800 -0.150600 0.182900 0.600000 0.360000 0.712000 +-0.288800 -0.150600 0.182900 0.600000 0.360000 0.712000 +0.577700 0.301200 0.182900 -0.536000 0.272000 0.792000 +0.577700 0.301200 0.182900 -0.536000 0.272000 0.792000 +0.600000 0.327100 0.182900 -0.144000 0.552000 0.816000 +0.600000 0.301200 0.199900 -0.528000 0.136000 0.832000 +0.650000 0.311500 0.182900 0.424000 0.496000 0.752000 +0.650000 0.301200 0.190400 0.408000 0.464000 0.776000 +0.660200 0.301200 0.182900 0.480000 0.488000 0.720000 +0.650000 0.251000 0.217300 -0.016000 0.232000 0.968000 +0.700000 0.263400 0.182900 0.512000 0.536000 0.664000 +0.700000 0.251000 0.193900 0.488000 0.504000 0.704000 +0.711700 0.251000 0.182900 0.560000 0.528000 0.624000 +0.700000 0.200800 0.226400 0.328000 0.432000 0.832000 +0.750000 0.208300 0.182900 0.448000 0.624000 0.632000 +0.750000 0.200800 0.191100 0.424000 0.552000 0.712000 +0.761100 0.200800 0.182900 0.432000 0.472000 0.760000 +0.750000 0.150600 0.201100 0.320000 0.240000 0.912000 +0.797300 0.150600 0.182900 0.336000 0.288000 0.888000 +0.750000 0.100400 0.207000 0.032000 -0.192000 0.976000 +0.800000 0.148000 0.182900 0.424000 0.336000 0.832000 +0.800000 0.100400 0.199400 -0.032000 0.024000 0.992000 +0.850000 0.129700 0.182900 0.408000 0.752000 0.504000 +0.850000 0.100400 0.222500 0.440000 0.584000 0.672000 +0.891700 0.100400 0.182900 0.576000 0.688000 0.424000 +0.850000 0.050200 0.216300 -0.184000 -0.272000 0.936000 +0.900000 0.093100 0.182900 0.568000 0.672000 0.464000 +0.900000 0.050200 0.226800 0.488000 0.496000 0.712000 +0.940200 0.050200 0.182900 0.624000 0.528000 0.568000 +0.900000 0.000000 0.237100 -0.176000 -0.616000 0.760000 +0.950000 0.037400 0.182900 0.520000 0.504000 0.680000 +0.950000 0.000000 0.206500 0.400000 0.008000 0.912000 +1.000000 0.004900 0.182900 0.336000 0.520000 0.776000 +1.000000 0.000000 0.186800 0.376000 0.128000 0.912000 +0.950000 0.000000 0.206500 0.400000 0.008000 0.912000 +1.000000 -0.012000 0.182900 0.384000 -0.248000 0.880000 +0.950000 -0.050200 0.197900 0.336000 -0.192000 0.920000 +0.975800 -0.050200 0.182900 0.464000 -0.232000 0.848000 +0.950000 -0.100400 0.196500 0.208000 -0.704000 0.672000 +0.959000 -0.100400 0.182900 0.616000 -0.584000 0.520000 +0.950000 -0.108800 0.182900 0.232000 -0.768000 0.584000 +1.000000 -0.100400 0.134700 0.432000 -0.528000 0.720000 +0.950000 -0.142500 0.121900 -0.608000 -0.672000 0.392000 +1.000000 -0.126300 0.121900 0.016000 -0.480000 0.872000 +0.950000 -0.150600 0.094900 -0.648000 -0.696000 0.272000 +1.000000 -0.150600 0.101600 -0.080000 -0.576000 0.808000 +0.950000 -0.158100 0.060900 -0.608000 -0.760000 0.200000 +1.000000 -0.176100 0.060900 -0.688000 -0.632000 0.336000 +0.950000 -0.168100 0.000000 -0.640000 -0.744000 0.184000 +1.000000 -0.200800 0.012500 -0.656000 -0.696000 0.264000 +0.995800 -0.200800 0.000000 -0.648000 -0.704000 0.264000 +1.000000 -0.204500 0.000000 -0.624000 -0.728000 0.256000 +0.973000 -0.200800 -0.060900 -0.584000 -0.760000 0.264000 +1.000000 -0.224100 -0.060900 -0.616000 -0.728000 0.280000 +0.950500 -0.200800 -0.121900 -0.632000 -0.744000 0.192000 +1.000000 -0.243600 -0.121900 -0.640000 -0.736000 0.184000 +0.950000 -0.200800 -0.124000 -0.680000 -0.712000 0.160000 +1.000000 -0.251000 -0.154300 -0.728000 -0.648000 0.200000 +0.950000 -0.211700 -0.182900 -0.704000 -0.680000 0.176000 +0.993400 -0.251000 -0.182900 -0.736000 -0.640000 0.200000 +0.950000 -0.224400 -0.243900 -0.688000 -0.640000 0.328000 +0.978600 -0.251000 -0.243900 -0.696000 -0.616000 0.352000 +0.950000 -0.251000 -0.295200 -0.640000 -0.496000 0.576000 +1.000000 -0.277900 -0.243900 -0.712000 -0.592000 0.360000 +0.950000 -0.261400 -0.304800 -0.752000 -0.584000 0.288000 +1.000000 -0.301200 -0.291200 -0.640000 -0.488000 0.576000 +0.989600 -0.301200 -0.304800 -0.816000 -0.560000 0.128000 +1.000000 -0.316200 -0.304800 -0.800000 -0.552000 0.224000 +1.000000 -0.301200 -0.328200 -0.784000 -0.440000 -0.424000 +0.989600 -0.301200 -0.304800 -0.816000 -0.560000 0.128000 +1.000000 -0.251000 -0.355700 -0.816000 -0.248000 -0.504000 +0.950000 -0.261400 -0.304800 -0.752000 -0.584000 0.288000 +0.950000 -0.251000 -0.328200 -0.712000 -0.568000 -0.392000 +0.942100 -0.251000 -0.304800 -0.752000 -0.552000 0.344000 +0.950000 -0.200800 -0.357000 -0.272000 -0.104000 -0.952000 +0.911900 -0.200800 -0.304800 -0.864000 -0.480000 -0.128000 +0.950000 -0.150600 -0.345500 -0.032000 0.064000 -0.992000 +0.900000 -0.181100 -0.304800 -0.768000 -0.440000 -0.448000 +0.900000 -0.150600 -0.332000 -0.672000 -0.328000 -0.656000 +0.883200 -0.150600 -0.304800 -0.864000 -0.368000 -0.320000 +0.900000 -0.100400 -0.341700 -0.464000 -0.104000 -0.872000 +0.869700 -0.100400 -0.304800 -0.880000 -0.248000 -0.400000 +0.900000 -0.050200 -0.348300 -0.256000 0.192000 -0.944000 +0.867300 -0.050200 -0.304800 -0.784000 -0.136000 -0.600000 +0.900000 0.000000 -0.329500 -0.080000 0.648000 -0.744000 +0.877300 0.000000 -0.304800 -0.592000 0.480000 -0.632000 +0.900000 0.016700 -0.304800 -0.152000 0.720000 -0.664000 +0.850000 0.000000 -0.279000 -0.536000 0.488000 -0.680000 +0.900000 0.050200 -0.268900 0.208000 0.672000 -0.696000 +0.850000 0.042400 -0.243900 -0.408000 0.528000 -0.736000 +0.858900 0.050200 -0.243900 -0.424000 0.568000 -0.696000 +0.850000 0.050200 -0.237100 -0.376000 0.576000 -0.720000 +0.900000 0.070800 -0.243900 -0.096000 0.744000 -0.656000 +0.850000 0.100400 -0.218500 0.128000 0.592000 -0.784000 +0.900000 0.100400 -0.203200 0.536000 0.688000 -0.472000 +0.850000 0.127100 -0.182900 0.192000 0.744000 -0.632000 +0.900000 0.111100 -0.182900 0.552000 0.712000 -0.416000 +0.850000 0.150600 -0.140900 0.432000 0.840000 -0.304000 +0.900000 0.127900 -0.121900 0.560000 0.776000 -0.264000 +0.859300 0.150600 -0.121900 0.456000 0.840000 -0.272000 +0.900000 0.143500 -0.060900 0.528000 0.808000 -0.240000 +0.888500 0.150600 -0.060900 0.504000 0.856000 -0.040000 +0.900000 0.131100 0.000000 0.480000 0.848000 0.192000 +0.867700 0.150600 0.000000 0.552000 0.816000 0.152000 +0.900000 0.118900 0.060900 0.472000 0.856000 0.184000 +0.855400 0.150600 0.060900 0.680000 0.720000 0.072000 +0.900000 0.107300 0.121900 0.512000 0.832000 0.184000 +0.850900 0.150600 0.121900 0.704000 0.704000 0.080000 +0.900000 0.100400 0.165200 0.584000 0.744000 0.296000 +0.850000 0.150600 0.126500 0.640000 0.560000 0.512000 +0.891700 0.100400 0.182900 0.576000 0.688000 0.424000 +0.850000 0.129700 0.182900 0.408000 0.752000 0.504000 +0.850000 0.150600 0.126500 0.640000 0.560000 0.512000 +0.800000 0.148000 0.182900 0.424000 0.336000 0.832000 +0.800000 0.150600 0.181400 0.520000 0.336000 0.776000 +0.797300 0.150600 0.182900 0.336000 0.288000 0.888000 +0.800000 0.190400 0.121900 0.624000 0.752000 0.168000 +0.761100 0.200800 0.182900 0.432000 0.472000 0.760000 +0.788900 0.200800 0.121900 0.632000 0.744000 0.184000 +0.750000 0.208300 0.182900 0.448000 0.624000 0.632000 +0.750000 0.233400 0.121900 0.720000 0.680000 -0.080000 +0.711700 0.251000 0.182900 0.560000 0.528000 0.624000 +0.736800 0.251000 0.121900 0.752000 0.632000 0.144000 +0.700000 0.263400 0.182900 0.512000 0.536000 0.664000 +0.700000 0.297800 0.121900 0.728000 0.680000 -0.032000 +0.660200 0.301200 0.182900 0.480000 0.488000 0.720000 +0.696500 0.301200 0.121900 0.712000 0.672000 0.168000 +0.650000 0.311500 0.182900 0.424000 0.496000 0.752000 +0.653800 0.351500 0.121900 0.656000 0.616000 0.424000 +0.650000 0.351500 0.128300 0.616000 0.616000 0.480000 +0.650000 0.355500 0.121900 0.632000 0.632000 0.432000 +0.600000 0.351500 0.157200 -0.376000 0.584000 0.704000 +0.600000 0.382600 0.121900 0.272000 0.776000 0.560000 +0.566500 0.351500 0.121900 -0.632000 0.576000 0.496000 +0.600000 0.401700 0.085900 0.096000 0.928000 0.336000 +0.550000 0.351500 0.078000 -0.616000 0.672000 0.392000 +0.584600 0.401700 0.060900 -0.416000 0.872000 0.248000 +0.550000 0.359900 0.060900 -0.592000 0.640000 0.480000 +0.568400 0.401700 0.000000 -0.472000 0.832000 -0.264000 +0.550000 0.388900 0.000000 -0.392000 0.856000 0.320000 +0.600000 0.401700 -0.057700 0.168000 0.920000 -0.344000 +0.550000 0.398000 -0.060900 0.000000 0.968000 -0.216000 +0.600000 0.400600 -0.060900 -0.072000 0.912000 -0.384000 +0.550000 0.362300 -0.121900 0.400000 0.656000 -0.632000 +0.600000 0.351500 -0.101600 0.448000 0.496000 -0.736000 +0.566700 0.351500 -0.121900 0.448000 0.536000 -0.704000 +0.600000 0.310600 -0.121900 0.480000 0.424000 -0.760000 +0.550000 0.351500 -0.135900 0.456000 0.632000 -0.616000 +0.600000 0.301200 -0.128700 0.472000 0.520000 -0.704000 +0.550000 0.301200 -0.167400 0.408000 0.504000 -0.752000 +0.600000 0.256700 -0.182900 0.328000 0.496000 -0.792000 +0.550000 0.283200 -0.182900 0.320000 0.472000 -0.816000 +0.600000 0.251000 -0.187000 0.320000 0.456000 -0.816000 +0.550000 0.251000 -0.199600 0.176000 0.288000 -0.936000 +0.600000 0.200800 -0.209200 0.248000 0.288000 -0.920000 +0.550000 0.200800 -0.211100 0.016000 0.048000 -0.992000 +0.600000 0.150600 -0.225200 0.008000 0.128000 -0.984000 +0.550000 0.150600 -0.215400 -0.144000 0.080000 -0.984000 +0.600000 0.100400 -0.237100 -0.096000 0.168000 -0.976000 +0.550000 0.100400 -0.212600 -0.200000 0.352000 -0.904000 +0.600000 0.076600 -0.243900 -0.096000 0.360000 -0.920000 +0.550000 0.067800 -0.243900 0.024000 0.672000 -0.728000 +0.600000 0.050200 -0.251100 0.248000 0.344000 -0.896000 +0.550000 0.050200 -0.258400 0.160000 0.632000 -0.752000 +0.600000 0.000000 -0.284600 0.512000 0.112000 -0.840000 +0.550000 0.015600 -0.304800 0.472000 0.712000 -0.512000 +0.578400 0.000000 -0.304800 0.536000 0.480000 -0.688000 +0.550000 0.000000 -0.335900 0.576000 0.464000 -0.664000 +0.587300 -0.050200 -0.304800 0.688000 0.056000 -0.712000 +0.550000 -0.050200 -0.345500 0.192000 -0.560000 -0.792000 +0.550000 -0.083700 -0.304800 0.088000 -0.736000 -0.664000 +0.500000 -0.050200 -0.339600 -0.136000 -0.672000 -0.720000 +0.500000 -0.082600 -0.304800 0.216000 -0.680000 -0.688000 +0.450000 -0.050200 -0.325200 -0.120000 -0.568000 -0.808000 +0.475800 -0.100400 -0.304800 0.512000 -0.104000 -0.848000 +0.450000 -0.100400 -0.322200 0.392000 -0.360000 -0.840000 +0.500000 -0.127100 -0.304800 0.480000 0.456000 -0.744000 +0.450000 -0.150600 -0.321300 -0.008000 0.120000 -0.992000 +0.500000 -0.150600 -0.319100 0.336000 0.504000 -0.792000 +0.450000 -0.200800 -0.331300 -0.472000 -0.400000 -0.776000 +0.500000 -0.200800 -0.334200 -0.376000 -0.448000 -0.800000 +0.450000 -0.217600 -0.304800 -0.352000 -0.736000 -0.560000 +0.500000 -0.222600 -0.304800 -0.320000 -0.704000 -0.624000 +0.450000 -0.248400 -0.243900 -0.224000 -0.888000 -0.384000 +0.500000 -0.251000 -0.264200 -0.272000 -0.744000 -0.600000 +0.459300 -0.251000 -0.243900 -0.280000 -0.864000 -0.400000 +0.500000 -0.282700 -0.243900 -0.568000 -0.592000 -0.560000 +0.450000 -0.251000 -0.203800 -0.216000 -0.960000 -0.144000 +0.500000 -0.288400 -0.182900 -0.520000 -0.656000 0.528000 +0.450000 -0.255300 -0.182900 -0.208000 -0.656000 0.712000 +0.500000 -0.251000 -0.123800 -0.544000 -0.688000 0.456000 +0.450000 -0.251000 -0.179900 -0.288000 -0.680000 0.664000 +0.500000 -0.250100 -0.121900 -0.432000 -0.712000 0.536000 +0.450000 -0.227100 -0.121900 -0.296000 -0.712000 0.624000 +0.500000 -0.203100 -0.060900 -0.256000 -0.616000 0.736000 +0.450000 -0.200800 -0.072200 -0.256000 -0.536000 0.800000 +0.491400 -0.200800 -0.060900 -0.168000 -0.584000 0.784000 +0.450000 -0.150600 -0.064700 -0.192000 0.128000 0.968000 +0.463100 -0.150600 -0.060900 -0.168000 0.352000 0.912000 +0.450000 -0.100400 -0.078400 -0.088000 0.200000 0.968000 +0.500000 -0.139000 -0.060900 0.080000 0.536000 0.832000 +0.500000 -0.100400 -0.086800 -0.048000 0.256000 0.960000 +0.530700 -0.150600 -0.060900 0.208000 0.504000 0.832000 +0.550000 -0.100400 -0.076900 0.056000 0.056000 0.992000 +0.550000 -0.150600 -0.067100 0.240000 0.480000 0.840000 +0.600000 -0.100400 -0.077400 0.584000 0.048000 0.800000 +0.600000 -0.150600 -0.093600 0.304000 0.568000 0.752000 +0.626600 -0.100400 -0.121900 0.848000 0.208000 0.472000 +0.650000 -0.150600 -0.116200 0.720000 0.480000 0.488000 +0.650000 -0.146100 -0.121900 0.720000 0.504000 0.464000 +0.652900 -0.150600 -0.121900 0.752000 0.456000 0.464000 +0.650000 -0.117900 -0.182900 0.792000 0.600000 0.024000 +0.675300 -0.150600 -0.182900 0.768000 0.552000 0.296000 +0.650000 -0.120200 -0.243900 0.704000 0.520000 -0.472000 +0.674200 -0.150600 -0.243900 0.696000 0.600000 -0.384000 +0.650000 -0.150600 -0.274900 0.544000 0.464000 -0.688000 +0.700000 -0.175300 -0.243900 0.752000 0.600000 -0.240000 +0.650000 -0.200800 -0.297000 0.088000 0.616000 -0.776000 +0.700000 -0.200800 -0.294000 0.576000 0.608000 -0.536000 +0.650000 -0.208600 -0.304800 0.024000 0.680000 -0.728000 +0.700000 -0.211400 -0.304800 0.288000 0.624000 -0.720000 +0.650000 -0.245700 -0.365800 0.168000 0.856000 -0.480000 +0.700000 -0.251000 -0.357800 0.296000 0.496000 -0.808000 +0.678000 -0.251000 -0.365800 0.264000 0.520000 -0.808000 +0.700000 -0.301200 -0.354900 0.160000 -0.240000 -0.952000 +0.650000 -0.267900 -0.365800 0.280000 -0.440000 -0.848000 +0.650000 -0.301200 -0.350300 0.016000 -0.440000 -0.888000 +0.600000 -0.288400 -0.365800 -0.376000 -0.712000 -0.584000 +0.600000 -0.301200 -0.352300 -0.528000 -0.312000 -0.776000 +0.573000 -0.251000 -0.365800 -0.696000 0.544000 -0.464000 +0.567500 -0.301200 -0.304800 -0.696000 0.400000 -0.584000 +0.550000 -0.251000 -0.326800 -0.648000 -0.504000 -0.560000 +0.550000 -0.272400 -0.304800 -0.680000 -0.440000 -0.576000 +0.535300 -0.251000 -0.304800 -0.648000 -0.480000 -0.576000 +0.550000 -0.301200 -0.279200 -0.712000 0.120000 -0.680000 +0.500000 -0.251000 -0.264200 -0.272000 -0.744000 -0.600000 +0.513800 -0.301200 -0.243900 -0.728000 0.592000 -0.328000 +0.500000 -0.282700 -0.243900 -0.568000 -0.592000 -0.560000 +0.511800 -0.301200 -0.182900 -0.912000 0.352000 0.176000 +0.500000 -0.288400 -0.182900 -0.520000 -0.656000 0.528000 +0.550000 -0.301200 -0.123600 -0.624000 -0.440000 0.632000 +0.500000 -0.251000 -0.123800 -0.544000 -0.688000 0.456000 +0.550000 -0.300100 -0.121900 -0.624000 -0.616000 0.472000 +0.501100 -0.251000 -0.121900 -0.552000 -0.624000 0.544000 +0.550000 -0.251000 -0.069700 -0.416000 -0.584000 0.688000 +0.500000 -0.250100 -0.121900 -0.432000 -0.712000 0.536000 +0.550000 -0.242100 -0.060900 -0.400000 -0.536000 0.736000 +0.500000 -0.203100 -0.060900 -0.256000 -0.616000 0.736000 +0.550000 -0.200800 -0.034900 0.016000 -0.040000 0.992000 +0.500000 -0.200800 -0.058700 -0.200000 -0.576000 0.784000 +0.550000 -0.159500 -0.060900 0.248000 0.472000 0.840000 +0.500000 -0.150600 -0.051600 0.024000 0.352000 0.928000 +0.530700 -0.150600 -0.060900 0.208000 0.504000 0.832000 +0.500000 -0.139000 -0.060900 0.080000 0.536000 0.832000 +0.500000 -0.150600 -0.051600 0.024000 0.352000 0.928000 +0.463100 -0.150600 -0.060900 -0.168000 0.352000 0.912000 +0.500000 -0.200800 -0.058700 -0.200000 -0.576000 0.784000 +0.491400 -0.200800 -0.060900 -0.168000 -0.584000 0.784000 +0.500000 -0.203100 -0.060900 -0.256000 -0.616000 0.736000 +0.500000 -0.203100 -0.060900 -0.256000 -0.616000 0.736000 +0.600000 0.251000 0.198700 -0.584000 -0.144000 0.792000 +0.600000 0.251000 0.198700 -0.584000 -0.144000 0.792000 +0.600000 0.301200 0.199900 -0.528000 0.136000 0.832000 +0.586200 0.251000 0.182900 -0.672000 -0.144000 0.720000 +0.577700 0.301200 0.182900 -0.536000 0.272000 0.792000 +0.550000 0.251000 0.125100 -0.872000 -0.184000 0.440000 +0.550000 0.301200 0.149100 -0.896000 -0.096000 0.416000 +0.548800 0.251000 0.121900 -0.912000 -0.176000 0.360000 +0.538800 0.301200 0.121900 -0.912000 0.128000 0.376000 +0.533200 0.251000 0.060900 -0.856000 0.032000 0.512000 +0.526500 0.301200 0.060900 -0.896000 0.008000 0.432000 +0.500800 0.251000 0.000000 -0.792000 -0.016000 0.608000 +0.500000 0.301200 0.002700 -0.768000 -0.080000 0.624000 +0.500000 0.266900 0.000000 -0.760000 -0.040000 0.640000 +0.497900 0.301200 0.000000 -0.728000 -0.144000 0.664000 +0.500000 0.251000 -0.000900 -0.496000 0.112000 0.856000 +0.450000 0.301200 -0.039700 -0.448000 -0.256000 0.848000 +0.450000 0.251000 -0.039600 -0.400000 -0.080000 0.904000 +0.400000 0.301200 -0.051900 -0.168000 -0.472000 0.856000 +0.400000 0.251000 -0.058700 -0.328000 -0.176000 0.920000 +0.353900 0.301200 -0.060900 -0.128000 -0.544000 0.824000 +0.395100 0.251000 -0.060900 -0.344000 -0.184000 0.912000 +0.350000 0.301200 -0.062100 -0.176000 -0.704000 0.680000 +0.350000 0.251000 -0.088400 -0.448000 -0.320000 0.824000 +0.300000 0.301200 -0.077400 -0.160000 -0.712000 0.680000 +0.300000 0.251000 -0.114600 -0.168000 -0.536000 0.824000 +0.250000 0.301200 -0.083600 -0.096000 -0.744000 0.648000 +0.271900 0.251000 -0.121900 -0.240000 -0.760000 0.592000 +0.250000 0.256500 -0.121900 -0.200000 -0.800000 0.552000 +0.300000 0.251000 -0.156100 -0.368000 -0.808000 -0.448000 +0.250000 0.284000 -0.182900 -0.096000 -0.256000 -0.952000 +0.300000 0.284000 -0.182900 -0.168000 -0.184000 -0.960000 +0.250000 0.301200 -0.184400 -0.080000 -0.056000 -0.992000 +0.300000 0.301200 -0.184400 -0.064000 -0.072000 -0.992000 +0.250000 0.351500 -0.189100 -0.160000 0.168000 -0.968000 +0.300000 0.351500 -0.193900 -0.008000 0.064000 -0.992000 +0.250000 0.370000 -0.182900 -0.184000 0.304000 -0.928000 +0.300000 0.379400 -0.182900 -0.016000 0.272000 -0.960000 +0.250000 0.401700 -0.172700 -0.016000 0.288000 -0.952000 +0.300000 0.401700 -0.174800 0.040000 0.368000 -0.920000 +0.250000 0.451900 -0.137900 0.128000 0.536000 -0.824000 +0.300000 0.451900 -0.131100 0.200000 0.712000 -0.664000 +0.250000 0.466900 -0.121900 0.232000 0.968000 0.016000 +0.300000 0.458100 -0.121900 0.224000 0.952000 -0.176000 +0.250000 0.451900 -0.094000 0.248000 0.784000 0.552000 +0.300000 0.451900 -0.106900 0.184000 0.864000 0.456000 +0.250000 0.432000 -0.060900 0.224000 0.624000 0.736000 +0.300000 0.430700 -0.060900 0.128000 0.808000 0.568000 +0.250000 0.401700 -0.026800 -0.216000 0.176000 0.952000 +0.300000 0.401700 -0.022200 0.096000 0.472000 0.864000 +0.250000 0.351500 -0.020200 -0.488000 -0.416000 0.760000 +0.300000 0.351500 -0.009100 -0.016000 -0.144000 0.984000 +0.250000 0.317900 -0.060900 -0.432000 -0.680000 0.584000 +0.300000 0.310700 -0.060900 -0.072000 -0.760000 0.640000 +0.250000 0.301200 -0.083600 -0.096000 -0.744000 0.648000 +0.300000 0.301200 -0.077400 -0.160000 -0.712000 0.680000 +0.300000 0.310700 -0.060900 -0.072000 -0.760000 0.640000 +0.350000 0.301200 -0.062100 -0.176000 -0.704000 0.680000 +0.350000 0.302200 -0.060900 -0.144000 -0.624000 0.760000 +0.353900 0.301200 -0.060900 -0.128000 -0.544000 0.824000 +0.350000 0.351500 -0.021800 0.032000 -0.048000 0.992000 +0.400000 0.301200 -0.051900 -0.168000 -0.472000 0.856000 +0.400000 0.351500 -0.018700 -0.136000 -0.208000 0.960000 +0.450000 0.301200 -0.039700 -0.448000 -0.256000 0.848000 +0.450000 0.351500 -0.003200 -0.296000 0.344000 0.888000 +0.497900 0.301200 0.000000 -0.728000 -0.144000 0.664000 +0.458200 0.351500 0.000000 -0.280000 0.520000 0.800000 +0.500000 0.301200 0.002700 -0.768000 -0.080000 0.624000 +0.500000 0.351500 0.029100 -0.680000 0.048000 0.728000 +0.526500 0.301200 0.060900 -0.896000 0.008000 0.432000 +0.540600 0.351500 0.060900 -0.584000 0.632000 0.496000 +0.538800 0.301200 0.121900 -0.912000 0.128000 0.376000 +0.550000 0.351500 0.078000 -0.616000 0.672000 0.392000 +0.550000 0.331800 0.121900 -0.696000 0.536000 0.456000 +0.566500 0.351500 0.121900 -0.632000 0.576000 0.496000 +0.550000 0.301200 0.149100 -0.896000 -0.096000 0.416000 +0.600000 0.351500 0.157200 -0.376000 0.584000 0.704000 +0.577700 0.301200 0.182900 -0.536000 0.272000 0.792000 +0.600000 0.327100 0.182900 -0.144000 0.552000 0.816000 +0.600000 0.351500 0.157200 -0.376000 0.584000 0.704000 +0.650000 0.311500 0.182900 0.424000 0.496000 0.752000 +0.650000 0.351500 0.128300 0.616000 0.616000 0.480000 +0.650000 0.351500 0.128300 0.616000 0.616000 0.480000 +0.586200 0.251000 0.182900 -0.672000 -0.144000 0.720000 +0.586200 0.251000 0.182900 -0.672000 -0.144000 0.720000 +0.600000 0.251000 0.198700 -0.584000 -0.144000 0.792000 +0.600000 0.211800 0.182900 -0.672000 -0.280000 0.672000 +0.650000 0.251000 0.217300 -0.016000 0.232000 0.968000 +0.604600 0.200800 0.182900 -0.672000 -0.288000 0.664000 +0.650000 0.200800 0.219700 -0.496000 -0.256000 0.824000 +0.641000 0.150600 0.182900 -0.528000 -0.464000 0.696000 +0.650000 0.150600 0.191100 -0.504000 -0.472000 0.720000 +0.650000 0.141000 0.182900 -0.512000 -0.488000 0.704000 +0.700000 0.150600 0.220800 -0.264000 -0.416000 0.864000 +0.685300 0.100400 0.182900 -0.504000 -0.560000 0.648000 +0.700000 0.100400 0.197200 -0.456000 -0.560000 0.680000 +0.700000 0.088000 0.182900 -0.464000 -0.608000 0.640000 +0.750000 0.100400 0.207000 0.032000 -0.192000 0.976000 +0.750000 0.062100 0.182900 -0.416000 -0.632000 0.648000 +0.800000 0.100400 0.199400 -0.032000 0.024000 0.992000 +0.762700 0.050200 0.182900 -0.512000 -0.672000 0.520000 +0.800000 0.050200 0.211000 -0.336000 -0.552000 0.752000 +0.800000 0.035400 0.182900 -0.432000 -0.808000 0.384000 +0.850000 0.050200 0.216300 -0.184000 -0.272000 0.936000 +0.846600 0.000000 0.182900 -0.736000 -0.616000 0.264000 +0.850000 0.000000 0.194300 -0.704000 -0.640000 0.296000 +0.850000 -0.004200 0.182900 -0.720000 -0.616000 0.288000 +0.900000 0.000000 0.237100 -0.176000 -0.616000 0.760000 +0.880500 -0.050200 0.182900 -0.744000 -0.528000 0.384000 +0.900000 -0.050200 0.230400 -0.448000 -0.568000 0.680000 +0.900000 -0.076800 0.182900 -0.504000 -0.624000 0.592000 +0.950000 -0.050200 0.197900 0.336000 -0.192000 0.920000 +0.934300 -0.100400 0.182900 -0.392000 -0.752000 0.520000 +0.950000 -0.100400 0.196500 0.208000 -0.704000 0.672000 +0.950000 -0.108800 0.182900 0.232000 -0.768000 0.584000 +0.934300 -0.100400 0.182900 -0.392000 -0.752000 0.520000 +0.950000 -0.142500 0.121900 -0.608000 -0.672000 0.392000 +0.900000 -0.100400 0.145900 -0.608000 -0.728000 0.304000 +0.900000 -0.107100 0.121900 -0.584000 -0.768000 0.240000 +0.892500 -0.100400 0.121900 -0.688000 -0.680000 0.240000 +0.900000 -0.117100 0.060900 -0.656000 -0.736000 0.136000 +0.881900 -0.100400 0.060900 -0.752000 -0.632000 0.152000 +0.900000 -0.125700 0.000000 -0.664000 -0.728000 0.136000 +0.873300 -0.100400 0.000000 -0.752000 -0.632000 0.120000 +0.900000 -0.135500 -0.060900 -0.672000 -0.712000 0.168000 +0.865600 -0.100400 -0.060900 -0.776000 -0.616000 0.120000 +0.900000 -0.148200 -0.121900 -0.664000 -0.728000 0.088000 +0.858300 -0.100400 -0.121900 -0.792000 -0.600000 0.056000 +0.900000 -0.150600 -0.145400 -0.696000 -0.704000 0.104000 +0.858100 -0.100400 -0.182900 -0.824000 -0.552000 0.000000 +0.895100 -0.150600 -0.182900 -0.744000 -0.648000 0.104000 +0.860900 -0.100400 -0.243900 -0.856000 -0.496000 -0.072000 +0.890800 -0.150600 -0.243900 -0.848000 -0.512000 0.064000 +0.869700 -0.100400 -0.304800 -0.880000 -0.248000 -0.400000 +0.883200 -0.150600 -0.304800 -0.864000 -0.368000 -0.320000 +0.890800 -0.150600 -0.243900 -0.848000 -0.512000 0.064000 +0.900000 -0.181100 -0.304800 -0.768000 -0.440000 -0.448000 +0.900000 -0.163000 -0.243900 -0.816000 -0.552000 0.128000 +0.911900 -0.200800 -0.304800 -0.864000 -0.480000 -0.128000 +0.928800 -0.200800 -0.243900 -0.736000 -0.616000 0.240000 +0.942100 -0.251000 -0.304800 -0.752000 -0.552000 0.344000 +0.950000 -0.224400 -0.243900 -0.688000 -0.640000 0.328000 +0.950000 -0.251000 -0.295200 -0.640000 -0.496000 0.576000 +0.942100 -0.251000 -0.304800 -0.752000 -0.552000 0.344000 +0.950000 -0.261400 -0.304800 -0.752000 -0.584000 0.288000 +0.950000 -0.261400 -0.304800 -0.752000 -0.584000 0.288000 +0.650000 0.251000 0.217300 -0.016000 0.232000 0.968000 +0.650000 0.251000 0.217300 -0.016000 0.232000 0.968000 +0.600000 0.251000 0.198700 -0.584000 -0.144000 0.792000 +0.650000 0.301200 0.190400 0.408000 0.464000 0.776000 +0.600000 0.301200 0.199900 -0.528000 0.136000 0.832000 +0.600000 0.301200 0.199900 -0.528000 0.136000 0.832000 +0.700000 0.251000 0.193900 0.488000 0.504000 0.704000 +0.700000 0.251000 0.193900 0.488000 0.504000 0.704000 +0.650000 0.251000 0.217300 -0.016000 0.232000 0.968000 +0.700000 0.200800 0.226400 0.328000 0.432000 0.832000 +0.650000 0.200800 0.219700 -0.496000 -0.256000 0.824000 +0.700000 0.150600 0.220800 -0.264000 -0.416000 0.864000 +0.650000 0.150600 0.191100 -0.504000 -0.472000 0.720000 +0.650000 0.150600 0.191100 -0.504000 -0.472000 0.720000 +0.750000 0.200800 0.191100 0.424000 0.552000 0.712000 +0.750000 0.200800 0.191100 0.424000 0.552000 0.712000 +0.700000 0.200800 0.226400 0.328000 0.432000 0.832000 +0.750000 0.150600 0.201100 0.320000 0.240000 0.912000 +0.700000 0.150600 0.220800 -0.264000 -0.416000 0.864000 +0.750000 0.100400 0.207000 0.032000 -0.192000 0.976000 +0.700000 0.100400 0.197200 -0.456000 -0.560000 0.680000 +0.700000 0.100400 0.197200 -0.456000 -0.560000 0.680000 +0.850000 0.050200 0.216300 -0.184000 -0.272000 0.936000 +0.850000 0.050200 0.216300 -0.184000 -0.272000 0.936000 +0.800000 0.050200 0.211000 -0.336000 -0.552000 0.752000 +0.850000 0.100400 0.222500 0.440000 0.584000 0.672000 +0.800000 0.100400 0.199400 -0.032000 0.024000 0.992000 +0.800000 0.100400 0.199400 -0.032000 0.024000 0.992000 +0.900000 0.000000 0.237100 -0.176000 -0.616000 0.760000 +0.900000 0.000000 0.237100 -0.176000 -0.616000 0.760000 +0.850000 0.000000 0.194300 -0.704000 -0.640000 0.296000 +0.900000 0.050200 0.226800 0.488000 0.496000 0.712000 +0.850000 0.050200 0.216300 -0.184000 -0.272000 0.936000 +0.850000 0.050200 0.216300 -0.184000 -0.272000 0.936000 +0.950000 -0.050200 0.197900 0.336000 -0.192000 0.920000 +0.950000 -0.050200 0.197900 0.336000 -0.192000 0.920000 +0.900000 -0.050200 0.230400 -0.448000 -0.568000 0.680000 +0.950000 0.000000 0.206500 0.400000 0.008000 0.912000 +0.900000 0.000000 0.237100 -0.176000 -0.616000 0.760000 +0.900000 0.000000 0.237100 -0.176000 -0.616000 0.760000 +-0.950000 0.150600 0.154300 0.208000 0.640000 0.736000 +-0.950000 0.150600 0.154300 0.208000 0.640000 0.736000 +-0.900000 0.150600 0.126400 0.344000 0.632000 0.688000 +-0.950000 0.178500 0.121900 0.272000 0.648000 0.704000 +-0.900000 0.154600 0.121900 0.352000 0.624000 0.688000 +-0.950000 0.200800 0.096100 0.208000 0.672000 0.704000 +-0.900000 0.200800 0.074800 0.296000 0.712000 0.624000 +-0.950000 0.226300 0.060900 0.264000 0.760000 0.584000 +-0.900000 0.210300 0.060900 0.312000 0.744000 0.576000 +-0.950000 0.251000 0.016800 0.288000 0.808000 0.504000 +-0.900000 0.240500 0.000000 0.368000 0.840000 0.376000 +-0.928700 0.251000 0.000000 0.312000 0.848000 0.408000 +-0.900000 0.251000 -0.035000 0.384000 0.864000 0.312000 +-0.950000 0.258900 0.000000 0.296000 0.848000 0.432000 +-0.900000 0.258900 -0.060900 0.400000 0.896000 0.144000 +-0.950000 0.277400 -0.060900 0.336000 0.928000 0.080000 +-0.900000 0.251000 -0.101700 0.376000 0.896000 -0.216000 +-0.950000 0.267200 -0.121900 0.344000 0.864000 -0.336000 +-0.910500 0.251000 -0.121900 0.344000 0.880000 -0.304000 +-0.950000 0.251000 -0.157200 0.320000 0.808000 -0.480000 +-0.900000 0.246900 -0.121900 0.360000 0.872000 -0.304000 +-0.950000 0.237800 -0.182900 0.296000 0.760000 -0.568000 +-0.900000 0.214200 -0.182900 0.360000 0.720000 -0.576000 +-0.950000 0.200800 -0.231900 0.272000 0.640000 -0.704000 +-0.900000 0.200800 -0.201400 0.352000 0.680000 -0.640000 +-0.950000 0.189400 -0.243900 0.264000 0.616000 -0.728000 +-0.900000 0.162400 -0.243900 0.336000 0.616000 -0.704000 +-0.950000 0.150600 -0.281200 0.240000 0.600000 -0.752000 +-0.900000 0.150600 -0.256300 0.328000 0.616000 -0.704000 +-0.950000 0.126000 -0.304800 0.168000 0.528000 -0.824000 +-0.900000 0.104600 -0.304800 0.304000 0.568000 -0.760000 +-0.950000 0.100400 -0.325900 0.192000 0.384000 -0.896000 +-0.900000 0.100400 -0.308600 0.312000 0.536000 -0.776000 +-0.950000 0.050200 -0.340200 0.184000 0.072000 -0.976000 +-0.900000 0.050200 -0.331200 0.320000 0.232000 -0.912000 +-0.950000 0.000000 -0.337100 0.184000 -0.088000 -0.976000 +-0.900000 0.000000 -0.328400 0.216000 0.000000 -0.968000 +-0.950000 -0.050200 -0.337400 0.088000 0.008000 -0.992000 +-0.900000 -0.050200 -0.330000 0.160000 0.128000 -0.976000 +-0.900000 0.000000 -0.328400 0.216000 0.000000 -0.968000 +-0.850000 -0.050200 -0.323400 0.248000 0.176000 -0.944000 +-0.850000 0.000000 -0.313800 0.264000 0.064000 -0.960000 +-0.808200 -0.050200 -0.304800 0.280000 0.136000 -0.944000 +-0.823600 0.000000 -0.304800 0.296000 0.080000 -0.944000 +-0.800000 -0.050200 -0.302200 0.264000 0.120000 -0.952000 +-0.800000 0.000000 -0.298500 0.248000 0.080000 -0.960000 +-0.750000 -0.050200 -0.287100 0.288000 0.040000 -0.952000 +-0.750000 0.000000 -0.285200 0.328000 0.160000 -0.920000 +-0.700000 -0.050200 -0.272000 0.360000 0.104000 -0.920000 +-0.700000 0.000000 -0.262900 0.392000 0.288000 -0.864000 +-0.650000 -0.050200 -0.249300 0.496000 0.208000 -0.840000 +-0.669700 0.000000 -0.243900 0.480000 0.312000 -0.808000 +-0.650000 -0.035200 -0.243900 0.544000 0.264000 -0.792000 +-0.650000 0.000000 -0.224600 0.632000 0.368000 -0.672000 +-0.642900 -0.050200 -0.243900 0.560000 0.208000 -0.792000 +-0.621400 0.000000 -0.182900 0.848000 0.280000 -0.440000 +-0.606100 -0.050200 -0.182900 0.864000 0.248000 -0.424000 +-0.606100 -0.050200 -0.182900 0.864000 0.248000 -0.424000 +-0.950000 0.127100 0.182900 0.248000 0.536000 0.800000 +-0.950000 0.127100 0.182900 0.248000 0.536000 0.800000 +-0.950000 0.150600 0.154300 0.208000 0.640000 0.736000 +-0.900000 0.101900 0.182900 0.304000 0.552000 0.768000 +-0.900000 0.150600 0.126400 0.344000 0.632000 0.688000 +-0.900000 0.150600 0.126400 0.344000 0.632000 0.688000 +-0.939400 -0.100400 0.121900 -0.456000 -0.816000 0.336000 +-0.939400 -0.100400 0.121900 -0.456000 -0.816000 0.336000 +-0.900000 -0.100400 0.174900 -0.400000 -0.624000 0.656000 +-0.900000 -0.127600 0.121900 -0.608000 -0.704000 0.344000 +-0.900000 -0.127600 0.121900 -0.608000 -0.704000 0.344000 +-0.900000 0.150600 0.126400 0.344000 0.632000 0.688000 +-0.900000 0.150600 0.126400 0.344000 0.632000 0.688000 +-0.900000 0.154600 0.121900 0.352000 0.624000 0.688000 +-0.892900 0.150600 0.121900 0.360000 0.624000 0.680000 +-0.900000 0.200800 0.074800 0.296000 0.712000 0.624000 +-0.850000 0.150600 0.098600 0.360000 0.600000 0.704000 +-0.879600 0.200800 0.060900 0.352000 0.712000 0.600000 +-0.850000 0.184100 0.060900 0.376000 0.632000 0.664000 +-0.850000 0.200800 0.035600 0.384000 0.744000 0.536000 +-0.800000 0.153700 0.060900 0.432000 0.632000 0.632000 +-0.811000 0.200800 0.000000 0.408000 0.816000 0.392000 +-0.800000 0.195100 0.000000 0.456000 0.768000 0.432000 +-0.800000 0.200800 -0.016800 0.416000 0.840000 0.336000 +-0.750000 0.162200 0.000000 0.464000 0.672000 0.560000 +-0.768900 0.200800 -0.060900 0.424000 0.888000 0.160000 +-0.750000 0.191300 -0.060900 0.496000 0.856000 0.072000 +-0.800000 0.200800 -0.113900 0.392000 0.880000 -0.256000 +-0.750000 0.174400 -0.121900 0.448000 0.824000 -0.336000 +-0.800000 0.198900 -0.121900 0.384000 0.872000 -0.288000 +-0.750000 0.150600 -0.159200 0.432000 0.664000 -0.600000 +-0.800000 0.163000 -0.182900 0.392000 0.688000 -0.600000 +-0.779100 0.150600 -0.182900 0.400000 0.664000 -0.616000 +-0.800000 0.150600 -0.199200 0.384000 0.648000 -0.648000 +-0.750000 0.132600 -0.182900 0.408000 0.656000 -0.624000 +-0.800000 0.108800 -0.243900 0.352000 0.608000 -0.704000 +-0.750000 0.100400 -0.222000 0.432000 0.576000 -0.680000 +-0.785800 0.100400 -0.243900 0.360000 0.584000 -0.720000 +-0.750000 0.077000 -0.243900 0.368000 0.552000 -0.744000 +-0.800000 0.100400 -0.252800 0.360000 0.584000 -0.720000 +-0.750000 0.050200 -0.267100 0.368000 0.432000 -0.816000 +-0.800000 0.050200 -0.288900 0.352000 0.360000 -0.856000 +-0.750000 0.000000 -0.285200 0.328000 0.160000 -0.920000 +-0.800000 0.000000 -0.298500 0.248000 0.080000 -0.960000 +-0.800000 0.050200 -0.288900 0.352000 0.360000 -0.856000 +-0.823600 0.000000 -0.304800 0.296000 0.080000 -0.944000 +-0.836500 0.050200 -0.304800 0.336000 0.344000 -0.872000 +-0.850000 0.000000 -0.313800 0.264000 0.064000 -0.960000 +-0.850000 0.050200 -0.311100 0.336000 0.328000 -0.872000 +-0.900000 0.000000 -0.328400 0.216000 0.000000 -0.968000 +-0.900000 0.050200 -0.331200 0.320000 0.232000 -0.912000 +-0.850000 0.050200 -0.311100 0.336000 0.328000 -0.872000 +-0.900000 0.100400 -0.308600 0.312000 0.536000 -0.776000 +-0.850000 0.061400 -0.304800 0.336000 0.392000 -0.848000 +-0.892300 0.100400 -0.304800 0.320000 0.536000 -0.776000 +-0.850000 0.100400 -0.281200 0.344000 0.488000 -0.792000 +-0.900000 0.104600 -0.304800 0.304000 0.568000 -0.760000 +-0.850000 0.135500 -0.243900 0.320000 0.608000 -0.712000 +-0.900000 0.150600 -0.256300 0.328000 0.616000 -0.704000 +-0.878700 0.150600 -0.243900 0.328000 0.616000 -0.704000 +-0.900000 0.162400 -0.243900 0.336000 0.616000 -0.704000 +-0.850000 0.150600 -0.229000 0.320000 0.608000 -0.720000 +-0.900000 0.200800 -0.201400 0.352000 0.680000 -0.640000 +-0.850000 0.188600 -0.182900 0.360000 0.712000 -0.592000 +-0.874200 0.200800 -0.182900 0.360000 0.712000 -0.584000 +-0.850000 0.200800 -0.163600 0.360000 0.768000 -0.512000 +-0.900000 0.214200 -0.182900 0.360000 0.720000 -0.576000 +-0.850000 0.222300 -0.121900 0.408000 0.856000 -0.296000 +-0.900000 0.246900 -0.121900 0.360000 0.872000 -0.304000 +-0.850000 0.235300 -0.060900 0.408000 0.904000 0.008000 +-0.900000 0.251000 -0.101700 0.376000 0.896000 -0.216000 +-0.884300 0.251000 -0.060900 0.432000 0.880000 0.144000 +-0.900000 0.258900 -0.060900 0.400000 0.896000 0.144000 +-0.900000 0.251000 -0.035000 0.384000 0.864000 0.312000 +-0.884300 0.251000 -0.060900 0.432000 0.880000 0.144000 +-0.900000 0.240500 0.000000 0.368000 0.840000 0.376000 +-0.850000 0.235300 -0.060900 0.408000 0.904000 0.008000 +-0.850000 0.219100 0.000000 0.368000 0.824000 0.424000 +-0.800000 0.214400 -0.060900 0.400000 0.896000 0.176000 +-0.811000 0.200800 0.000000 0.408000 0.816000 0.392000 +-0.800000 0.200800 -0.016800 0.416000 0.840000 0.336000 +-0.800000 0.214400 -0.060900 0.400000 0.896000 0.176000 +-0.768900 0.200800 -0.060900 0.424000 0.888000 0.160000 +-0.800000 0.200800 -0.113900 0.392000 0.880000 -0.256000 +-0.800000 0.214400 -0.060900 0.400000 0.896000 0.176000 +-0.804300 0.200800 -0.121900 0.384000 0.872000 -0.288000 +-0.850000 0.235300 -0.060900 0.408000 0.904000 0.008000 +-0.850000 0.222300 -0.121900 0.408000 0.856000 -0.296000 +-0.804300 0.200800 -0.121900 0.384000 0.872000 -0.288000 +-0.850000 0.200800 -0.163600 0.360000 0.768000 -0.512000 +-0.800000 0.198900 -0.121900 0.384000 0.872000 -0.288000 +-0.850000 0.188600 -0.182900 0.360000 0.712000 -0.592000 +-0.800000 0.163000 -0.182900 0.392000 0.688000 -0.600000 +-0.850000 0.150600 -0.229000 0.320000 0.608000 -0.720000 +-0.800000 0.150600 -0.199200 0.384000 0.648000 -0.648000 +-0.850000 0.135500 -0.243900 0.320000 0.608000 -0.712000 +-0.800000 0.108800 -0.243900 0.352000 0.608000 -0.704000 +-0.850000 0.100400 -0.281200 0.344000 0.488000 -0.792000 +-0.800000 0.100400 -0.252800 0.360000 0.584000 -0.720000 +-0.850000 0.061400 -0.304800 0.336000 0.392000 -0.848000 +-0.800000 0.050200 -0.288900 0.352000 0.360000 -0.856000 +-0.836500 0.050200 -0.304800 0.336000 0.344000 -0.872000 +-0.850000 0.061400 -0.304800 0.336000 0.392000 -0.848000 +-0.850000 0.050200 -0.311100 0.336000 0.328000 -0.872000 +-0.850000 0.050200 -0.311100 0.336000 0.328000 -0.872000 +-0.850000 0.127100 0.121900 0.424000 0.560000 0.704000 +-0.850000 0.127100 0.121900 0.424000 0.560000 0.704000 +-0.820700 0.100400 0.121900 0.496000 0.488000 0.704000 +-0.850000 0.100400 0.150400 0.488000 0.512000 0.696000 +-0.850000 0.100400 0.150400 0.488000 0.512000 0.696000 +-0.839600 0.000000 0.182900 0.264000 0.152000 0.944000 +-0.839600 0.000000 0.182900 0.264000 0.152000 0.944000 +-0.809300 -0.050200 0.182900 0.232000 0.160000 0.952000 +-0.800000 0.000000 0.163200 0.400000 0.288000 0.864000 +-0.800000 -0.050200 0.179900 0.264000 0.176000 0.944000 +-0.750000 0.000000 0.129400 0.496000 0.360000 0.776000 +-0.750000 -0.050200 0.155100 0.464000 0.288000 0.832000 +-0.740500 0.000000 0.121900 0.504000 0.352000 0.784000 +-0.708600 -0.050200 0.121900 0.496000 0.344000 0.784000 +-0.700000 0.000000 0.089700 0.584000 0.336000 0.736000 +-0.700000 -0.050200 0.115300 0.496000 0.344000 0.792000 +-0.666100 0.000000 0.060900 0.560000 0.376000 0.728000 +-0.650000 -0.050200 0.076400 0.576000 0.320000 0.744000 +-0.650000 -0.023500 0.060900 0.576000 0.360000 0.720000 +-0.635700 -0.050200 0.060900 0.640000 0.304000 0.696000 +-0.650000 0.000000 0.045200 0.576000 0.400000 0.704000 +-0.600000 -0.050200 0.018400 0.648000 0.320000 0.688000 +-0.609800 0.000000 0.000000 0.696000 0.384000 0.592000 +-0.600000 -0.018300 0.000000 0.712000 0.368000 0.584000 +-0.600000 0.000000 -0.017800 0.736000 0.384000 0.544000 +-0.584800 -0.050200 0.000000 0.744000 0.336000 0.568000 +-0.573200 0.000000 -0.060900 0.920000 0.296000 -0.248000 +-0.554400 -0.050200 -0.060900 0.944000 0.280000 0.128000 +-0.554400 -0.050200 -0.060900 0.944000 0.280000 0.128000 +-0.800000 -0.063400 0.182900 0.240000 0.160000 0.952000 +-0.800000 -0.063400 0.182900 0.240000 0.160000 0.952000 +-0.809300 -0.050200 0.182900 0.232000 0.160000 0.952000 +-0.800000 -0.050200 0.179900 0.264000 0.176000 0.944000 +-0.800000 -0.050200 0.179900 0.264000 0.176000 0.944000 +-0.850000 -0.137400 0.182900 -0.304000 -0.312000 0.896000 +-0.850000 -0.137400 0.182900 -0.304000 -0.312000 0.896000 +-0.836800 -0.150600 0.182900 -0.304000 -0.304000 0.896000 +-0.850000 -0.150600 0.175600 -0.632000 -0.392000 0.664000 +-0.803100 -0.200800 0.182900 -0.456000 -0.168000 0.864000 +-0.850000 -0.200800 0.125700 -0.776000 -0.360000 0.504000 +-0.850000 -0.200800 0.125700 -0.776000 -0.360000 0.504000 +-0.800000 -0.251000 0.157900 -0.576000 -0.400000 0.696000 +-0.800000 -0.251000 0.157900 -0.576000 -0.400000 0.696000 +-0.800000 -0.280700 0.121900 -0.736000 -0.528000 0.408000 +-0.819200 -0.251000 0.121900 -0.760000 -0.496000 0.400000 +-0.800000 -0.301200 0.085900 -0.768000 -0.544000 0.304000 +-0.838400 -0.251000 0.060900 -0.808000 -0.528000 0.248000 +-0.805900 -0.301200 0.060900 -0.800000 -0.536000 0.232000 +-0.800000 -0.301200 0.085900 -0.768000 -0.544000 0.304000 +-0.800000 -0.310100 0.060900 -0.800000 -0.544000 0.224000 +-0.805900 -0.301200 0.060900 -0.800000 -0.536000 0.232000 +-0.800000 -0.327900 0.000000 -0.800000 -0.560000 0.176000 +-0.817700 -0.301200 0.000000 -0.808000 -0.560000 0.168000 +-0.817700 -0.301200 0.000000 -0.808000 -0.560000 0.168000 +-0.800000 0.077200 0.121900 0.512000 0.416000 0.744000 +-0.800000 0.077200 0.121900 0.512000 0.416000 0.744000 +-0.781300 0.050200 0.121900 0.536000 0.400000 0.736000 +-0.800000 0.050200 0.139800 0.504000 0.392000 0.760000 +-0.800000 0.050200 0.139800 0.504000 0.392000 0.760000 +-0.776900 -0.100400 0.182900 0.184000 0.120000 0.968000 +-0.776900 -0.100400 0.182900 0.184000 0.120000 0.968000 +-0.750000 -0.100400 0.174700 0.320000 0.192000 0.920000 +-0.750000 -0.136500 0.182900 0.216000 0.112000 0.968000 +-0.700000 -0.100400 0.138900 0.488000 0.288000 0.816000 +-0.743500 -0.150600 0.182900 0.192000 0.096000 0.968000 +-0.700000 -0.150600 0.164200 0.408000 0.248000 0.872000 +-0.703900 -0.200800 0.182900 0.128000 0.064000 0.984000 +-0.700000 -0.200800 0.182200 0.152000 0.072000 0.984000 +-0.700000 -0.208700 0.182900 0.176000 0.120000 0.968000 +-0.650000 -0.200800 0.153500 0.376000 0.280000 0.872000 +-0.650000 -0.249200 0.182900 0.176000 0.464000 0.864000 +-0.600000 -0.200800 0.130000 0.152000 0.560000 0.808000 +-0.638500 -0.251000 0.182900 0.072000 0.424000 0.896000 +-0.600000 -0.251000 0.177800 0.080000 0.520000 0.840000 +-0.600000 -0.260000 0.182900 0.056000 0.320000 0.944000 +-0.550000 -0.251000 0.173600 -0.016000 0.472000 0.872000 +-0.550000 -0.264400 0.182900 -0.072000 0.456000 0.880000 +-0.512000 -0.251000 0.182900 -0.112000 0.632000 0.760000 +-0.550000 -0.251000 0.173600 -0.016000 0.472000 0.872000 +-0.500000 -0.249000 0.182900 -0.112000 0.656000 0.744000 +-0.550000 -0.202900 0.121900 0.032000 0.728000 0.680000 +-0.500000 -0.200800 0.127000 -0.088000 0.600000 0.784000 +-0.536800 -0.200800 0.121900 -0.104000 0.736000 0.664000 +-0.500000 -0.196200 0.121900 -0.112000 0.784000 0.600000 +-0.550000 -0.200800 0.118700 0.032000 0.784000 0.608000 +-0.500000 -0.166600 0.060900 -0.304000 0.832000 0.448000 +-0.550000 -0.166800 0.060900 0.264000 0.816000 0.504000 +-0.500000 -0.150600 0.019400 -0.216000 0.856000 0.464000 +-0.550000 -0.150600 0.029600 0.504000 0.688000 0.512000 +-0.500000 -0.141000 0.000000 -0.040000 0.880000 0.456000 +-0.550000 -0.125000 0.000000 0.608000 0.616000 0.488000 +-0.500000 -0.119500 -0.060900 -0.160000 0.976000 0.112000 +-0.550000 -0.100400 -0.036900 0.792000 0.376000 0.464000 +-0.533200 -0.100400 -0.060900 0.712000 0.696000 -0.024000 +-0.533200 -0.100400 -0.060900 0.712000 0.696000 -0.024000 +-0.750000 -0.267900 0.182900 -0.232000 -0.192000 0.944000 +-0.750000 -0.267900 0.182900 -0.232000 -0.192000 0.944000 +-0.750000 -0.301200 0.168400 -0.360000 -0.432000 0.816000 +-0.700000 -0.272200 0.182900 -0.072000 -0.128000 0.984000 +-0.700000 -0.301200 0.175400 -0.248000 -0.280000 0.920000 +-0.671000 -0.301200 0.182900 -0.120000 -0.104000 0.984000 +-0.700000 -0.351500 0.155000 -0.664000 -0.344000 0.656000 +-0.663400 -0.351500 0.182900 -0.304000 -0.080000 0.944000 +-0.700000 -0.401700 0.124500 -0.664000 -0.408000 0.616000 +-0.650000 -0.385200 0.182900 -0.496000 -0.152000 0.848000 +-0.650000 -0.401700 0.178700 -0.552000 -0.344000 0.752000 +-0.644900 -0.401700 0.182900 -0.528000 -0.240000 0.808000 +-0.650000 -0.451900 0.140100 -0.528000 -0.568000 0.624000 +-0.600000 -0.446800 0.182900 -0.240000 -0.464000 0.848000 +-0.600000 -0.451900 0.179400 -0.216000 -0.496000 0.832000 +-0.583500 -0.451900 0.182900 -0.128000 -0.544000 0.824000 +-0.600000 -0.495400 0.121900 -0.392000 -0.720000 0.560000 +-0.550000 -0.456500 0.182900 0.056000 -0.736000 0.672000 +-0.550000 -0.494000 0.121900 0.024000 -0.832000 0.536000 +-0.600000 -0.495400 0.121900 -0.392000 -0.720000 0.560000 +-0.550000 -0.502100 0.104800 0.104000 -0.840000 0.520000 +-0.600000 -0.502100 0.110700 -0.280000 -0.792000 0.528000 +-0.550000 -0.532000 0.060900 0.080000 -0.776000 0.624000 +-0.600000 -0.531600 0.060900 -0.448000 -0.736000 0.496000 +-0.600000 -0.502100 0.110700 -0.280000 -0.792000 0.528000 +-0.640700 -0.502100 0.060900 -0.496000 -0.728000 0.456000 +-0.600000 -0.495400 0.121900 -0.392000 -0.720000 0.560000 +-0.650000 -0.495900 0.060900 -0.528000 -0.720000 0.432000 +-0.650000 -0.463300 0.121900 -0.512000 -0.696000 0.496000 +-0.700000 -0.453200 0.060900 -0.560000 -0.720000 0.392000 +-0.664200 -0.451900 0.121900 -0.552000 -0.696000 0.448000 +-0.700000 -0.451900 0.063700 -0.672000 -0.600000 0.424000 +-0.700000 -0.404000 0.121900 -0.624000 -0.536000 0.560000 +-0.701000 -0.451900 0.060900 -0.792000 -0.480000 0.344000 +-0.701700 -0.401700 0.121900 -0.704000 -0.408000 0.568000 +-0.731300 -0.401700 0.060900 -0.784000 -0.496000 0.344000 +-0.739400 -0.351500 0.121900 -0.528000 -0.576000 0.616000 +-0.750000 -0.377100 0.060900 -0.760000 -0.552000 0.320000 +-0.750000 -0.351500 0.110100 -0.600000 -0.584000 0.536000 +-0.767900 -0.351500 0.060900 -0.760000 -0.568000 0.296000 +-0.767900 -0.351500 0.060900 -0.760000 -0.568000 0.296000 +-0.750000 -0.301200 0.168400 -0.360000 -0.432000 0.816000 +-0.750000 -0.301200 0.168400 -0.360000 -0.432000 0.816000 +-0.700000 -0.301200 0.175400 -0.248000 -0.280000 0.920000 +-0.750000 -0.342500 0.121900 -0.536000 -0.592000 0.592000 +-0.700000 -0.351500 0.155000 -0.664000 -0.344000 0.656000 +-0.739400 -0.351500 0.121900 -0.528000 -0.576000 0.616000 +-0.700000 -0.401700 0.124500 -0.664000 -0.408000 0.616000 +-0.701700 -0.401700 0.121900 -0.704000 -0.408000 0.568000 +-0.700000 -0.404000 0.121900 -0.624000 -0.536000 0.560000 +-0.700000 -0.401700 0.124500 -0.664000 -0.408000 0.616000 +-0.664200 -0.451900 0.121900 -0.552000 -0.696000 0.448000 +-0.650000 -0.401700 0.178700 -0.552000 -0.344000 0.752000 +-0.650000 -0.451900 0.140100 -0.528000 -0.568000 0.624000 +-0.664200 -0.451900 0.121900 -0.552000 -0.696000 0.448000 +-0.650000 -0.463300 0.121900 -0.512000 -0.696000 0.496000 +-0.650000 -0.451900 0.140100 -0.528000 -0.568000 0.624000 +-0.600000 -0.495400 0.121900 -0.392000 -0.720000 0.560000 +-0.600000 -0.451900 0.179400 -0.216000 -0.496000 0.832000 +-0.600000 -0.451900 0.179400 -0.216000 -0.496000 0.832000 +-0.700000 -0.062200 0.121900 0.504000 0.344000 0.784000 +-0.700000 -0.062200 0.121900 0.504000 0.344000 0.784000 +-0.677900 -0.100400 0.121900 0.528000 0.328000 0.776000 +-0.700000 -0.100400 0.138900 0.488000 0.288000 0.816000 +-0.650000 -0.141800 0.121900 0.432000 0.328000 0.832000 +-0.700000 -0.150600 0.164200 0.408000 0.248000 0.872000 +-0.650000 -0.150600 0.126000 0.408000 0.336000 0.840000 +-0.700000 -0.200800 0.182200 0.152000 0.072000 0.984000 +-0.650000 -0.200800 0.153500 0.376000 0.280000 0.872000 +-0.650000 -0.150600 0.126000 0.408000 0.336000 0.840000 +-0.600000 -0.200800 0.130000 0.152000 0.560000 0.808000 +-0.642900 -0.150600 0.121900 0.408000 0.352000 0.832000 +-0.600000 -0.190600 0.121900 0.296000 0.496000 0.808000 +-0.600000 -0.150600 0.080700 0.576000 0.424000 0.688000 +-0.559300 -0.200800 0.121900 0.160000 0.720000 0.672000 +-0.575700 -0.150600 0.060900 0.384000 0.664000 0.632000 +-0.550000 -0.200800 0.118700 0.032000 0.784000 0.608000 +-0.550000 -0.166800 0.060900 0.264000 0.816000 0.504000 +-0.575700 -0.150600 0.060900 0.384000 0.664000 0.632000 +-0.550000 -0.150600 0.029600 0.504000 0.688000 0.512000 +-0.600000 -0.122400 0.060900 0.616000 0.400000 0.664000 +-0.550000 -0.125000 0.000000 0.608000 0.616000 0.488000 +-0.600000 -0.100400 0.044600 0.672000 0.336000 0.656000 +-0.565600 -0.100400 0.000000 0.744000 0.440000 0.496000 +-0.550000 -0.125000 0.000000 0.608000 0.616000 0.488000 +-0.550000 -0.100400 -0.036900 0.792000 0.376000 0.464000 +-0.550000 -0.100400 -0.036900 0.792000 0.376000 0.464000 +-0.650000 -0.150600 0.126000 0.408000 0.336000 0.840000 +-0.650000 -0.150600 0.126000 0.408000 0.336000 0.840000 +-0.650000 -0.141800 0.121900 0.432000 0.328000 0.832000 +-0.642900 -0.150600 0.121900 0.408000 0.352000 0.832000 +-0.650000 -0.100400 0.096100 0.592000 0.288000 0.744000 +-0.600000 -0.150600 0.080700 0.576000 0.424000 0.688000 +-0.612900 -0.100400 0.060900 0.624000 0.376000 0.672000 +-0.600000 -0.122400 0.060900 0.616000 0.400000 0.664000 +-0.600000 -0.100400 0.044600 0.672000 0.336000 0.656000 +-0.600000 -0.100400 0.044600 0.672000 0.336000 0.656000 +-0.600000 -0.190600 0.121900 0.296000 0.496000 0.808000 +-0.600000 -0.190600 0.121900 0.296000 0.496000 0.808000 +-0.559300 -0.200800 0.121900 0.160000 0.720000 0.672000 +-0.600000 -0.200800 0.130000 0.152000 0.560000 0.808000 +-0.550000 -0.202900 0.121900 0.032000 0.728000 0.680000 +-0.600000 -0.251000 0.177800 0.080000 0.520000 0.840000 +-0.550000 -0.251000 0.173600 -0.016000 0.472000 0.872000 +-0.550000 -0.251000 0.173600 -0.016000 0.472000 0.872000 +-0.500000 -0.200800 0.127000 -0.088000 0.600000 0.784000 +-0.500000 -0.200800 0.127000 -0.088000 0.600000 0.784000 +-0.450000 -0.200800 0.150000 -0.304000 0.608000 0.720000 +-0.500000 -0.196200 0.121900 -0.112000 0.784000 0.600000 +-0.450000 -0.173700 0.121900 -0.368000 0.648000 0.656000 +-0.500000 -0.166600 0.060900 -0.304000 0.832000 0.448000 +-0.450000 -0.150600 0.089400 -0.440000 0.744000 0.496000 +-0.472400 -0.150600 0.060900 -0.464000 0.768000 0.416000 +-0.450000 -0.136300 0.060900 -0.512000 0.720000 0.448000 +-0.500000 -0.150600 0.019400 -0.216000 0.856000 0.464000 +-0.450000 -0.112700 0.000000 -0.520000 0.784000 0.320000 +-0.500000 -0.141000 0.000000 -0.040000 0.880000 0.456000 +-0.500000 -0.141000 0.000000 -0.040000 0.880000 0.456000 +-0.500000 -0.200800 0.127000 -0.088000 0.600000 0.784000 +-0.500000 -0.200800 0.127000 -0.088000 0.600000 0.784000 +-0.500000 -0.249000 0.182900 -0.112000 0.656000 0.744000 +-0.450000 -0.200800 0.150000 -0.304000 0.608000 0.720000 +-0.450000 -0.233700 0.182900 -0.216000 0.472000 0.848000 +-0.400000 -0.200800 0.179200 -0.200000 0.464000 0.856000 +-0.400000 -0.206800 0.182900 -0.168000 0.424000 0.880000 +-0.383500 -0.200800 0.182900 -0.152000 0.448000 0.872000 +-0.400000 -0.200800 0.179200 -0.200000 0.464000 0.856000 +-0.350000 -0.189600 0.182900 -0.288000 0.472000 0.824000 +-0.400000 -0.150600 0.133500 -0.392000 0.600000 0.688000 +-0.350000 -0.150600 0.151300 -0.584000 0.352000 0.720000 +-0.350000 -0.189600 0.182900 -0.288000 0.472000 0.824000 +-0.311100 -0.150600 0.182900 -0.424000 0.464000 0.768000 +-0.311100 -0.150600 0.182900 -0.424000 0.464000 0.768000 +-0.400000 -0.200800 0.179200 -0.200000 0.464000 0.856000 +-0.400000 -0.200800 0.179200 -0.200000 0.464000 0.856000 +-0.450000 -0.200800 0.150000 -0.304000 0.608000 0.720000 +-0.400000 -0.150600 0.133500 -0.392000 0.600000 0.688000 +-0.450000 -0.173700 0.121900 -0.368000 0.648000 0.656000 +-0.414900 -0.150600 0.121900 -0.424000 0.616000 0.648000 +-0.450000 -0.150600 0.089400 -0.440000 0.744000 0.496000 +-0.450000 -0.150600 0.089400 -0.440000 0.744000 0.496000 +-0.351400 -0.100400 0.121900 -0.608000 0.368000 0.696000 +-0.351400 -0.100400 0.121900 -0.608000 0.368000 0.696000 +-0.350000 -0.097900 0.121900 -0.560000 0.424000 0.704000 +-0.350000 -0.100400 0.123500 -0.608000 0.328000 0.712000 +-0.300000 -0.066800 0.121900 -0.280000 0.584000 0.752000 +-0.300000 -0.100400 0.149000 -0.304000 0.432000 0.840000 +-0.255700 -0.050200 0.121900 -0.192000 0.512000 0.832000 +-0.250000 -0.100400 0.155000 0.480000 0.160000 0.856000 +-0.250000 -0.050200 0.123600 0.200000 0.440000 0.864000 +-0.250000 -0.050200 0.123600 0.200000 0.440000 0.864000 +-0.369700 -0.301200 0.182900 0.552000 -0.328000 0.752000 +-0.369700 -0.301200 0.182900 0.552000 -0.328000 0.752000 +-0.350000 -0.276800 0.182900 0.600000 -0.432000 0.664000 +-0.350000 -0.301200 0.167500 0.592000 -0.368000 0.712000 +-0.350000 -0.301200 0.167500 0.592000 -0.368000 0.712000 +-0.334800 -0.251000 0.182900 0.672000 -0.480000 0.552000 +-0.334800 -0.251000 0.182900 0.672000 -0.480000 0.552000 +-0.300000 -0.205800 0.182900 0.768000 -0.472000 0.416000 +-0.300000 -0.251000 0.131000 0.632000 -0.616000 0.464000 +-0.300000 -0.251000 0.131000 0.632000 -0.616000 0.464000 +-0.300000 -0.251000 0.131000 0.632000 -0.616000 0.464000 +-0.300000 -0.251000 0.131000 0.632000 -0.616000 0.464000 +-0.294600 -0.251000 0.121900 0.616000 -0.600000 0.488000 +-0.300000 -0.256400 0.121900 0.624000 -0.624000 0.456000 +-0.300000 -0.256400 0.121900 0.624000 -0.624000 0.456000 +0.550000 0.331800 0.121900 -0.696000 0.536000 0.456000 +0.550000 0.331800 0.121900 -0.696000 0.536000 0.456000 +0.550000 0.301200 0.149100 -0.896000 -0.096000 0.416000 +0.538800 0.301200 0.121900 -0.912000 0.128000 0.376000 +0.538800 0.301200 0.121900 -0.912000 0.128000 0.376000 +0.548800 0.251000 0.121900 -0.912000 -0.176000 0.360000 +0.548800 0.251000 0.121900 -0.912000 -0.176000 0.360000 +0.550000 0.251000 0.125100 -0.872000 -0.184000 0.440000 +0.550000 0.246100 0.121900 -0.904000 -0.224000 0.352000 +0.586200 0.251000 0.182900 -0.672000 -0.144000 0.720000 +0.567500 0.200800 0.121900 -0.784000 -0.344000 0.504000 +0.600000 0.211800 0.182900 -0.672000 -0.280000 0.672000 +0.600000 0.200800 0.176700 -0.712000 -0.296000 0.624000 +0.604600 0.200800 0.182900 -0.672000 -0.288000 0.664000 +0.600000 0.150600 0.141200 -0.712000 -0.440000 0.536000 +0.641000 0.150600 0.182900 -0.528000 -0.464000 0.696000 +0.600000 0.134700 0.121900 -0.776000 -0.456000 0.424000 +0.650000 0.141000 0.182900 -0.512000 -0.488000 0.704000 +0.627900 0.100400 0.121900 -0.608000 -0.608000 0.504000 +0.650000 0.100400 0.150000 -0.536000 -0.592000 0.592000 +0.650000 0.080100 0.121900 -0.576000 -0.640000 0.496000 +0.685300 0.100400 0.182900 -0.504000 -0.560000 0.648000 +0.692100 0.050200 0.121900 -0.432000 -0.784000 0.424000 +0.700000 0.088000 0.182900 -0.464000 -0.608000 0.640000 +0.700000 0.050200 0.131500 -0.112000 -0.824000 0.544000 +0.750000 0.062100 0.182900 -0.416000 -0.632000 0.648000 +0.744700 0.050200 0.121900 0.096000 -0.864000 0.480000 +0.750000 0.050900 0.121900 0.096000 -0.792000 0.600000 +0.750000 0.050200 0.120200 -0.160000 -0.904000 0.376000 +0.751700 0.050200 0.121900 -0.392000 -0.816000 0.416000 +0.750000 0.031700 0.060900 -0.136000 -0.928000 0.336000 +0.800000 0.028400 0.121900 -0.376000 -0.808000 0.432000 +0.798100 0.000000 0.060900 -0.504000 -0.792000 0.312000 +0.800000 0.000000 0.064400 -0.576000 -0.736000 0.344000 +0.800000 -0.001000 0.060900 -0.584000 -0.776000 0.216000 +0.829700 0.000000 0.121900 -0.704000 -0.616000 0.344000 +0.843600 -0.050200 0.060900 -0.704000 -0.672000 0.184000 +0.850000 -0.029600 0.121900 -0.840000 -0.432000 0.312000 +0.850000 -0.050200 0.089500 -0.768000 -0.592000 0.216000 +0.857500 -0.050200 0.121900 -0.848000 -0.448000 0.272000 +0.850000 -0.056700 0.060900 -0.720000 -0.664000 0.176000 +0.892500 -0.100400 0.121900 -0.688000 -0.680000 0.240000 +0.881900 -0.100400 0.060900 -0.752000 -0.632000 0.152000 +0.850000 -0.056700 0.060900 -0.720000 -0.664000 0.176000 +0.873300 -0.100400 0.000000 -0.752000 -0.632000 0.120000 +0.850000 -0.068700 0.000000 -0.752000 -0.640000 0.136000 +0.865600 -0.100400 -0.060900 -0.776000 -0.616000 0.120000 +0.850000 -0.079400 -0.060900 -0.768000 -0.616000 0.120000 +0.858300 -0.100400 -0.121900 -0.792000 -0.600000 0.056000 +0.850000 -0.088400 -0.121900 -0.808000 -0.584000 0.016000 +0.858100 -0.100400 -0.182900 -0.824000 -0.552000 0.000000 +0.850000 -0.086900 -0.182900 -0.848000 -0.512000 -0.048000 +0.860900 -0.100400 -0.243900 -0.856000 -0.496000 -0.072000 +0.850000 -0.077200 -0.243900 -0.824000 -0.432000 -0.344000 +0.869700 -0.100400 -0.304800 -0.880000 -0.248000 -0.400000 +0.850000 -0.050200 -0.276700 -0.784000 -0.280000 -0.544000 +0.867300 -0.050200 -0.304800 -0.784000 -0.136000 -0.600000 +0.850000 0.000000 -0.279000 -0.536000 0.488000 -0.680000 +0.877300 0.000000 -0.304800 -0.592000 0.480000 -0.632000 +0.877300 0.000000 -0.304800 -0.592000 0.480000 -0.632000 +0.600000 0.150600 0.141200 -0.712000 -0.440000 0.536000 +0.600000 0.150600 0.141200 -0.712000 -0.440000 0.536000 +0.600000 0.200800 0.176700 -0.712000 -0.296000 0.624000 +0.591100 0.150600 0.121900 -0.792000 -0.400000 0.440000 +0.567500 0.200800 0.121900 -0.784000 -0.344000 0.504000 +0.560700 0.150600 0.060900 -0.704000 -0.368000 0.592000 +0.550000 0.200800 0.086900 -0.880000 -0.256000 0.392000 +0.550000 0.174700 0.060900 -0.744000 -0.320000 0.576000 +0.538800 0.200800 0.060900 -0.824000 -0.216000 0.520000 +0.550000 0.150600 0.048400 -0.632000 -0.416000 0.640000 +0.500000 0.200800 0.008600 -0.576000 -0.176000 0.792000 +0.510200 0.150600 0.000000 -0.752000 -0.384000 0.520000 +0.500000 0.181600 0.000000 -0.600000 -0.304000 0.728000 +0.500000 0.150600 -0.020200 -0.704000 -0.472000 0.520000 +0.488800 0.200800 0.000000 -0.512000 0.024000 0.856000 +0.460500 0.150600 -0.060900 -0.624000 -0.512000 0.584000 +0.450000 0.200800 -0.035500 -0.536000 -0.264000 0.792000 +0.450000 0.163500 -0.060900 -0.600000 -0.504000 0.608000 +0.416500 0.200800 -0.060900 -0.560000 -0.352000 0.744000 +0.450000 0.150600 -0.075000 -0.616000 -0.488000 0.608000 +0.400000 0.200800 -0.077800 -0.600000 -0.432000 0.664000 +0.401900 0.150600 -0.121900 -0.864000 -0.496000 -0.024000 +0.400000 0.152400 -0.121900 -0.688000 -0.712000 -0.048000 +0.407800 0.150600 -0.182900 -0.544000 -0.240000 -0.800000 +0.400000 0.155900 -0.182900 -0.216000 -0.144000 -0.960000 +0.450000 0.150600 -0.187200 -0.088000 0.168000 -0.976000 +0.400000 0.200800 -0.189400 -0.152000 -0.072000 -0.984000 +0.450000 0.200800 -0.192400 -0.128000 -0.040000 -0.984000 +0.400000 0.251000 -0.186400 -0.152000 0.040000 -0.984000 +0.450000 0.251000 -0.188200 -0.104000 0.040000 -0.992000 +0.400000 0.301200 -0.184200 -0.016000 -0.016000 -0.992000 +0.450000 0.301200 -0.186200 0.000000 -0.016000 -0.992000 +0.400000 0.351500 -0.194500 0.000000 0.072000 -0.992000 +0.450000 0.351500 -0.196000 0.120000 0.128000 -0.976000 +0.400000 0.377300 -0.182900 0.016000 0.320000 -0.944000 +0.450000 0.373800 -0.182900 0.104000 0.432000 -0.888000 +0.400000 0.401700 -0.171200 0.088000 0.472000 -0.872000 +0.450000 0.401700 -0.160800 0.376000 0.656000 -0.640000 +0.400000 0.432800 -0.121900 0.160000 0.904000 -0.384000 +0.450000 0.422200 -0.121900 0.368000 0.832000 -0.392000 +0.400000 0.419800 -0.060900 0.080000 0.848000 0.520000 +0.450000 0.414500 -0.060900 0.192000 0.928000 0.304000 +0.400000 0.401700 -0.034800 -0.040000 0.584000 0.808000 +0.450000 0.401700 -0.038900 -0.120000 0.592000 0.784000 +0.400000 0.351500 -0.018700 -0.136000 -0.208000 0.960000 +0.450000 0.351500 -0.003200 -0.296000 0.344000 0.888000 +0.450000 0.401700 -0.038900 -0.120000 0.592000 0.784000 +0.458200 0.351500 0.000000 -0.280000 0.520000 0.800000 +0.500000 0.401700 -0.057700 0.096000 0.864000 0.480000 +0.500000 0.369100 0.000000 -0.184000 0.800000 0.552000 +0.517100 0.401700 -0.060900 0.080000 0.968000 0.224000 +0.550000 0.388900 0.000000 -0.392000 0.856000 0.320000 +0.550000 0.398000 -0.060900 0.000000 0.968000 -0.216000 +0.517100 0.401700 -0.060900 0.080000 0.968000 0.224000 +0.550000 0.362300 -0.121900 0.400000 0.656000 -0.632000 +0.500000 0.401700 -0.069300 0.168000 0.952000 -0.216000 +0.500000 0.393600 -0.121900 0.504000 0.744000 -0.432000 +0.488600 0.401700 -0.121900 0.504000 0.776000 -0.368000 +0.500000 0.355500 -0.182900 0.400000 0.616000 -0.664000 +0.450000 0.401700 -0.160800 0.376000 0.656000 -0.640000 +0.450000 0.373800 -0.182900 0.104000 0.432000 -0.888000 +0.500000 0.355500 -0.182900 0.400000 0.616000 -0.664000 +0.450000 0.351500 -0.196000 0.120000 0.128000 -0.976000 +0.500000 0.351500 -0.187300 0.416000 0.568000 -0.696000 +0.450000 0.301200 -0.186200 0.000000 -0.016000 -0.992000 +0.500000 0.301200 -0.193500 0.168000 0.072000 -0.976000 +0.450000 0.251000 -0.188200 -0.104000 0.040000 -0.992000 +0.500000 0.251000 -0.199400 0.072000 0.096000 -0.984000 +0.450000 0.200800 -0.192400 -0.128000 -0.040000 -0.984000 +0.500000 0.200800 -0.200200 -0.104000 -0.048000 -0.992000 +0.450000 0.150600 -0.187200 -0.088000 0.168000 -0.976000 +0.500000 0.150600 -0.194400 -0.208000 0.240000 -0.944000 +0.450000 0.100400 -0.233000 -0.008000 0.816000 -0.568000 +0.500000 0.100400 -0.210700 0.048000 0.704000 -0.704000 +0.450000 0.095300 -0.243900 -0.008000 0.856000 -0.512000 +0.500000 0.082500 -0.243900 0.216000 0.832000 -0.504000 +0.450000 0.055500 -0.304800 0.064000 0.864000 -0.496000 +0.500000 0.050200 -0.303800 0.264000 0.816000 -0.504000 +0.496000 0.050200 -0.304800 0.104000 0.800000 -0.576000 +0.500000 0.049600 -0.304800 0.264000 0.736000 -0.616000 +0.450000 0.050200 -0.314200 0.064000 0.744000 -0.656000 +0.500000 0.014000 -0.365800 0.216000 0.784000 -0.568000 +0.450000 0.007700 -0.365800 -0.264000 0.744000 -0.600000 +0.500000 0.000000 -0.393700 0.528000 0.072000 -0.840000 +0.450000 0.000000 -0.377000 -0.360000 0.400000 -0.840000 +0.500000 -0.027200 -0.365800 0.264000 -0.576000 -0.768000 +0.450000 -0.014200 -0.365800 -0.336000 -0.568000 -0.744000 +0.500000 -0.050200 -0.339600 -0.136000 -0.672000 -0.720000 +0.450000 -0.050200 -0.325200 -0.120000 -0.568000 -0.808000 +0.450000 -0.014200 -0.365800 -0.336000 -0.568000 -0.744000 +0.400000 -0.050200 -0.360800 0.184000 -0.432000 -0.872000 +0.431500 0.000000 -0.365800 -0.424000 0.312000 -0.840000 +0.400000 0.000000 -0.343200 -0.216000 0.592000 -0.768000 +0.450000 0.007700 -0.365800 -0.264000 0.744000 -0.600000 +0.400000 0.041200 -0.304800 -0.352000 0.672000 -0.648000 +0.450000 0.050200 -0.314200 0.064000 0.744000 -0.656000 +0.419200 0.050200 -0.304800 -0.224000 0.736000 -0.632000 +0.450000 0.055500 -0.304800 0.064000 0.864000 -0.496000 +0.400000 0.050200 -0.294000 -0.352000 0.672000 -0.640000 +0.450000 0.095300 -0.243900 -0.008000 0.856000 -0.512000 +0.400000 0.083700 -0.243900 -0.328000 0.768000 -0.536000 +0.450000 0.100400 -0.233000 -0.008000 0.816000 -0.568000 +0.400000 0.100400 -0.207800 -0.424000 0.688000 -0.576000 +0.450000 0.150600 -0.187200 -0.088000 0.168000 -0.976000 +0.400000 0.146600 -0.182900 -0.440000 0.464000 -0.760000 +0.407800 0.150600 -0.182900 -0.544000 -0.240000 -0.800000 +0.400000 0.100400 -0.150800 -0.768000 0.376000 0.512000 +0.401900 0.150600 -0.121900 -0.864000 -0.496000 -0.024000 +0.415000 0.100400 -0.121900 -0.640000 0.192000 0.736000 +0.450000 0.150600 -0.075000 -0.616000 -0.488000 0.608000 +0.450000 0.100400 -0.090700 -0.384000 -0.320000 0.856000 +0.460500 0.150600 -0.060900 -0.624000 -0.512000 0.584000 +0.500000 0.100400 -0.067100 -0.632000 -0.296000 0.704000 +0.500000 0.107000 -0.060900 -0.608000 -0.480000 0.616000 +0.504600 0.100400 -0.060900 -0.704000 -0.248000 0.656000 +0.500000 0.150600 -0.020200 -0.704000 -0.472000 0.520000 +0.550000 0.100400 -0.005700 -0.672000 -0.576000 0.448000 +0.510200 0.150600 0.000000 -0.752000 -0.384000 0.520000 +0.550000 0.104000 0.000000 -0.664000 -0.568000 0.464000 +0.550000 0.150600 0.048400 -0.632000 -0.416000 0.640000 +0.553100 0.100400 0.000000 -0.664000 -0.576000 0.464000 +0.560700 0.150600 0.060900 -0.704000 -0.368000 0.592000 +0.593200 0.100400 0.060900 -0.640000 -0.584000 0.496000 +0.591100 0.150600 0.121900 -0.792000 -0.400000 0.440000 +0.600000 0.100400 0.071800 -0.648000 -0.592000 0.472000 +0.600000 0.134700 0.121900 -0.776000 -0.456000 0.424000 +0.627900 0.100400 0.121900 -0.608000 -0.608000 0.504000 +0.600000 0.100400 0.071800 -0.648000 -0.592000 0.472000 +0.650000 0.080100 0.121900 -0.576000 -0.640000 0.496000 +0.600000 0.093600 0.060900 -0.624000 -0.616000 0.464000 +0.650000 0.050200 0.073400 -0.576000 -0.624000 0.512000 +0.641200 0.050200 0.060900 -0.600000 -0.608000 0.512000 +0.650000 0.041800 0.060900 -0.568000 -0.648000 0.504000 +0.602900 0.050200 0.000000 -0.576000 -0.704000 0.400000 +0.650000 0.013100 0.000000 -0.448000 -0.792000 0.392000 +0.600000 0.050200 -0.005300 -0.440000 -0.752000 0.480000 +0.650000 0.000000 -0.040500 0.104000 -0.944000 0.296000 +0.600000 0.000000 -0.044900 -0.016000 -0.720000 0.688000 +0.650000 -0.010200 -0.060900 0.168000 -0.784000 0.592000 +0.600000 -0.012300 -0.060900 0.104000 -0.576000 0.800000 +0.650000 -0.033500 -0.121900 0.512000 -0.672000 0.520000 +0.600000 -0.050200 -0.088500 0.448000 -0.400000 0.792000 +0.638000 -0.050200 -0.121900 0.800000 -0.536000 0.256000 +0.600000 -0.100400 -0.077400 0.584000 0.048000 0.800000 +0.626600 -0.100400 -0.121900 0.848000 0.208000 0.472000 +0.638000 -0.050200 -0.121900 0.800000 -0.536000 0.256000 +0.638900 -0.100400 -0.182900 0.920000 0.368000 0.072000 +0.649100 -0.050200 -0.182900 0.816000 -0.544000 0.144000 +0.637300 -0.100400 -0.243900 0.848000 0.016000 -0.520000 +0.637200 -0.050200 -0.243900 0.840000 -0.080000 -0.528000 +0.604900 -0.100400 -0.304800 0.744000 -0.360000 -0.552000 +0.600000 -0.050200 -0.286000 0.712000 0.144000 -0.680000 +0.600000 -0.086300 -0.304800 0.440000 0.312000 -0.832000 +0.587300 -0.050200 -0.304800 0.688000 0.056000 -0.712000 +0.589400 -0.100400 -0.304800 -0.440000 -0.424000 -0.784000 +0.550000 -0.083700 -0.304800 0.088000 -0.736000 -0.664000 +0.550000 -0.100400 -0.280800 -0.008000 -0.528000 -0.840000 +0.500000 -0.082600 -0.304800 0.216000 -0.680000 -0.688000 +0.500000 -0.100400 -0.277800 0.560000 -0.104000 -0.816000 +0.475800 -0.100400 -0.304800 0.512000 -0.104000 -0.848000 +0.500000 -0.127100 -0.304800 0.480000 0.456000 -0.744000 +0.500000 -0.100400 -0.277800 0.560000 -0.104000 -0.816000 +0.523400 -0.150600 -0.304800 0.376000 0.592000 -0.704000 +0.550000 -0.100400 -0.280800 -0.008000 -0.528000 -0.840000 +0.550000 -0.150600 -0.287800 0.352000 0.528000 -0.768000 +0.589400 -0.100400 -0.304800 -0.440000 -0.424000 -0.784000 +0.600000 -0.150600 -0.265200 0.248000 0.032000 -0.960000 +0.600000 -0.105700 -0.304800 0.312000 -0.728000 -0.600000 +0.650000 -0.150600 -0.274900 0.544000 0.464000 -0.688000 +0.604900 -0.100400 -0.304800 0.744000 -0.360000 -0.552000 +0.650000 -0.120200 -0.243900 0.704000 0.520000 -0.472000 +0.637300 -0.100400 -0.243900 0.848000 0.016000 -0.520000 +0.650000 -0.117900 -0.182900 0.792000 0.600000 0.024000 +0.638900 -0.100400 -0.182900 0.920000 0.368000 0.072000 +0.650000 -0.146100 -0.121900 0.720000 0.504000 0.464000 +0.626600 -0.100400 -0.121900 0.848000 0.208000 0.472000 +0.626600 -0.100400 -0.121900 0.848000 0.208000 0.472000 +0.591100 0.150600 0.121900 -0.792000 -0.400000 0.440000 +0.591100 0.150600 0.121900 -0.792000 -0.400000 0.440000 +0.600000 0.150600 0.141200 -0.712000 -0.440000 0.536000 +0.600000 0.134700 0.121900 -0.776000 -0.456000 0.424000 +0.600000 0.134700 0.121900 -0.776000 -0.456000 0.424000 +0.650000 0.141000 0.182900 -0.512000 -0.488000 0.704000 +0.650000 0.141000 0.182900 -0.512000 -0.488000 0.704000 +0.685300 0.100400 0.182900 -0.504000 -0.560000 0.648000 +0.650000 0.100400 0.150000 -0.536000 -0.592000 0.592000 +0.650000 0.100400 0.150000 -0.536000 -0.592000 0.592000 +0.692100 0.050200 0.121900 -0.432000 -0.784000 0.424000 +0.692100 0.050200 0.121900 -0.432000 -0.784000 0.424000 +0.700000 0.050200 0.131500 -0.112000 -0.824000 0.544000 +0.700000 0.046100 0.121900 -0.152000 -0.904000 0.376000 +0.744700 0.050200 0.121900 0.096000 -0.864000 0.480000 +0.700000 0.026800 0.060900 -0.288000 -0.896000 0.328000 +0.750000 0.050200 0.120200 -0.160000 -0.904000 0.376000 +0.750000 0.031700 0.060900 -0.136000 -0.928000 0.336000 +0.700000 0.026800 0.060900 -0.288000 -0.896000 0.328000 +0.750000 0.013300 0.000000 -0.240000 -0.936000 0.240000 +0.700000 0.012000 0.000000 -0.032000 -0.960000 0.272000 +0.750000 0.001600 -0.060900 -0.416000 -0.904000 -0.016000 +0.700000 0.001400 -0.060900 0.088000 -0.968000 0.192000 +0.750000 0.004300 -0.121900 -0.408000 -0.880000 -0.216000 +0.700000 0.000400 -0.121900 0.224000 -0.968000 0.032000 +0.750000 0.019900 -0.182900 -0.176000 -0.792000 -0.576000 +0.700000 0.009000 -0.182900 0.456000 -0.744000 -0.472000 +0.750000 0.050200 -0.223600 -0.168000 -0.552000 -0.808000 +0.700000 0.050200 -0.225700 0.368000 -0.368000 -0.848000 +0.750000 0.100400 -0.218500 0.200000 0.232000 -0.944000 +0.700000 0.100400 -0.234000 0.272000 0.000000 -0.960000 +0.750000 0.150600 -0.191500 0.256000 0.656000 -0.704000 +0.700000 0.150600 -0.210500 0.296000 0.424000 -0.848000 +0.750000 0.157000 -0.182900 0.280000 0.720000 -0.624000 +0.700000 0.190400 -0.182900 0.432000 0.560000 -0.696000 +0.750000 0.186400 -0.121900 0.504000 0.648000 -0.560000 +0.700000 0.200800 -0.171600 0.480000 0.608000 -0.616000 +0.734900 0.200800 -0.121900 0.552000 0.608000 -0.552000 +0.700000 0.229200 -0.121900 0.528000 0.656000 -0.528000 +0.750000 0.200800 -0.104400 0.480000 0.680000 -0.544000 +0.700000 0.251000 -0.093200 0.552000 0.600000 -0.568000 +0.750000 0.228900 -0.060900 0.576000 0.696000 -0.416000 +0.725300 0.251000 -0.060900 0.696000 0.648000 -0.288000 +0.750000 0.219200 0.000000 0.672000 0.728000 0.080000 +0.721000 0.251000 0.000000 0.784000 0.608000 -0.040000 +0.750000 0.222200 0.060900 0.704000 0.696000 -0.080000 +0.727500 0.251000 0.060900 0.792000 0.584000 -0.112000 +0.750000 0.233400 0.121900 0.720000 0.680000 -0.080000 +0.736800 0.251000 0.121900 0.752000 0.632000 0.144000 +0.727500 0.251000 0.060900 0.792000 0.584000 -0.112000 +0.700000 0.297800 0.121900 0.728000 0.680000 -0.032000 +0.700000 0.290800 0.060900 0.800000 0.576000 -0.104000 +0.696500 0.301200 0.121900 0.712000 0.672000 0.168000 +0.692400 0.301200 0.060900 0.752000 0.648000 -0.056000 +0.653800 0.351500 0.121900 0.656000 0.616000 0.424000 +0.663900 0.351500 0.060900 0.768000 0.624000 0.096000 +0.650000 0.355500 0.121900 0.632000 0.632000 0.432000 +0.650000 0.370100 0.060900 0.776000 0.624000 0.048000 +0.600000 0.382600 0.121900 0.272000 0.776000 0.560000 +0.612200 0.401700 0.060900 0.488000 0.832000 0.224000 +0.600000 0.401700 0.085900 0.096000 0.928000 0.336000 +0.600000 0.407100 0.060900 0.120000 0.968000 0.184000 +0.584600 0.401700 0.060900 -0.416000 0.872000 0.248000 +0.600000 0.410900 0.000000 0.104000 0.992000 -0.032000 +0.568400 0.401700 0.000000 -0.472000 0.832000 -0.264000 +0.600000 0.401700 -0.057700 0.168000 0.920000 -0.344000 +0.600000 0.410900 0.000000 0.104000 0.992000 -0.032000 +0.616700 0.401700 0.000000 0.496000 0.864000 -0.032000 +0.600000 0.407100 0.060900 0.120000 0.968000 0.184000 +0.612200 0.401700 0.060900 0.488000 0.832000 0.224000 +0.616700 0.401700 0.000000 0.496000 0.864000 -0.032000 +0.650000 0.370100 0.060900 0.776000 0.624000 0.048000 +0.650000 0.368200 0.000000 0.792000 0.584000 -0.144000 +0.663900 0.351500 0.060900 0.768000 0.624000 0.096000 +0.660900 0.351500 0.000000 0.832000 0.512000 -0.176000 +0.692400 0.301200 0.060900 0.752000 0.648000 -0.056000 +0.685300 0.301200 0.000000 0.832000 0.536000 -0.104000 +0.700000 0.290800 0.060900 0.800000 0.576000 -0.104000 +0.700000 0.279600 0.000000 0.792000 0.600000 -0.048000 +0.727500 0.251000 0.060900 0.792000 0.584000 -0.112000 +0.721000 0.251000 0.000000 0.784000 0.608000 -0.040000 +0.700000 0.279600 0.000000 0.792000 0.600000 -0.048000 +0.725300 0.251000 -0.060900 0.696000 0.648000 -0.288000 +0.700000 0.278700 -0.060900 0.648000 0.584000 -0.472000 +0.700000 0.251000 -0.093200 0.552000 0.600000 -0.568000 +0.680100 0.301200 -0.060900 0.752000 0.544000 -0.368000 +0.673000 0.251000 -0.121900 0.568000 0.576000 -0.584000 +0.650000 0.301200 -0.100800 0.528000 0.504000 -0.672000 +0.650000 0.278000 -0.121900 0.448000 0.624000 -0.624000 +0.608400 0.301200 -0.121900 0.448000 0.488000 -0.744000 +0.650000 0.251000 -0.154700 0.488000 0.640000 -0.584000 +0.600000 0.301200 -0.128700 0.472000 0.520000 -0.704000 +0.608400 0.251000 -0.182900 0.328000 0.488000 -0.800000 +0.600000 0.256700 -0.182900 0.328000 0.496000 -0.792000 +0.600000 0.251000 -0.187000 0.320000 0.456000 -0.816000 +0.608400 0.251000 -0.182900 0.328000 0.488000 -0.800000 +0.600000 0.200800 -0.209200 0.248000 0.288000 -0.920000 +0.650000 0.227800 -0.182900 0.368000 0.576000 -0.720000 +0.650000 0.200800 -0.204000 0.272000 0.408000 -0.864000 +0.687200 0.200800 -0.182900 0.432000 0.544000 -0.712000 +0.650000 0.150600 -0.219600 0.200000 0.280000 -0.928000 +0.700000 0.190400 -0.182900 0.432000 0.560000 -0.696000 +0.700000 0.150600 -0.210500 0.296000 0.424000 -0.848000 +0.650000 0.150600 -0.219600 0.200000 0.280000 -0.928000 +0.700000 0.100400 -0.234000 0.272000 0.000000 -0.960000 +0.650000 0.100400 -0.241400 0.232000 0.064000 -0.968000 +0.700000 0.050200 -0.225700 0.368000 -0.368000 -0.848000 +0.650000 0.067400 -0.243900 0.208000 0.056000 -0.968000 +0.653800 0.050200 -0.243900 0.232000 0.032000 -0.968000 +0.650000 0.050200 -0.244900 0.216000 0.040000 -0.968000 +0.653800 0.000000 -0.243900 0.576000 -0.112000 -0.808000 +0.650000 0.000000 -0.248500 0.680000 -0.160000 -0.712000 +0.650000 -0.016900 -0.243900 0.704000 -0.184000 -0.672000 +0.600000 0.000000 -0.284600 0.512000 0.112000 -0.840000 +0.637200 -0.050200 -0.243900 0.840000 -0.080000 -0.528000 +0.600000 -0.050200 -0.286000 0.712000 0.144000 -0.680000 +0.600000 0.000000 -0.284600 0.512000 0.112000 -0.840000 +0.587300 -0.050200 -0.304800 0.688000 0.056000 -0.712000 +0.578400 0.000000 -0.304800 0.536000 0.480000 -0.688000 +0.578400 0.000000 -0.304800 0.536000 0.480000 -0.688000 +0.750000 0.062100 0.182900 -0.416000 -0.632000 0.648000 +0.750000 0.062100 0.182900 -0.416000 -0.632000 0.648000 +0.750000 0.050900 0.121900 0.096000 -0.792000 0.600000 +0.762700 0.050200 0.182900 -0.512000 -0.672000 0.520000 +0.751700 0.050200 0.121900 -0.392000 -0.816000 0.416000 +0.800000 0.035400 0.182900 -0.432000 -0.808000 0.384000 +0.800000 0.028400 0.121900 -0.376000 -0.808000 0.432000 +0.846600 0.000000 0.182900 -0.736000 -0.616000 0.264000 +0.829700 0.000000 0.121900 -0.704000 -0.616000 0.344000 +0.850000 -0.004200 0.182900 -0.720000 -0.616000 0.288000 +0.850000 -0.029600 0.121900 -0.840000 -0.432000 0.312000 +0.880500 -0.050200 0.182900 -0.744000 -0.528000 0.384000 +0.857500 -0.050200 0.121900 -0.848000 -0.448000 0.272000 +0.900000 -0.076800 0.182900 -0.504000 -0.624000 0.592000 +0.892500 -0.100400 0.121900 -0.688000 -0.680000 0.240000 +0.900000 -0.100400 0.145900 -0.608000 -0.728000 0.304000 +0.900000 -0.076800 0.182900 -0.504000 -0.624000 0.592000 +0.934300 -0.100400 0.182900 -0.392000 -0.752000 0.520000 +0.934300 -0.100400 0.182900 -0.392000 -0.752000 0.520000 +0.800000 0.150600 0.181400 0.520000 0.336000 0.776000 +0.800000 0.150600 0.181400 0.520000 0.336000 0.776000 +0.850000 0.150600 0.126500 0.640000 0.560000 0.512000 +0.800000 0.190400 0.121900 0.624000 0.752000 0.168000 +0.850000 0.151600 0.121900 0.680000 0.720000 0.080000 +0.800000 0.182100 0.060900 0.560000 0.824000 -0.024000 +0.850000 0.154700 0.060900 0.576000 0.800000 0.096000 +0.800000 0.184600 0.000000 0.464000 0.872000 0.120000 +0.850000 0.161100 0.000000 0.480000 0.856000 0.160000 +0.800000 0.194300 -0.060900 0.416000 0.824000 -0.360000 +0.850000 0.171300 -0.060900 0.448000 0.864000 -0.216000 +0.800000 0.164900 -0.121900 0.312000 0.800000 -0.504000 +0.850000 0.155600 -0.121900 0.432000 0.856000 -0.272000 +0.800000 0.150600 -0.164100 0.256000 0.800000 -0.528000 +0.850000 0.150600 -0.140900 0.432000 0.840000 -0.304000 +0.800000 0.138600 -0.182900 0.232000 0.712000 -0.656000 +0.850000 0.127100 -0.182900 0.192000 0.744000 -0.632000 +0.800000 0.100400 -0.216300 0.104000 0.416000 -0.896000 +0.850000 0.100400 -0.218500 0.128000 0.592000 -0.784000 +0.800000 0.050200 -0.233400 -0.176000 0.416000 -0.880000 +0.850000 0.050200 -0.237100 -0.376000 0.576000 -0.720000 +0.800000 0.000000 -0.217200 -0.656000 -0.464000 -0.584000 +0.850000 0.042400 -0.243900 -0.408000 0.528000 -0.736000 +0.819700 0.000000 -0.243900 -0.752000 -0.192000 -0.616000 +0.850000 0.000000 -0.279000 -0.536000 0.488000 -0.680000 +0.835300 -0.050200 -0.243900 -0.840000 -0.416000 -0.336000 +0.850000 -0.050200 -0.276700 -0.784000 -0.280000 -0.544000 +0.850000 -0.077200 -0.243900 -0.824000 -0.432000 -0.344000 +0.835300 -0.050200 -0.243900 -0.840000 -0.416000 -0.336000 +0.850000 -0.086900 -0.182900 -0.848000 -0.512000 -0.048000 +0.822900 -0.050200 -0.182900 -0.792000 -0.592000 -0.088000 +0.850000 -0.088400 -0.121900 -0.808000 -0.584000 0.016000 +0.818400 -0.050200 -0.121900 -0.760000 -0.640000 0.016000 +0.850000 -0.079400 -0.060900 -0.768000 -0.616000 0.120000 +0.823600 -0.050200 -0.060900 -0.736000 -0.664000 0.112000 +0.850000 -0.068700 0.000000 -0.752000 -0.640000 0.136000 +0.832800 -0.050200 0.000000 -0.728000 -0.656000 0.144000 +0.850000 -0.056700 0.060900 -0.720000 -0.664000 0.176000 +0.843600 -0.050200 0.060900 -0.704000 -0.672000 0.184000 +0.850000 -0.050200 0.089500 -0.768000 -0.592000 0.216000 +0.850000 -0.050200 0.089500 -0.768000 -0.592000 0.216000 +0.850000 0.150600 0.126500 0.640000 0.560000 0.512000 +0.850000 0.150600 0.126500 0.640000 0.560000 0.512000 +0.850000 0.151600 0.121900 0.680000 0.720000 0.080000 +0.850900 0.150600 0.121900 0.704000 0.704000 0.080000 +0.850000 0.154700 0.060900 0.576000 0.800000 0.096000 +0.855400 0.150600 0.060900 0.680000 0.720000 0.072000 +0.850000 0.161100 0.000000 0.480000 0.856000 0.160000 +0.867700 0.150600 0.000000 0.552000 0.816000 0.152000 +0.850000 0.171300 -0.060900 0.448000 0.864000 -0.216000 +0.888500 0.150600 -0.060900 0.504000 0.856000 -0.040000 +0.850000 0.155600 -0.121900 0.432000 0.856000 -0.272000 +0.859300 0.150600 -0.121900 0.456000 0.840000 -0.272000 +0.850000 0.150600 -0.140900 0.432000 0.840000 -0.304000 +0.850000 0.150600 -0.140900 0.432000 0.840000 -0.304000 +0.891700 0.100400 0.182900 0.576000 0.688000 0.424000 +0.891700 0.100400 0.182900 0.576000 0.688000 0.424000 +0.900000 0.100400 0.165200 0.584000 0.744000 0.296000 +0.900000 0.093100 0.182900 0.568000 0.672000 0.464000 +0.911800 0.100400 0.121900 0.528000 0.800000 0.264000 +0.940200 0.050200 0.182900 0.624000 0.528000 0.568000 +0.950000 0.069700 0.121900 0.360000 0.840000 0.384000 +0.950000 0.050200 0.169400 0.600000 0.560000 0.560000 +1.000000 0.053600 0.121900 0.280000 0.872000 0.392000 +1.000000 0.050200 0.131000 0.336000 0.784000 0.512000 +0.950000 0.050200 0.169400 0.600000 0.560000 0.560000 +1.000000 0.004900 0.182900 0.336000 0.520000 0.776000 +0.950000 0.037400 0.182900 0.520000 0.504000 0.680000 +0.950000 0.050200 0.169400 0.600000 0.560000 0.560000 +0.940200 0.050200 0.182900 0.624000 0.528000 0.568000 +0.940200 0.050200 0.182900 0.624000 0.528000 0.568000 +0.900000 0.100400 0.165200 0.584000 0.744000 0.296000 +0.900000 0.100400 0.165200 0.584000 0.744000 0.296000 +0.900000 0.107300 0.121900 0.512000 0.832000 0.184000 +0.911800 0.100400 0.121900 0.528000 0.800000 0.264000 +0.900000 0.118900 0.060900 0.472000 0.856000 0.184000 +0.936800 0.100400 0.060900 0.456000 0.872000 0.168000 +0.900000 0.131100 0.000000 0.480000 0.848000 0.192000 +0.950000 0.100400 0.012800 0.496000 0.848000 0.136000 +0.950000 0.102000 0.000000 0.472000 0.864000 0.120000 +0.952900 0.100400 0.000000 0.504000 0.848000 0.120000 +0.950000 0.106300 -0.060900 0.576000 0.776000 -0.240000 +0.957800 0.100400 -0.060900 0.544000 0.824000 -0.120000 +0.950000 0.100400 -0.078300 0.560000 0.768000 -0.304000 +1.000000 0.074600 -0.060900 0.496000 0.816000 -0.280000 +0.950000 0.086300 -0.121900 0.544000 0.784000 -0.280000 +1.000000 0.056100 -0.121900 0.488000 0.808000 -0.304000 +0.950000 0.069900 -0.182900 0.544000 0.736000 -0.392000 +1.000000 0.050200 -0.141200 0.512000 0.792000 -0.320000 +0.978000 0.050200 -0.182900 0.512000 0.768000 -0.376000 +1.000000 0.035800 -0.182900 0.504000 0.768000 -0.376000 +0.950000 0.050200 -0.224500 0.472000 0.712000 -0.504000 +1.000000 0.004200 -0.243900 0.464000 0.680000 -0.552000 +0.950000 0.037500 -0.243900 0.432000 0.688000 -0.576000 +1.000000 0.000000 -0.249700 0.512000 0.464000 -0.720000 +0.950000 0.000000 -0.291100 0.424000 0.536000 -0.720000 +1.000000 -0.050200 -0.288900 0.520000 0.432000 -0.728000 +0.950000 -0.016600 -0.304800 0.448000 0.520000 -0.720000 +0.981700 -0.050200 -0.304800 0.528000 0.432000 -0.720000 +0.950000 -0.050200 -0.338500 0.440000 0.400000 -0.800000 +1.000000 -0.073100 -0.304800 0.536000 0.424000 -0.720000 +0.950000 -0.100400 -0.351000 0.336000 0.064000 -0.936000 +1.000000 -0.100400 -0.325200 0.488000 0.344000 -0.792000 +0.950000 -0.150600 -0.345500 -0.032000 0.064000 -0.992000 +1.000000 -0.150600 -0.335800 0.136000 0.136000 -0.976000 +0.950000 -0.200800 -0.357000 -0.272000 -0.104000 -0.952000 +1.000000 -0.200800 -0.338800 0.136000 -0.384000 -0.904000 +0.950000 -0.251000 -0.328200 -0.712000 -0.568000 -0.392000 +1.000000 -0.251000 -0.355700 -0.816000 -0.248000 -0.504000 +1.000000 -0.251000 -0.355700 -0.816000 -0.248000 -0.504000 +1.000000 -0.012000 0.182900 0.384000 -0.248000 0.880000 +1.000000 -0.012000 0.182900 0.384000 -0.248000 0.880000 +1.000000 -0.050200 0.168100 0.416000 -0.344000 0.832000 +0.975800 -0.050200 0.182900 0.464000 -0.232000 0.848000 +1.000000 -0.100400 0.134700 0.432000 -0.528000 0.720000 +0.959000 -0.100400 0.182900 0.616000 -0.584000 0.520000 +0.959000 -0.100400 0.182900 0.616000 -0.584000 0.520000 +-0.900000 0.200800 0.074800 0.296000 0.712000 0.624000 +-0.900000 0.200800 0.074800 0.296000 0.712000 0.624000 +-0.900000 0.210300 0.060900 0.312000 0.744000 0.576000 +-0.879600 0.200800 0.060900 0.352000 0.712000 0.600000 +-0.900000 0.240500 0.000000 0.368000 0.840000 0.376000 +-0.850000 0.200800 0.035600 0.384000 0.744000 0.536000 +-0.850000 0.219100 0.000000 0.368000 0.824000 0.424000 +-0.811000 0.200800 0.000000 0.408000 0.816000 0.392000 +-0.811000 0.200800 0.000000 0.408000 0.816000 0.392000 +-0.900000 -0.127600 0.121900 -0.608000 -0.704000 0.344000 +-0.900000 -0.127600 0.121900 -0.608000 -0.704000 0.344000 +-0.900000 -0.149700 0.060900 -0.696000 -0.664000 0.232000 +-0.878400 -0.150600 0.121900 -0.736000 -0.560000 0.368000 +-0.899200 -0.150600 0.060900 -0.816000 -0.504000 0.256000 +-0.851500 -0.200800 0.121900 -0.832000 -0.360000 0.408000 +-0.869300 -0.200800 0.060900 -0.824000 -0.496000 0.248000 +-0.899200 -0.150600 0.060900 -0.816000 -0.504000 0.256000 +-0.882700 -0.200800 0.000000 -0.840000 -0.496000 0.192000 +-0.900000 -0.150600 0.057700 -0.744000 -0.616000 0.232000 +-0.900000 -0.169600 0.000000 -0.800000 -0.552000 0.224000 +-0.882700 -0.200800 0.000000 -0.840000 -0.496000 0.192000 +-0.900000 -0.192500 -0.060900 -0.856000 -0.488000 0.144000 +-0.895700 -0.200800 -0.060900 -0.864000 -0.480000 0.136000 +-0.900000 -0.200800 -0.096200 -0.752000 -0.632000 0.128000 +-0.860100 -0.251000 -0.060900 -0.808000 -0.568000 0.112000 +-0.900000 -0.204500 -0.121900 -0.688000 -0.712000 0.104000 +-0.866600 -0.251000 -0.121900 -0.808000 -0.576000 0.072000 +-0.900000 -0.206900 -0.182900 -0.648000 -0.752000 0.056000 +-0.864200 -0.251000 -0.182900 -0.800000 -0.592000 0.000000 +-0.900000 -0.212400 -0.243900 -0.672000 -0.712000 0.176000 +-0.869200 -0.251000 -0.243900 -0.768000 -0.600000 0.200000 +-0.900000 -0.236500 -0.304800 -0.680000 -0.456000 -0.560000 +-0.891700 -0.251000 -0.304800 -0.808000 -0.512000 -0.264000 +-0.891700 -0.251000 -0.304800 -0.808000 -0.512000 -0.264000 +-0.850000 0.184100 0.060900 0.376000 0.632000 0.664000 +-0.850000 0.184100 0.060900 0.376000 0.632000 0.664000 +-0.850000 0.150600 0.098600 0.360000 0.600000 0.704000 +-0.800000 0.153700 0.060900 0.432000 0.632000 0.632000 +-0.800000 0.150600 0.064100 0.424000 0.560000 0.704000 +-0.796300 0.150600 0.060900 0.512000 0.584000 0.616000 +-0.800000 0.153700 0.060900 0.432000 0.632000 0.632000 +-0.750000 0.150600 0.014500 0.472000 0.624000 0.608000 +-0.800000 0.195100 0.000000 0.456000 0.768000 0.432000 +-0.750000 0.162200 0.000000 0.464000 0.672000 0.560000 +-0.750000 0.150600 0.014500 0.472000 0.624000 0.608000 +-0.734000 0.150600 0.000000 0.496000 0.640000 0.576000 +-0.750000 0.162200 0.000000 0.464000 0.672000 0.560000 +-0.700000 0.150600 -0.043600 0.552000 0.712000 0.424000 +-0.750000 0.191300 -0.060900 0.496000 0.856000 0.072000 +-0.700000 0.159000 -0.060900 0.600000 0.776000 0.184000 +-0.750000 0.174400 -0.121900 0.448000 0.824000 -0.336000 +-0.700000 0.150600 -0.089800 0.592000 0.744000 -0.280000 +-0.715000 0.150600 -0.121900 0.512000 0.744000 -0.408000 +-0.700000 0.140000 -0.121900 0.536000 0.728000 -0.408000 +-0.750000 0.150600 -0.159200 0.432000 0.664000 -0.600000 +-0.700000 0.100400 -0.182100 0.536000 0.592000 -0.592000 +-0.750000 0.132600 -0.182900 0.408000 0.656000 -0.624000 +-0.700900 0.100400 -0.182900 0.440000 0.608000 -0.648000 +-0.750000 0.100400 -0.222000 0.432000 0.576000 -0.680000 +-0.700000 0.099700 -0.182900 0.504000 0.560000 -0.640000 +-0.750000 0.077000 -0.243900 0.368000 0.552000 -0.744000 +-0.700000 0.050200 -0.235800 0.504000 0.432000 -0.744000 +-0.711800 0.050200 -0.243900 0.416000 0.432000 -0.792000 +-0.700000 0.037400 -0.243900 0.440000 0.392000 -0.800000 +-0.750000 0.050200 -0.267100 0.368000 0.432000 -0.816000 +-0.700000 0.000000 -0.262900 0.392000 0.288000 -0.864000 +-0.750000 0.000000 -0.285200 0.328000 0.160000 -0.920000 +-0.750000 0.000000 -0.285200 0.328000 0.160000 -0.920000 +-0.750000 0.012900 0.121900 0.496000 0.384000 0.768000 +-0.750000 0.012900 0.121900 0.496000 0.384000 0.768000 +-0.781300 0.050200 0.121900 0.536000 0.400000 0.736000 +-0.750000 0.050200 0.097600 0.464000 0.408000 0.776000 +-0.750000 0.050200 0.097600 0.464000 0.408000 0.776000 +-0.800000 -0.280700 0.121900 -0.736000 -0.528000 0.408000 +-0.800000 -0.280700 0.121900 -0.736000 -0.528000 0.408000 +-0.783300 -0.301200 0.121900 -0.688000 -0.568000 0.440000 +-0.800000 -0.301200 0.085900 -0.768000 -0.544000 0.304000 +-0.800000 -0.301200 0.085900 -0.768000 -0.544000 0.304000 +-0.750000 -0.342500 0.121900 -0.536000 -0.592000 0.592000 +-0.750000 -0.342500 0.121900 -0.536000 -0.592000 0.592000 +-0.739400 -0.351500 0.121900 -0.528000 -0.576000 0.616000 +-0.750000 -0.351500 0.110100 -0.600000 -0.584000 0.536000 +-0.750000 -0.351500 0.110100 -0.600000 -0.584000 0.536000 +-0.701000 -0.451900 0.060900 -0.792000 -0.480000 0.344000 +-0.701000 -0.451900 0.060900 -0.792000 -0.480000 0.344000 +-0.700000 -0.451900 0.063700 -0.672000 -0.600000 0.424000 +-0.700000 -0.453200 0.060900 -0.560000 -0.720000 0.392000 +-0.700000 -0.453200 0.060900 -0.560000 -0.720000 0.392000 +-0.650000 -0.141800 0.121900 0.432000 0.328000 0.832000 +-0.650000 -0.141800 0.121900 0.432000 0.328000 0.832000 +-0.677900 -0.100400 0.121900 0.528000 0.328000 0.776000 +-0.650000 -0.100400 0.096100 0.592000 0.288000 0.744000 +-0.650000 -0.100400 0.096100 0.592000 0.288000 0.744000 +-0.600000 -0.122400 0.060900 0.616000 0.400000 0.664000 +-0.600000 -0.122400 0.060900 0.616000 0.400000 0.664000 +-0.575700 -0.150600 0.060900 0.384000 0.664000 0.632000 +-0.600000 -0.150600 0.080700 0.576000 0.424000 0.688000 +-0.600000 -0.150600 0.080700 0.576000 0.424000 0.688000 +-0.559300 -0.200800 0.121900 0.160000 0.720000 0.672000 +-0.559300 -0.200800 0.121900 0.160000 0.720000 0.672000 +-0.550000 -0.200800 0.118700 0.032000 0.784000 0.608000 +-0.550000 -0.202900 0.121900 0.032000 0.728000 0.680000 +-0.536800 -0.200800 0.121900 -0.104000 0.736000 0.664000 +-0.536800 -0.200800 0.121900 -0.104000 0.736000 0.664000 +-0.550000 -0.494000 0.121900 0.024000 -0.832000 0.536000 +-0.550000 -0.494000 0.121900 0.024000 -0.832000 0.536000 +-0.550000 -0.502100 0.104800 0.104000 -0.840000 0.520000 +-0.500000 -0.486900 0.121900 0.296000 -0.800000 0.504000 +-0.500000 -0.502100 0.088800 0.616000 -0.688000 0.376000 +-0.450000 -0.453600 0.121900 0.584000 -0.744000 0.288000 +-0.489100 -0.502100 0.060900 0.704000 -0.616000 0.328000 +-0.450000 -0.471900 0.060900 0.592000 -0.752000 0.272000 +-0.450000 -0.471900 0.060900 0.592000 -0.752000 0.272000 +-0.550000 -0.502100 0.104800 0.104000 -0.840000 0.520000 +-0.550000 -0.502100 0.104800 0.104000 -0.840000 0.520000 +-0.550000 -0.532000 0.060900 0.080000 -0.776000 0.624000 +-0.500000 -0.502100 0.088800 0.616000 -0.688000 0.376000 +-0.500000 -0.517700 0.060900 0.632000 -0.632000 0.440000 +-0.489100 -0.502100 0.060900 0.704000 -0.616000 0.328000 +-0.489100 -0.502100 0.060900 0.704000 -0.616000 0.328000 +-0.405500 -0.100400 0.060900 -0.712000 0.456000 0.520000 +-0.405500 -0.100400 0.060900 -0.712000 0.456000 0.520000 +-0.400000 -0.090100 0.060900 -0.696000 0.400000 0.584000 +-0.400000 -0.100400 0.069600 -0.688000 0.456000 0.552000 +-0.367400 -0.050200 0.060900 -0.696000 0.408000 0.584000 +-0.351400 -0.100400 0.121900 -0.608000 0.368000 0.696000 +-0.350000 -0.050200 0.083200 -0.416000 0.344000 0.832000 +-0.350000 -0.097900 0.121900 -0.560000 0.424000 0.704000 +-0.300000 -0.050200 0.104800 -0.312000 0.512000 0.792000 +-0.300000 -0.066800 0.121900 -0.280000 0.584000 0.752000 +-0.255700 -0.050200 0.121900 -0.192000 0.512000 0.832000 +-0.255700 -0.050200 0.121900 -0.192000 0.512000 0.832000 +-0.350000 -0.001900 0.060900 -0.656000 0.280000 0.688000 +-0.350000 -0.001900 0.060900 -0.656000 0.280000 0.688000 +-0.350000 -0.050200 0.083200 -0.416000 0.344000 0.832000 +-0.367400 -0.050200 0.060900 -0.696000 0.408000 0.584000 +-0.367400 -0.050200 0.060900 -0.696000 0.408000 0.584000 +-0.351400 -0.100400 0.121900 -0.608000 0.368000 0.696000 +-0.351400 -0.100400 0.121900 -0.608000 0.368000 0.696000 +-0.400000 -0.140400 0.121900 -0.448000 0.624000 0.632000 +-0.400000 -0.100400 0.069600 -0.688000 0.456000 0.552000 +-0.400000 -0.100400 0.069600 -0.688000 0.456000 0.552000 +-0.400000 -0.401700 0.111300 0.640000 -0.680000 0.336000 +-0.400000 -0.401700 0.111300 0.640000 -0.680000 0.336000 +-0.400000 -0.423000 0.060900 0.616000 -0.696000 0.360000 +-0.350000 -0.401700 0.073400 0.632000 -0.688000 0.344000 +-0.350000 -0.406300 0.060900 0.592000 -0.728000 0.320000 +-0.344500 -0.401700 0.060900 0.632000 -0.688000 0.328000 +-0.344500 -0.401700 0.060900 0.632000 -0.688000 0.328000 +-0.348200 0.000000 0.060900 -0.376000 0.448000 0.800000 +-0.348200 0.000000 0.060900 -0.376000 0.448000 0.800000 +-0.300000 0.027200 0.060900 -0.160000 0.552000 0.808000 +-0.300000 0.000000 0.088800 -0.240000 0.432000 0.864000 +-0.250000 0.033500 0.060900 0.056000 0.528000 0.840000 +-0.250000 0.000000 0.079500 -0.144000 0.552000 0.816000 +-0.200000 0.020500 0.060900 0.664000 0.440000 0.600000 +-0.200000 0.000000 0.081400 0.696000 0.336000 0.624000 +-0.190300 0.000000 0.060900 0.816000 0.200000 0.536000 +-0.200000 -0.050200 0.072600 0.688000 0.360000 0.624000 +-0.193200 -0.050200 0.060900 0.808000 0.008000 0.584000 +-0.200000 -0.100400 0.076800 0.784000 -0.136000 0.600000 +-0.190200 -0.100400 0.060900 0.752000 -0.248000 0.600000 +-0.200000 -0.121800 0.060900 0.728000 -0.328000 0.592000 +-0.200000 -0.121800 0.060900 0.728000 -0.328000 0.592000 +-0.250000 0.000000 0.079500 -0.144000 0.552000 0.816000 +-0.250000 0.000000 0.079500 -0.144000 0.552000 0.816000 +-0.200000 0.000000 0.081400 0.696000 0.336000 0.624000 +-0.250000 -0.048000 0.121900 0.272000 0.640000 0.704000 +-0.200000 -0.050200 0.072600 0.688000 0.360000 0.624000 +-0.247100 -0.050200 0.121900 0.488000 0.512000 0.696000 +-0.200000 -0.100400 0.076800 0.784000 -0.136000 0.600000 +-0.230200 -0.100400 0.121900 0.776000 -0.176000 0.600000 +-0.230200 -0.100400 0.121900 0.776000 -0.176000 0.600000 +0.550000 0.351500 0.078000 -0.616000 0.672000 0.392000 +0.550000 0.351500 0.078000 -0.616000 0.672000 0.392000 +0.540600 0.351500 0.060900 -0.584000 0.632000 0.496000 +0.550000 0.359900 0.060900 -0.592000 0.640000 0.480000 +0.500000 0.351500 0.029100 -0.680000 0.048000 0.728000 +0.550000 0.388900 0.000000 -0.392000 0.856000 0.320000 +0.500000 0.369100 0.000000 -0.184000 0.800000 0.552000 +0.500000 0.351500 0.029100 -0.680000 0.048000 0.728000 +0.458200 0.351500 0.000000 -0.280000 0.520000 0.800000 +0.458200 0.351500 0.000000 -0.280000 0.520000 0.800000 +0.550000 0.246100 0.121900 -0.904000 -0.224000 0.352000 +0.550000 0.246100 0.121900 -0.904000 -0.224000 0.352000 +0.550000 0.200800 0.086900 -0.880000 -0.256000 0.392000 +0.548800 0.251000 0.121900 -0.912000 -0.176000 0.360000 +0.538800 0.200800 0.060900 -0.824000 -0.216000 0.520000 +0.533200 0.251000 0.060900 -0.856000 0.032000 0.512000 +0.500000 0.200800 0.008600 -0.576000 -0.176000 0.792000 +0.500800 0.251000 0.000000 -0.792000 -0.016000 0.608000 +0.500000 0.245700 0.000000 -0.568000 0.120000 0.808000 +0.500000 0.251000 -0.000900 -0.496000 0.112000 0.856000 +0.488800 0.200800 0.000000 -0.512000 0.024000 0.856000 +0.450000 0.251000 -0.039600 -0.400000 -0.080000 0.904000 +0.450000 0.200800 -0.035500 -0.536000 -0.264000 0.792000 +0.400000 0.251000 -0.058700 -0.328000 -0.176000 0.920000 +0.416500 0.200800 -0.060900 -0.560000 -0.352000 0.744000 +0.400000 0.242400 -0.060900 -0.352000 -0.192000 0.904000 +0.400000 0.200800 -0.077800 -0.600000 -0.432000 0.664000 +0.395100 0.251000 -0.060900 -0.344000 -0.184000 0.912000 +0.366500 0.200800 -0.121900 -0.760000 -0.624000 0.168000 +0.350000 0.251000 -0.088400 -0.448000 -0.320000 0.824000 +0.350000 0.218900 -0.121900 -0.504000 -0.816000 0.264000 +0.300000 0.251000 -0.114600 -0.168000 -0.536000 0.824000 +0.300000 0.236900 -0.121900 -0.304000 -0.688000 0.640000 +0.271900 0.251000 -0.121900 -0.240000 -0.760000 0.592000 +0.300000 0.251000 -0.156100 -0.368000 -0.808000 -0.448000 +0.300000 0.236900 -0.121900 -0.304000 -0.688000 0.640000 +0.321900 0.251000 -0.182900 -0.240000 -0.296000 -0.920000 +0.350000 0.218900 -0.121900 -0.504000 -0.816000 0.264000 +0.350000 0.236900 -0.182900 -0.272000 -0.424000 -0.856000 +0.366500 0.200800 -0.121900 -0.760000 -0.624000 0.168000 +0.380800 0.200800 -0.182900 -0.440000 -0.264000 -0.856000 +0.400000 0.152400 -0.121900 -0.688000 -0.712000 -0.048000 +0.400000 0.155900 -0.182900 -0.216000 -0.144000 -0.960000 +0.380800 0.200800 -0.182900 -0.440000 -0.264000 -0.856000 +0.400000 0.200800 -0.189400 -0.152000 -0.072000 -0.984000 +0.350000 0.236900 -0.182900 -0.272000 -0.424000 -0.856000 +0.400000 0.251000 -0.186400 -0.152000 0.040000 -0.984000 +0.350000 0.251000 -0.187300 -0.168000 -0.184000 -0.960000 +0.400000 0.301200 -0.184200 -0.016000 -0.016000 -0.992000 +0.350000 0.301200 -0.184400 -0.056000 0.000000 -0.992000 +0.400000 0.351500 -0.194500 0.000000 0.072000 -0.992000 +0.350000 0.351500 -0.192800 0.000000 0.056000 -0.992000 +0.400000 0.377300 -0.182900 0.016000 0.320000 -0.944000 +0.350000 0.377400 -0.182900 0.000000 0.280000 -0.952000 +0.400000 0.401700 -0.171200 0.088000 0.472000 -0.872000 +0.350000 0.401700 -0.174600 0.056000 0.440000 -0.888000 +0.400000 0.432800 -0.121900 0.160000 0.904000 -0.384000 +0.350000 0.445000 -0.121900 0.208000 0.960000 -0.152000 +0.400000 0.419800 -0.060900 0.080000 0.848000 0.520000 +0.350000 0.424300 -0.060900 0.120000 0.824000 0.544000 +0.400000 0.401700 -0.034800 -0.040000 0.584000 0.808000 +0.350000 0.401700 -0.031000 0.032000 0.488000 0.864000 +0.400000 0.351500 -0.018700 -0.136000 -0.208000 0.960000 +0.350000 0.351500 -0.021800 0.032000 -0.048000 0.992000 +0.350000 0.401700 -0.031000 0.032000 0.488000 0.864000 +0.300000 0.351500 -0.009100 -0.016000 -0.144000 0.984000 +0.300000 0.401700 -0.022200 0.096000 0.472000 0.864000 +0.350000 0.401700 -0.031000 0.032000 0.488000 0.864000 +0.300000 0.430700 -0.060900 0.128000 0.808000 0.568000 +0.350000 0.424300 -0.060900 0.120000 0.824000 0.544000 +0.300000 0.451900 -0.106900 0.184000 0.864000 0.456000 +0.350000 0.445000 -0.121900 0.208000 0.960000 -0.152000 +0.323400 0.451900 -0.121900 0.248000 0.944000 -0.200000 +0.350000 0.401700 -0.174600 0.056000 0.440000 -0.888000 +0.300000 0.451900 -0.131100 0.200000 0.712000 -0.664000 +0.300000 0.401700 -0.174800 0.040000 0.368000 -0.920000 +0.350000 0.401700 -0.174600 0.056000 0.440000 -0.888000 +0.300000 0.379400 -0.182900 -0.016000 0.272000 -0.960000 +0.350000 0.377400 -0.182900 0.000000 0.280000 -0.952000 +0.300000 0.351500 -0.193900 -0.008000 0.064000 -0.992000 +0.350000 0.351500 -0.192800 0.000000 0.056000 -0.992000 +0.300000 0.301200 -0.184400 -0.064000 -0.072000 -0.992000 +0.350000 0.301200 -0.184400 -0.056000 0.000000 -0.992000 +0.300000 0.284000 -0.182900 -0.168000 -0.184000 -0.960000 +0.350000 0.251000 -0.187300 -0.168000 -0.184000 -0.960000 +0.321900 0.251000 -0.182900 -0.240000 -0.296000 -0.920000 +0.350000 0.236900 -0.182900 -0.272000 -0.424000 -0.856000 +0.350000 0.236900 -0.182900 -0.272000 -0.424000 -0.856000 +0.550000 0.246100 0.121900 -0.904000 -0.224000 0.352000 +0.550000 0.246100 0.121900 -0.904000 -0.224000 0.352000 +0.567500 0.200800 0.121900 -0.784000 -0.344000 0.504000 +0.550000 0.200800 0.086900 -0.880000 -0.256000 0.392000 +0.550000 0.200800 0.086900 -0.880000 -0.256000 0.392000 +0.600000 0.100400 0.071800 -0.648000 -0.592000 0.472000 +0.600000 0.100400 0.071800 -0.648000 -0.592000 0.472000 +0.600000 0.093600 0.060900 -0.624000 -0.616000 0.464000 +0.593200 0.100400 0.060900 -0.640000 -0.584000 0.496000 +0.600000 0.053300 0.000000 -0.472000 -0.712000 0.512000 +0.553100 0.100400 0.000000 -0.664000 -0.576000 0.464000 +0.600000 0.050200 -0.005300 -0.440000 -0.752000 0.480000 +0.550000 0.100400 -0.005700 -0.672000 -0.576000 0.448000 +0.550000 0.050200 -0.037800 -0.320000 -0.688000 0.640000 +0.504600 0.100400 -0.060900 -0.704000 -0.248000 0.656000 +0.500000 0.050200 -0.057700 -0.560000 0.128000 0.816000 +0.500000 0.067400 -0.060900 -0.592000 0.120000 0.792000 +0.495100 0.050200 -0.060900 -0.456000 0.136000 0.872000 +0.500000 0.100400 -0.067100 -0.632000 -0.296000 0.704000 +0.450000 0.050200 -0.077000 -0.360000 0.120000 0.920000 +0.450000 0.100400 -0.090700 -0.384000 -0.320000 0.856000 +0.400000 0.050200 -0.114800 -0.552000 0.256000 0.784000 +0.415000 0.100400 -0.121900 -0.640000 0.192000 0.736000 +0.400000 0.072600 -0.121900 -0.632000 0.256000 0.720000 +0.400000 0.100400 -0.150800 -0.768000 0.376000 0.512000 +0.393200 0.050200 -0.121900 -0.648000 0.352000 0.664000 +0.381500 0.100400 -0.182900 -0.896000 0.440000 -0.008000 +0.357200 0.050200 -0.182900 -0.736000 0.640000 0.184000 +0.400000 0.100400 -0.207800 -0.424000 0.688000 -0.576000 +0.351400 0.050200 -0.243900 -0.480000 0.768000 -0.416000 +0.400000 0.083700 -0.243900 -0.328000 0.768000 -0.536000 +0.400000 0.050200 -0.294000 -0.352000 0.672000 -0.640000 +0.351400 0.050200 -0.243900 -0.480000 0.768000 -0.416000 +0.400000 0.041200 -0.304800 -0.352000 0.672000 -0.648000 +0.350000 0.049300 -0.243900 -0.512000 0.784000 -0.320000 +0.350000 0.024300 -0.304800 -0.456000 0.784000 -0.408000 +0.300000 0.032100 -0.243900 -0.576000 0.680000 -0.432000 +0.301400 0.000000 -0.304800 -0.584000 0.656000 -0.464000 +0.300000 0.000000 -0.302400 -0.544000 0.608000 -0.568000 +0.300000 -0.003100 -0.304800 -0.376000 0.424000 -0.816000 +0.301400 0.000000 -0.304800 -0.584000 0.656000 -0.464000 +0.300000 -0.050200 -0.319900 -0.536000 0.224000 -0.808000 +0.350000 0.000000 -0.339100 -0.264000 0.552000 -0.784000 +0.342100 -0.050200 -0.365800 -0.640000 -0.104000 -0.752000 +0.350000 -0.037900 -0.365800 -0.440000 0.432000 -0.776000 +0.350000 -0.050200 -0.374000 -0.496000 -0.096000 -0.856000 +0.383500 -0.050200 -0.365800 0.200000 -0.288000 -0.928000 +0.350000 -0.059800 -0.365800 -0.280000 -0.560000 -0.768000 +0.400000 -0.050200 -0.360800 0.184000 -0.432000 -0.872000 +0.350000 -0.100400 -0.331300 -0.432000 -0.520000 -0.728000 +0.400000 -0.100400 -0.340000 -0.040000 -0.360000 -0.928000 +0.350000 -0.127600 -0.304800 0.032000 -0.600000 -0.792000 +0.400000 -0.150600 -0.318400 -0.432000 -0.416000 -0.792000 +0.380400 -0.150600 -0.304800 -0.424000 -0.456000 -0.776000 +0.400000 -0.168700 -0.304800 -0.504000 -0.464000 -0.720000 +0.350000 -0.150600 -0.283600 -0.064000 -0.424000 -0.896000 +0.400000 -0.200800 -0.276700 0.448000 -0.472000 -0.752000 +0.350000 -0.200800 -0.271400 0.216000 0.224000 -0.944000 +0.400000 -0.249400 -0.243900 0.760000 -0.472000 -0.424000 +0.350000 -0.228300 -0.304800 0.616000 0.528000 -0.576000 +0.399000 -0.251000 -0.243900 0.912000 -0.008000 -0.392000 +0.366700 -0.251000 -0.304800 0.704000 0.488000 -0.496000 +0.350000 -0.228300 -0.304800 0.616000 0.528000 -0.576000 +0.350000 -0.251000 -0.329500 0.536000 0.472000 -0.688000 +0.320800 -0.200800 -0.304800 0.496000 0.328000 -0.800000 +0.300000 -0.251000 -0.347800 0.304000 0.384000 -0.864000 +0.300000 -0.200800 -0.324200 0.480000 0.248000 -0.832000 +0.320800 -0.200800 -0.304800 0.496000 0.328000 -0.800000 +0.300000 -0.150600 -0.312600 0.312000 -0.200000 -0.920000 +0.313400 -0.150600 -0.304800 0.400000 -0.360000 -0.840000 +0.300000 -0.100400 -0.310000 -0.248000 0.072000 -0.960000 +0.350000 -0.127600 -0.304800 0.032000 -0.600000 -0.792000 +0.350000 -0.100400 -0.331300 -0.432000 -0.520000 -0.728000 +0.300000 -0.100400 -0.310000 -0.248000 0.072000 -0.960000 +0.350000 -0.059800 -0.365800 -0.280000 -0.560000 -0.768000 +0.300000 -0.050200 -0.319900 -0.536000 0.224000 -0.808000 +0.342100 -0.050200 -0.365800 -0.640000 -0.104000 -0.752000 +0.350000 -0.059800 -0.365800 -0.280000 -0.560000 -0.768000 +0.350000 -0.050200 -0.374000 -0.496000 -0.096000 -0.856000 +0.350000 -0.050200 -0.374000 -0.496000 -0.096000 -0.856000 +0.650000 0.080100 0.121900 -0.576000 -0.640000 0.496000 +0.650000 0.080100 0.121900 -0.576000 -0.640000 0.496000 +0.692100 0.050200 0.121900 -0.432000 -0.784000 0.424000 +0.650000 0.050200 0.073400 -0.576000 -0.624000 0.512000 +0.700000 0.046100 0.121900 -0.152000 -0.904000 0.376000 +0.650000 0.041800 0.060900 -0.568000 -0.648000 0.504000 +0.700000 0.026800 0.060900 -0.288000 -0.896000 0.328000 +0.650000 0.013100 0.000000 -0.448000 -0.792000 0.392000 +0.700000 0.012000 0.000000 -0.032000 -0.960000 0.272000 +0.650000 0.000000 -0.040500 0.104000 -0.944000 0.296000 +0.700000 0.001400 -0.060900 0.088000 -0.968000 0.192000 +0.686800 0.000000 -0.060900 0.208000 -0.960000 0.144000 +0.700000 0.000400 -0.121900 0.224000 -0.968000 0.032000 +0.698200 0.000000 -0.121900 0.296000 -0.952000 0.032000 +0.700000 0.009000 -0.182900 0.456000 -0.744000 -0.472000 +0.687300 0.000000 -0.182900 0.648000 -0.600000 -0.456000 +0.700000 0.050200 -0.225700 0.368000 -0.368000 -0.848000 +0.653800 0.000000 -0.243900 0.576000 -0.112000 -0.808000 +0.653800 0.050200 -0.243900 0.232000 0.032000 -0.968000 +0.653800 0.050200 -0.243900 0.232000 0.032000 -0.968000 +0.750000 0.233400 0.121900 0.720000 0.680000 -0.080000 +0.750000 0.233400 0.121900 0.720000 0.680000 -0.080000 +0.788900 0.200800 0.121900 0.632000 0.744000 0.184000 +0.750000 0.222200 0.060900 0.704000 0.696000 -0.080000 +0.772600 0.200800 0.060900 0.648000 0.736000 -0.136000 +0.750000 0.219200 0.000000 0.672000 0.728000 0.080000 +0.770200 0.200800 0.000000 0.616000 0.776000 0.056000 +0.750000 0.228900 -0.060900 0.576000 0.696000 -0.416000 +0.787300 0.200800 -0.060900 0.520000 0.824000 -0.184000 +0.750000 0.200800 -0.104400 0.480000 0.680000 -0.544000 +0.800000 0.194300 -0.060900 0.416000 0.824000 -0.360000 +0.750000 0.186400 -0.121900 0.504000 0.648000 -0.560000 +0.800000 0.164900 -0.121900 0.312000 0.800000 -0.504000 +0.750000 0.157000 -0.182900 0.280000 0.720000 -0.624000 +0.800000 0.150600 -0.164100 0.256000 0.800000 -0.528000 +0.769100 0.150600 -0.182900 0.248000 0.704000 -0.648000 +0.800000 0.138600 -0.182900 0.232000 0.712000 -0.656000 +0.750000 0.150600 -0.191500 0.256000 0.656000 -0.704000 +0.800000 0.100400 -0.216300 0.104000 0.416000 -0.896000 +0.750000 0.100400 -0.218500 0.200000 0.232000 -0.944000 +0.800000 0.050200 -0.233400 -0.176000 0.416000 -0.880000 +0.750000 0.050200 -0.223600 -0.168000 -0.552000 -0.808000 +0.800000 0.000000 -0.217200 -0.656000 -0.464000 -0.584000 +0.750000 0.019900 -0.182900 -0.176000 -0.792000 -0.576000 +0.776700 0.000000 -0.182900 -0.576000 -0.728000 -0.360000 +0.750000 0.004300 -0.121900 -0.408000 -0.880000 -0.216000 +0.756600 0.000000 -0.121900 -0.496000 -0.856000 -0.080000 +0.750000 0.001600 -0.060900 -0.416000 -0.904000 -0.016000 +0.753100 0.000000 -0.060900 -0.472000 -0.872000 0.000000 +0.750000 0.013300 0.000000 -0.240000 -0.936000 0.240000 +0.772100 0.000000 0.000000 -0.504000 -0.832000 0.224000 +0.750000 0.031700 0.060900 -0.136000 -0.928000 0.336000 +0.798100 0.000000 0.060900 -0.504000 -0.792000 0.312000 +0.772100 0.000000 0.000000 -0.504000 -0.832000 0.224000 +0.800000 -0.001000 0.060900 -0.584000 -0.776000 0.216000 +0.800000 -0.015400 0.000000 -0.560000 -0.800000 0.184000 +0.843600 -0.050200 0.060900 -0.704000 -0.672000 0.184000 +0.832800 -0.050200 0.000000 -0.728000 -0.656000 0.144000 +0.800000 -0.015400 0.000000 -0.560000 -0.800000 0.184000 +0.823600 -0.050200 -0.060900 -0.736000 -0.664000 0.112000 +0.800000 -0.024700 -0.060900 -0.616000 -0.776000 0.088000 +0.818400 -0.050200 -0.121900 -0.760000 -0.640000 0.016000 +0.800000 -0.027900 -0.121900 -0.664000 -0.736000 -0.072000 +0.822900 -0.050200 -0.182900 -0.792000 -0.592000 -0.088000 +0.800000 -0.017800 -0.182900 -0.616000 -0.680000 -0.376000 +0.835300 -0.050200 -0.243900 -0.840000 -0.416000 -0.336000 +0.800000 0.000000 -0.217200 -0.656000 -0.464000 -0.584000 +0.819700 0.000000 -0.243900 -0.752000 -0.192000 -0.616000 +0.819700 0.000000 -0.243900 -0.752000 -0.192000 -0.616000 +0.788900 0.200800 0.121900 0.632000 0.744000 0.184000 +0.788900 0.200800 0.121900 0.632000 0.744000 0.184000 +0.800000 0.190400 0.121900 0.624000 0.752000 0.168000 +0.772600 0.200800 0.060900 0.648000 0.736000 -0.136000 +0.800000 0.182100 0.060900 0.560000 0.824000 -0.024000 +0.770200 0.200800 0.000000 0.616000 0.776000 0.056000 +0.800000 0.184600 0.000000 0.464000 0.872000 0.120000 +0.787300 0.200800 -0.060900 0.520000 0.824000 -0.184000 +0.800000 0.194300 -0.060900 0.416000 0.824000 -0.360000 +0.800000 0.194300 -0.060900 0.416000 0.824000 -0.360000 +0.800000 0.028400 0.121900 -0.376000 -0.808000 0.432000 +0.800000 0.028400 0.121900 -0.376000 -0.808000 0.432000 +0.829700 0.000000 0.121900 -0.704000 -0.616000 0.344000 +0.800000 0.000000 0.064400 -0.576000 -0.736000 0.344000 +0.800000 0.000000 0.064400 -0.576000 -0.736000 0.344000 +0.911800 0.100400 0.121900 0.528000 0.800000 0.264000 +0.911800 0.100400 0.121900 0.528000 0.800000 0.264000 +0.950000 0.069700 0.121900 0.360000 0.840000 0.384000 +0.936800 0.100400 0.060900 0.456000 0.872000 0.168000 +0.950000 0.091300 0.060900 0.600000 0.776000 0.176000 +0.950000 0.100400 0.012800 0.496000 0.848000 0.136000 +1.000000 0.068400 0.060900 0.464000 0.872000 0.104000 +0.952900 0.100400 0.000000 0.504000 0.848000 0.120000 +1.000000 0.075000 0.000000 0.472000 0.872000 0.072000 +0.957800 0.100400 -0.060900 0.544000 0.824000 -0.120000 +1.000000 0.074600 -0.060900 0.496000 0.816000 -0.280000 +1.000000 0.074600 -0.060900 0.496000 0.816000 -0.280000 +0.950000 -0.142500 0.121900 -0.608000 -0.672000 0.392000 +0.950000 -0.142500 0.121900 -0.608000 -0.672000 0.392000 +0.950000 -0.150600 0.094900 -0.648000 -0.696000 0.272000 +0.900000 -0.107100 0.121900 -0.584000 -0.768000 0.240000 +0.942000 -0.150600 0.060900 -0.704000 -0.672000 0.200000 +0.900000 -0.117100 0.060900 -0.656000 -0.736000 0.136000 +0.931300 -0.150600 0.000000 -0.640000 -0.744000 0.144000 +0.900000 -0.125700 0.000000 -0.664000 -0.728000 0.136000 +0.917800 -0.150600 -0.060900 -0.640000 -0.736000 0.184000 +0.900000 -0.135500 -0.060900 -0.672000 -0.712000 0.168000 +0.902600 -0.150600 -0.121900 -0.664000 -0.736000 0.096000 +0.900000 -0.148200 -0.121900 -0.664000 -0.728000 0.088000 +0.900000 -0.150600 -0.145400 -0.696000 -0.704000 0.104000 +0.902600 -0.150600 -0.121900 -0.664000 -0.736000 0.096000 +0.900000 -0.155900 -0.182900 -0.744000 -0.648000 0.112000 +0.950000 -0.200400 -0.121900 -0.720000 -0.672000 0.136000 +0.939100 -0.200800 -0.182900 -0.712000 -0.672000 0.160000 +0.950000 -0.200800 -0.124000 -0.680000 -0.712000 0.160000 +0.950000 -0.211700 -0.182900 -0.704000 -0.680000 0.176000 +0.939100 -0.200800 -0.182900 -0.712000 -0.672000 0.160000 +0.950000 -0.224400 -0.243900 -0.688000 -0.640000 0.328000 +0.928800 -0.200800 -0.243900 -0.736000 -0.616000 0.240000 +0.939100 -0.200800 -0.182900 -0.712000 -0.672000 0.160000 +0.900000 -0.163000 -0.243900 -0.816000 -0.552000 0.128000 +0.900000 -0.155900 -0.182900 -0.744000 -0.648000 0.112000 +0.890800 -0.150600 -0.243900 -0.848000 -0.512000 0.064000 +0.895100 -0.150600 -0.182900 -0.744000 -0.648000 0.104000 +0.900000 -0.155900 -0.182900 -0.744000 -0.648000 0.112000 +0.900000 -0.150600 -0.145400 -0.696000 -0.704000 0.104000 +0.900000 -0.150600 -0.145400 -0.696000 -0.704000 0.104000 +0.950000 -0.150600 0.094900 -0.648000 -0.696000 0.272000 +0.950000 -0.150600 0.094900 -0.648000 -0.696000 0.272000 +0.950000 -0.158100 0.060900 -0.608000 -0.760000 0.200000 +0.942000 -0.150600 0.060900 -0.704000 -0.672000 0.200000 +0.950000 -0.168100 0.000000 -0.640000 -0.744000 0.184000 +0.931300 -0.150600 0.000000 -0.640000 -0.744000 0.144000 +0.950000 -0.183700 -0.060900 -0.632000 -0.728000 0.232000 +0.917800 -0.150600 -0.060900 -0.640000 -0.736000 0.184000 +0.950000 -0.200400 -0.121900 -0.720000 -0.672000 0.136000 +0.902600 -0.150600 -0.121900 -0.664000 -0.736000 0.096000 +0.902600 -0.150600 -0.121900 -0.664000 -0.736000 0.096000 +1.000000 0.053600 0.121900 0.280000 0.872000 0.392000 +1.000000 0.053600 0.121900 0.280000 0.872000 0.392000 +0.950000 0.069700 0.121900 0.360000 0.840000 0.384000 +1.000000 0.068400 0.060900 0.464000 0.872000 0.104000 +0.950000 0.091300 0.060900 0.600000 0.776000 0.176000 +0.950000 0.091300 0.060900 0.600000 0.776000 0.176000 +-1.000000 -0.090800 0.060900 -0.320000 -0.912000 0.248000 +-1.000000 -0.090800 0.060900 -0.320000 -0.912000 0.248000 +-0.973400 -0.100400 0.060900 -0.344000 -0.904000 0.240000 +-1.000000 -0.100400 0.014600 -0.304000 -0.920000 0.208000 +-1.000000 -0.100400 0.014600 -0.304000 -0.920000 0.208000 +-0.950000 0.258900 0.000000 0.296000 0.848000 0.432000 +-0.950000 0.258900 0.000000 0.296000 0.848000 0.432000 +-0.928700 0.251000 0.000000 0.312000 0.848000 0.408000 +-0.950000 0.251000 0.016800 0.288000 0.808000 0.504000 +-0.950000 0.251000 0.016800 0.288000 0.808000 0.504000 +-0.900000 -0.149700 0.060900 -0.696000 -0.664000 0.232000 +-0.900000 -0.149700 0.060900 -0.696000 -0.664000 0.232000 +-0.899200 -0.150600 0.060900 -0.816000 -0.504000 0.256000 +-0.900000 -0.150600 0.057700 -0.744000 -0.616000 0.232000 +-0.900000 -0.150600 0.057700 -0.744000 -0.616000 0.232000 +-0.750000 0.106000 0.060900 0.496000 0.464000 0.728000 +-0.750000 0.106000 0.060900 0.496000 0.464000 0.728000 +-0.796300 0.150600 0.060900 0.512000 0.584000 0.616000 +-0.750000 0.150600 0.014500 0.472000 0.624000 0.608000 +-0.750000 0.150600 0.014500 0.472000 0.624000 0.608000 +-0.750800 -0.401700 0.000000 -0.816000 -0.520000 0.208000 +-0.750800 -0.401700 0.000000 -0.816000 -0.520000 0.208000 +-0.750000 -0.401700 0.004100 -0.816000 -0.520000 0.232000 +-0.750000 -0.403200 0.000000 -0.832000 -0.504000 0.216000 +-0.750000 -0.403200 0.000000 -0.832000 -0.504000 0.216000 +-0.700000 0.051600 0.060900 0.528000 0.416000 0.728000 +-0.700000 0.051600 0.060900 0.528000 0.416000 0.728000 +-0.744800 0.100400 0.060900 0.496000 0.456000 0.728000 +-0.700000 0.100400 0.019100 0.504000 0.504000 0.688000 +-0.700000 0.100400 0.019100 0.504000 0.504000 0.688000 +-0.700000 0.121800 0.000000 0.536000 0.544000 0.632000 +-0.700000 0.121800 0.000000 0.536000 0.544000 0.632000 +-0.680200 0.100400 0.000000 0.600000 0.440000 0.656000 +-0.700000 0.100400 0.019100 0.504000 0.504000 0.688000 +-0.700000 0.100400 0.019100 0.504000 0.504000 0.688000 +-0.650000 -0.023500 0.060900 0.576000 0.360000 0.720000 +-0.650000 -0.023500 0.060900 0.576000 0.360000 0.720000 +-0.666100 0.000000 0.060900 0.560000 0.376000 0.728000 +-0.650000 0.000000 0.045200 0.576000 0.400000 0.704000 +-0.650000 0.000000 0.045200 0.576000 0.400000 0.704000 +-0.650000 0.063100 0.000000 0.592000 0.392000 0.696000 +-0.650000 0.063100 0.000000 0.592000 0.392000 0.696000 +-0.641800 0.050200 0.000000 0.616000 0.400000 0.664000 +-0.650000 0.050200 0.008200 0.568000 0.384000 0.720000 +-0.650000 0.050200 0.008200 0.568000 0.384000 0.720000 +-0.650000 -0.495900 0.060900 -0.528000 -0.720000 0.432000 +-0.650000 -0.495900 0.060900 -0.528000 -0.720000 0.432000 +-0.640700 -0.502100 0.060900 -0.496000 -0.728000 0.456000 +-0.650000 -0.502100 0.048300 -0.536000 -0.712000 0.440000 +-0.650000 -0.502100 0.048300 -0.536000 -0.712000 0.440000 +-0.633400 -0.552300 0.000000 -0.384000 -0.672000 0.624000 +-0.633400 -0.552300 0.000000 -0.384000 -0.672000 0.624000 +-0.600000 -0.552300 0.023900 -0.224000 -0.776000 0.584000 +-0.600000 -0.566300 0.000000 -0.184000 -0.816000 0.544000 +-0.550000 -0.552300 0.031000 0.256000 -0.800000 0.528000 +-0.550000 -0.565800 0.000000 0.224000 -0.872000 0.424000 +-0.509600 -0.552300 0.000000 0.320000 -0.840000 0.424000 +-0.509600 -0.552300 0.000000 0.320000 -0.840000 0.424000 +-0.600000 -0.018300 0.000000 0.712000 0.368000 0.584000 +-0.600000 -0.018300 0.000000 0.712000 0.368000 0.584000 +-0.584800 -0.050200 0.000000 0.744000 0.336000 0.568000 +-0.600000 -0.050200 0.018400 0.648000 0.320000 0.688000 +-0.600000 -0.050200 0.018400 0.648000 0.320000 0.688000 +-0.472400 -0.150600 0.060900 -0.464000 0.768000 0.416000 +-0.472400 -0.150600 0.060900 -0.464000 0.768000 0.416000 +-0.500000 -0.166600 0.060900 -0.304000 0.832000 0.448000 +-0.500000 -0.150600 0.019400 -0.216000 0.856000 0.464000 +-0.500000 -0.150600 0.019400 -0.216000 0.856000 0.464000 +-0.434300 -0.100400 0.000000 -0.648000 0.720000 0.208000 +-0.434300 -0.100400 0.000000 -0.648000 0.720000 0.208000 +-0.405500 -0.100400 0.060900 -0.712000 0.456000 0.520000 +-0.400000 -0.050900 0.000000 -0.776000 0.576000 0.224000 +-0.400000 -0.090100 0.060900 -0.696000 0.400000 0.584000 +-0.399300 -0.050200 0.000000 -0.696000 0.680000 0.184000 +-0.367400 -0.050200 0.060900 -0.696000 0.408000 0.584000 +-0.367400 -0.050200 0.060900 -0.696000 0.408000 0.584000 +-0.355100 0.050200 0.000000 -0.872000 0.216000 0.416000 +-0.355100 0.050200 0.000000 -0.872000 0.216000 0.416000 +-0.350000 0.077100 0.000000 -0.776000 0.256000 0.568000 +-0.350000 0.050200 0.010900 -0.568000 0.448000 0.680000 +-0.321000 0.100400 0.000000 -0.264000 0.416000 0.864000 +-0.300000 0.050200 0.038600 -0.224000 0.544000 0.800000 +-0.300000 0.100400 0.006400 -0.200000 0.408000 0.880000 +-0.250000 0.050200 0.048300 0.000000 0.552000 0.832000 +-0.250000 0.100400 0.002600 0.144000 0.496000 0.848000 +-0.250000 0.100400 0.002600 0.144000 0.496000 0.848000 +-0.350000 0.000000 0.059800 -0.688000 0.400000 0.592000 +-0.350000 0.000000 0.059800 -0.688000 0.400000 0.592000 +-0.350000 0.050200 0.010900 -0.568000 0.448000 0.680000 +-0.373100 0.000000 0.000000 -0.880000 0.240000 0.392000 +-0.355100 0.050200 0.000000 -0.872000 0.216000 0.416000 +-0.377800 0.000000 -0.060900 -0.864000 0.424000 -0.248000 +-0.358600 0.050200 -0.060900 -0.920000 0.168000 -0.328000 +-0.372200 0.000000 -0.121900 -0.848000 0.480000 -0.200000 +-0.350000 0.050200 -0.078800 -0.832000 0.272000 -0.472000 +-0.350000 0.031200 -0.121900 -0.744000 0.552000 -0.352000 +-0.335400 0.050200 -0.121900 -0.752000 0.472000 -0.456000 +-0.350000 0.000000 -0.171400 -0.688000 0.416000 -0.584000 +-0.301000 0.050200 -0.182900 -0.704000 0.472000 -0.512000 +-0.340600 0.000000 -0.182900 -0.696000 0.480000 -0.520000 +-0.350000 0.000000 -0.171400 -0.688000 0.416000 -0.584000 +-0.350000 -0.016600 -0.182900 -0.688000 0.360000 -0.616000 +-0.372200 0.000000 -0.121900 -0.848000 0.480000 -0.200000 +-0.365500 -0.050200 -0.182900 -0.728000 0.384000 -0.560000 +-0.399400 -0.050200 -0.121900 -0.760000 0.504000 -0.392000 +-0.400000 -0.096400 -0.182900 -0.664000 0.552000 -0.496000 +-0.400000 -0.050900 -0.121900 -0.736000 0.536000 -0.408000 +-0.403600 -0.100400 -0.182900 -0.616000 0.592000 -0.512000 +-0.434900 -0.100400 -0.121900 -0.608000 0.744000 -0.256000 +-0.434900 -0.100400 -0.121900 -0.608000 0.744000 -0.256000 +-0.350000 0.000000 0.059800 -0.688000 0.400000 0.592000 +-0.350000 0.000000 0.059800 -0.688000 0.400000 0.592000 +-0.350000 0.050200 0.010900 -0.568000 0.448000 0.680000 +-0.348200 0.000000 0.060900 -0.376000 0.448000 0.800000 +-0.300000 0.050200 0.038600 -0.224000 0.544000 0.800000 +-0.300000 0.027200 0.060900 -0.160000 0.552000 0.808000 +-0.250000 0.050200 0.048300 0.000000 0.552000 0.832000 +-0.250000 0.033500 0.060900 0.056000 0.528000 0.840000 +-0.200000 0.050200 0.037800 0.512000 0.448000 0.720000 +-0.200000 0.020500 0.060900 0.664000 0.440000 0.600000 +-0.200000 0.020500 0.060900 0.664000 0.440000 0.600000 +-0.208400 0.401700 0.000000 -0.424000 0.248000 0.864000 +-0.208400 0.401700 0.000000 -0.424000 0.248000 0.864000 +-0.200000 0.408700 0.000000 -0.112000 0.496000 0.856000 +-0.200000 0.401700 0.005100 -0.168000 0.288000 0.936000 +-0.185900 0.401700 0.000000 0.264000 0.248000 0.928000 +-0.200000 0.384800 0.000000 -0.112000 -0.232000 0.960000 +-0.150000 0.401700 -0.011900 0.240000 0.256000 0.928000 +-0.200000 0.351500 -0.009600 0.208000 -0.208000 0.952000 +-0.150000 0.351500 -0.029900 0.096000 -0.168000 0.976000 +-0.200000 0.301200 -0.022600 0.056000 -0.176000 0.976000 +-0.150000 0.301200 -0.033800 0.040000 -0.024000 0.992000 +-0.200000 0.251000 -0.048300 -0.120000 -0.296000 0.944000 +-0.150000 0.251000 -0.027500 -0.136000 -0.104000 0.984000 +-0.200000 0.206100 -0.060900 -0.448000 -0.184000 0.872000 +-0.150000 0.200800 -0.027500 -0.320000 -0.168000 0.928000 +-0.198000 0.200800 -0.060900 -0.464000 0.288000 0.832000 +-0.150000 0.150600 -0.037800 0.256000 -0.016000 0.960000 +-0.200000 0.199100 -0.060900 -0.320000 0.504000 0.792000 +-0.200000 0.150600 -0.023100 -0.360000 0.472000 0.792000 +-0.250000 0.177000 -0.060900 -0.096000 0.568000 0.808000 +-0.250000 0.150600 -0.042200 0.008000 0.568000 0.816000 +-0.277600 0.200800 -0.060900 0.584000 -0.072000 0.800000 +-0.300000 0.150600 -0.036000 -0.360000 0.064000 0.920000 +-0.300000 0.200800 -0.040500 0.440000 0.208000 0.864000 +-0.346000 0.150600 -0.060900 -0.768000 -0.144000 0.616000 +-0.350000 0.200800 -0.003200 -0.528000 -0.104000 0.832000 +-0.350000 0.153200 -0.060900 -0.608000 -0.784000 0.016000 +-0.368900 0.200800 -0.060900 -0.952000 0.040000 -0.280000 +-0.350000 0.200800 -0.076700 -0.368000 -0.104000 -0.920000 +-0.356100 0.251000 -0.060900 -0.936000 0.104000 -0.312000 +-0.350000 0.251000 -0.067500 -0.624000 0.048000 -0.768000 +-0.353500 0.301200 -0.060900 -0.872000 0.080000 -0.464000 +-0.350000 0.301200 -0.064600 -0.624000 0.064000 -0.768000 +-0.350000 0.329400 -0.060900 -0.960000 0.152000 -0.224000 +-0.300000 0.301200 -0.089300 -0.344000 0.056000 -0.936000 +-0.344500 0.351500 -0.060900 -0.776000 0.288000 0.552000 +-0.300000 0.351500 -0.083400 -0.432000 0.176000 -0.880000 +-0.307400 0.401700 -0.060900 -0.696000 0.688000 -0.152000 +-0.300000 0.401700 -0.066400 -0.448000 0.440000 -0.768000 +-0.300000 0.408800 -0.060900 -0.664000 0.712000 -0.184000 +-0.250000 0.401700 -0.091800 -0.416000 0.456000 -0.776000 +-0.250000 0.447500 -0.060900 -0.512000 0.744000 0.408000 +-0.208300 0.401700 -0.121900 -0.432000 0.432000 -0.784000 +-0.242600 0.451900 -0.060900 -0.440000 0.728000 0.512000 +-0.200000 0.409200 -0.121900 -0.400000 0.464000 -0.776000 +-0.200000 0.451900 -0.081300 -0.400000 0.504000 -0.752000 +-0.152100 0.451900 -0.121900 -0.424000 0.536000 -0.720000 +-0.200000 0.477600 -0.060900 -0.544000 0.808000 -0.208000 +-0.150000 0.453400 -0.121900 -0.320000 0.624000 -0.704000 +-0.150000 0.501300 -0.060900 -0.376000 0.880000 -0.280000 +-0.100000 0.479800 -0.121900 -0.288000 0.584000 -0.752000 +-0.146800 0.502100 -0.060900 -0.272000 0.960000 0.016000 +-0.100000 0.502100 -0.081300 -0.184000 0.840000 -0.488000 +-0.100000 0.517800 -0.060900 -0.120000 0.976000 0.136000 +-0.050000 0.502100 -0.117100 -0.040000 0.912000 -0.392000 +-0.050000 0.515300 -0.060900 0.432000 0.792000 0.408000 +-0.033200 0.502100 -0.060900 0.616000 0.496000 0.600000 +-0.050000 0.502100 -0.046900 0.400000 0.496000 0.760000 +-0.023600 0.451900 -0.060900 0.376000 0.152000 0.904000 +-0.050000 0.451900 -0.049700 0.432000 0.024000 0.896000 +-0.005200 0.401700 -0.060900 0.264000 0.168000 0.944000 +-0.050000 0.401700 -0.052300 0.176000 0.040000 0.976000 +0.000000 0.393800 -0.060900 0.224000 0.176000 0.952000 +-0.050000 0.351500 -0.043600 0.248000 0.032000 0.960000 +0.000000 0.351500 -0.051600 0.280000 -0.248000 0.920000 +-0.050000 0.301200 -0.044600 0.440000 -0.008000 0.896000 +0.000000 0.334500 -0.060900 0.312000 -0.368000 0.864000 +-0.027600 0.301200 -0.060900 0.456000 -0.208000 0.856000 +0.000000 0.301200 -0.076500 0.296000 -0.272000 0.904000 +-0.035000 0.251000 -0.060900 0.512000 -0.448000 0.728000 +0.000000 0.251000 -0.086600 0.344000 -0.360000 0.864000 +-0.050000 0.236000 -0.060900 0.536000 -0.496000 0.672000 +0.000000 0.211400 -0.121900 0.496000 -0.712000 0.480000 +-0.050000 0.200800 -0.090500 0.520000 -0.520000 0.672000 +-0.012800 0.200800 -0.121900 0.688000 -0.616000 0.376000 +-0.050000 0.170300 -0.121900 0.584000 -0.576000 0.560000 +0.000000 0.200800 -0.169000 0.576000 -0.744000 0.320000 +-0.050000 0.150600 -0.159500 0.712000 -0.480000 0.504000 +0.000000 0.195100 -0.182900 0.504000 -0.656000 -0.544000 +-0.033200 0.150600 -0.182900 0.832000 -0.552000 -0.016000 +0.000000 0.200800 -0.186400 0.272000 -0.456000 -0.840000 +-0.050000 0.150600 -0.210200 0.840000 -0.208000 -0.496000 +-0.050000 0.200800 -0.204500 0.304000 -0.328000 -0.888000 +-0.077600 0.150600 -0.243900 0.320000 0.328000 -0.880000 +-0.100000 0.200800 -0.221500 0.056000 0.392000 -0.912000 +-0.100000 0.164100 -0.243900 -0.032000 0.432000 -0.896000 +-0.150000 0.200800 -0.199200 -0.328000 0.272000 -0.896000 +-0.126800 0.150600 -0.243900 -0.208000 0.496000 -0.832000 +-0.150000 0.150600 -0.235500 -0.296000 0.536000 -0.784000 +-0.150000 0.141700 -0.243900 -0.352000 0.528000 -0.768000 +-0.200000 0.150600 -0.197300 -0.488000 0.464000 -0.728000 +-0.198500 0.100400 -0.243900 -0.376000 0.480000 -0.784000 +-0.200000 0.100400 -0.242800 -0.520000 0.512000 -0.672000 +-0.200000 0.099300 -0.243900 -0.456000 0.488000 -0.736000 +-0.249100 0.100400 -0.182900 -0.576000 0.496000 -0.640000 +-0.250000 0.055800 -0.243900 -0.560000 0.648000 -0.504000 +-0.250000 0.099600 -0.182900 -0.488000 0.616000 -0.608000 +-0.256300 0.050200 -0.243900 -0.592000 0.624000 -0.488000 +-0.300000 0.052000 -0.182900 -0.664000 0.464000 -0.568000 +-0.300000 0.050200 -0.185100 -0.648000 0.560000 -0.504000 +-0.256300 0.050200 -0.243900 -0.592000 0.624000 -0.488000 +-0.300000 0.001800 -0.243900 -0.496000 0.680000 -0.520000 +-0.250000 0.050200 -0.254100 -0.584000 0.656000 -0.464000 +-0.300000 0.000000 -0.248500 -0.656000 0.560000 -0.488000 +-0.250000 0.000000 -0.286200 -0.320000 0.712000 -0.616000 +-0.300000 -0.050200 -0.270300 -0.824000 0.232000 -0.512000 +-0.250000 -0.028200 -0.304800 -0.400000 0.416000 -0.808000 +-0.266700 -0.050200 -0.304800 -0.504000 0.288000 -0.808000 +-0.250000 -0.050200 -0.318700 -0.440000 0.320000 -0.832000 +-0.288100 -0.100400 -0.304800 -0.408000 0.240000 -0.872000 +-0.250000 -0.100400 -0.327300 -0.384000 0.152000 -0.904000 +-0.300000 -0.118900 -0.304800 -0.376000 0.264000 -0.880000 +-0.250000 -0.150600 -0.327500 -0.120000 0.152000 -0.976000 +-0.300000 -0.150600 -0.319300 -0.256000 0.480000 -0.832000 +-0.250000 -0.200800 -0.333200 0.168000 0.080000 -0.976000 +-0.300000 -0.200800 -0.340600 0.016000 0.280000 -0.952000 +-0.250000 -0.251000 -0.337900 0.384000 0.112000 -0.912000 +-0.300000 -0.251000 -0.348000 0.192000 0.248000 -0.944000 +-0.250000 -0.301200 -0.349000 0.296000 0.272000 -0.912000 +-0.300000 -0.296900 -0.365800 0.296000 0.528000 -0.784000 +-0.291400 -0.301200 -0.365800 0.272000 0.504000 -0.808000 +-0.300000 -0.301200 -0.369600 0.320000 0.544000 -0.768000 +-0.250000 -0.342900 -0.365800 0.504000 0.512000 -0.680000 +-0.300000 -0.341100 -0.426800 -0.128000 0.536000 -0.832000 +-0.250000 -0.351500 -0.379700 0.552000 0.712000 -0.416000 +-0.273100 -0.351500 -0.426800 0.480000 0.752000 -0.440000 +-0.250000 -0.368100 -0.426800 0.504000 0.792000 -0.336000 +-0.250000 -0.351500 -0.379700 0.552000 0.712000 -0.416000 +-0.200000 -0.393200 -0.426800 0.696000 0.632000 -0.328000 +-0.241400 -0.351500 -0.365800 0.488000 0.640000 -0.576000 +-0.200000 -0.365300 -0.365800 0.504000 0.768000 -0.376000 +-0.200000 -0.351500 -0.343300 0.312000 0.640000 -0.696000 +-0.241400 -0.351500 -0.365800 0.488000 0.640000 -0.576000 +-0.200000 -0.301200 -0.313400 0.328000 0.152000 -0.928000 +-0.250000 -0.342900 -0.365800 0.504000 0.512000 -0.680000 +-0.250000 -0.301200 -0.349000 0.296000 0.272000 -0.912000 +-0.291400 -0.301200 -0.365800 0.272000 0.504000 -0.808000 +-0.291400 -0.301200 -0.365800 0.272000 0.504000 -0.808000 +-0.200000 0.401700 0.005100 -0.168000 0.288000 0.936000 +-0.200000 0.401700 0.005100 -0.168000 0.288000 0.936000 +-0.200000 0.384800 0.000000 -0.112000 -0.232000 0.960000 +-0.208400 0.401700 0.000000 -0.424000 0.248000 0.864000 +-0.200000 0.351500 -0.009600 0.208000 -0.208000 0.952000 +-0.250000 0.401700 -0.023000 -0.400000 -0.016000 0.912000 +-0.250000 0.351500 -0.004200 0.040000 0.000000 0.992000 +-0.300000 0.401700 -0.053800 -0.512000 0.520000 0.672000 +-0.300000 0.351500 -0.024700 -0.384000 0.216000 0.896000 +-0.307400 0.401700 -0.060900 -0.696000 0.688000 -0.152000 +-0.344500 0.351500 -0.060900 -0.776000 0.288000 0.552000 +-0.300000 0.351500 -0.024700 -0.384000 0.216000 0.896000 +-0.350000 0.329400 -0.060900 -0.960000 0.152000 -0.224000 +-0.300000 0.301200 -0.020200 -0.184000 0.032000 0.976000 +-0.350000 0.301200 -0.051600 -0.832000 0.120000 0.528000 +-0.300000 0.251000 -0.020200 0.208000 -0.160000 0.960000 +-0.350000 0.251000 -0.040500 -0.808000 0.200000 0.544000 +-0.300000 0.200800 -0.040500 0.440000 0.208000 0.864000 +-0.350000 0.200800 -0.003200 -0.528000 -0.104000 0.832000 +-0.350000 0.251000 -0.040500 -0.808000 0.200000 0.544000 +-0.368900 0.200800 -0.060900 -0.952000 0.040000 -0.280000 +-0.356100 0.251000 -0.060900 -0.936000 0.104000 -0.312000 +-0.350000 0.251000 -0.040500 -0.808000 0.200000 0.544000 +-0.353500 0.301200 -0.060900 -0.872000 0.080000 -0.464000 +-0.350000 0.301200 -0.051600 -0.832000 0.120000 0.528000 +-0.350000 0.329400 -0.060900 -0.960000 0.152000 -0.224000 +-0.350000 0.329400 -0.060900 -0.960000 0.152000 -0.224000 +-0.250000 -0.301200 0.006000 0.344000 -0.608000 0.704000 +-0.250000 -0.301200 0.006000 0.344000 -0.608000 0.704000 +-0.235900 -0.301200 0.000000 0.272000 -0.568000 0.768000 +-0.250000 -0.307700 0.000000 0.288000 -0.576000 0.760000 +-0.250000 -0.307700 0.000000 0.288000 -0.576000 0.760000 +-0.169100 -0.301200 0.000000 -0.376000 -0.392000 0.832000 +-0.169100 -0.301200 0.000000 -0.376000 -0.392000 0.832000 +-0.150000 -0.301200 0.010200 -0.304000 -0.280000 0.904000 +-0.150000 -0.346200 0.000000 -0.392000 -0.160000 0.904000 +-0.100000 -0.301200 0.037800 -0.016000 -0.152000 0.984000 +-0.100000 -0.344900 0.000000 0.072000 -0.528000 0.840000 +-0.050000 -0.301200 0.029100 0.312000 -0.280000 0.904000 +-0.050000 -0.329200 0.000000 0.264000 -0.624000 0.720000 +-0.002200 -0.301200 0.000000 0.384000 -0.648000 0.648000 +-0.050000 -0.351500 -0.027000 0.488000 -0.688000 0.528000 +0.000000 -0.301200 -0.001900 0.408000 -0.704000 0.568000 +-0.029100 -0.351500 -0.060900 0.584000 -0.680000 0.424000 +0.000000 -0.326800 -0.060900 0.344000 -0.824000 0.432000 +0.000000 -0.351500 -0.112600 0.544000 -0.704000 0.448000 +0.032200 -0.301200 -0.060900 0.552000 -0.696000 0.448000 +0.006400 -0.351500 -0.121900 0.552000 -0.776000 0.288000 +0.050000 -0.301200 -0.085900 0.528000 -0.704000 0.464000 +0.050000 -0.321600 -0.121900 0.584000 -0.712000 0.376000 +0.074000 -0.301200 -0.121900 0.536000 -0.792000 0.264000 +0.050000 -0.327900 -0.182900 0.552000 -0.824000 0.048000 +0.088900 -0.301200 -0.182900 0.488000 -0.864000 0.072000 +0.050000 -0.327900 -0.243900 0.480000 -0.872000 0.000000 +0.091700 -0.301200 -0.243900 0.488000 -0.864000 -0.008000 +0.050000 -0.326800 -0.304800 0.424000 -0.880000 -0.184000 +0.085600 -0.301200 -0.304800 0.544000 -0.768000 -0.320000 +0.050000 -0.303000 -0.365800 0.400000 -0.792000 -0.448000 +0.052200 -0.301200 -0.365800 0.552000 -0.720000 -0.416000 +0.050000 -0.301200 -0.369000 0.376000 -0.768000 -0.512000 +0.100000 -0.263400 -0.365800 0.480000 -0.672000 -0.544000 +0.050000 -0.251000 -0.406500 0.232000 -0.312000 -0.912000 +0.100000 -0.251000 -0.380100 0.472000 -0.384000 -0.784000 +0.050000 -0.206300 -0.365800 -0.112000 0.608000 -0.776000 +0.100000 -0.224900 -0.365800 0.352000 0.456000 -0.808000 +0.050000 -0.200800 -0.360800 -0.016000 0.576000 -0.808000 +0.100000 -0.200800 -0.352600 0.240000 0.528000 -0.800000 +0.100000 -0.224900 -0.365800 0.352000 0.456000 -0.808000 +0.150000 -0.200800 -0.325200 0.160000 0.176000 -0.968000 +0.118000 -0.251000 -0.365800 0.536000 -0.224000 -0.808000 +0.150000 -0.251000 -0.336000 0.080000 -0.336000 -0.928000 +0.100000 -0.263400 -0.365800 0.480000 -0.672000 -0.544000 +0.150000 -0.287400 -0.304800 0.000000 -0.712000 -0.688000 +0.100000 -0.292600 -0.304800 0.432000 -0.840000 -0.304000 +0.150000 -0.287700 -0.243900 -0.208000 -0.968000 0.064000 +0.100000 -0.296900 -0.243900 0.408000 -0.912000 0.000000 +0.150000 -0.278000 -0.182900 -0.064000 -0.936000 0.328000 +0.100000 -0.295100 -0.182900 0.440000 -0.880000 0.144000 +0.150000 -0.253200 -0.121900 0.192000 -0.808000 0.552000 +0.100000 -0.284500 -0.121900 0.464000 -0.744000 0.472000 +0.150000 -0.251000 -0.118100 0.224000 -0.792000 0.560000 +0.100000 -0.256900 -0.060900 0.456000 -0.800000 0.368000 +0.110300 -0.251000 -0.060900 0.504000 -0.760000 0.392000 +0.100000 -0.251000 -0.044600 0.544000 -0.608000 0.568000 +0.130700 -0.200800 -0.060900 0.504000 0.008000 0.856000 +0.100000 -0.200800 -0.044900 0.416000 0.232000 0.872000 +0.100000 -0.170000 -0.060900 0.256000 0.296000 0.912000 +0.050000 -0.200800 -0.016400 0.232000 0.648000 0.720000 +0.076800 -0.150600 -0.060900 0.208000 0.432000 0.872000 +0.050000 -0.150600 -0.053500 0.160000 0.448000 0.872000 +0.050000 -0.140200 -0.060900 0.152000 0.504000 0.848000 +0.000000 -0.150600 -0.047300 0.168000 0.600000 0.768000 +0.000000 -0.136800 -0.060900 0.088000 0.520000 0.840000 +-0.050000 -0.150600 -0.033100 0.152000 0.512000 0.840000 +-0.050000 -0.119400 -0.060900 0.168000 0.528000 0.824000 +-0.100000 -0.150600 -0.019000 0.512000 0.456000 0.720000 +-0.100000 -0.105500 -0.060900 0.480000 0.464000 0.736000 +-0.129500 -0.150600 0.000000 0.416000 0.264000 0.864000 +-0.104300 -0.100400 -0.060900 0.528000 0.416000 0.728000 +-0.150000 -0.104300 0.000000 0.496000 0.120000 0.848000 +-0.150000 -0.100400 -0.001300 0.848000 0.032000 0.520000 +-0.150600 -0.100400 0.000000 0.800000 0.040000 0.592000 +-0.150000 -0.050200 -0.005700 0.768000 -0.024000 0.632000 +-0.152800 -0.050200 0.000000 0.848000 0.032000 0.520000 +-0.150000 0.000000 -0.001200 0.744000 0.064000 0.656000 +-0.150800 0.000000 0.000000 0.744000 0.072000 0.656000 +-0.150000 0.050200 -0.012600 0.624000 0.240000 0.728000 +-0.163800 0.050200 0.000000 0.704000 0.216000 0.664000 +-0.150000 0.100400 -0.027500 0.432000 0.296000 0.848000 +-0.200000 0.089800 0.000000 0.216000 0.544000 0.800000 +-0.200000 0.100400 -0.008800 0.176000 0.488000 0.848000 +-0.238500 0.100400 0.000000 0.152000 0.496000 0.848000 +-0.200000 0.150600 -0.023100 -0.360000 0.472000 0.792000 +-0.250000 0.104200 0.000000 0.144000 0.480000 0.856000 +-0.250000 0.150600 -0.042200 0.008000 0.568000 0.816000 +-0.300000 0.112500 0.000000 -0.064000 0.472000 0.872000 +-0.300000 0.150600 -0.036000 -0.360000 0.064000 0.920000 +-0.300000 0.150600 -0.036000 -0.360000 0.064000 0.920000 +-0.150000 -0.104300 0.000000 0.496000 0.120000 0.848000 +-0.150000 -0.104300 0.000000 0.496000 0.120000 0.848000 +-0.129500 -0.150600 0.000000 0.416000 0.264000 0.864000 +-0.150000 -0.150600 0.010200 0.376000 0.208000 0.896000 +-0.100000 -0.188700 0.000000 0.176000 0.408000 0.888000 +-0.150000 -0.200800 0.013600 0.104000 0.200000 0.968000 +-0.100000 -0.200800 0.005100 0.056000 0.344000 0.936000 +-0.150000 -0.251000 0.002400 -0.056000 -0.176000 0.976000 +-0.100000 -0.251000 0.029400 -0.128000 0.120000 0.976000 +-0.150000 -0.301200 0.010200 -0.304000 -0.280000 0.904000 +-0.100000 -0.301200 0.037800 -0.016000 -0.152000 0.984000 +-0.100000 -0.251000 0.029400 -0.128000 0.120000 0.976000 +-0.050000 -0.301200 0.029100 0.312000 -0.280000 0.904000 +-0.050000 -0.251000 0.040700 0.136000 0.064000 0.984000 +-0.002200 -0.301200 0.000000 0.384000 -0.648000 0.648000 +0.000000 -0.251000 0.031300 0.424000 -0.232000 0.872000 +0.000000 -0.299000 0.000000 0.440000 -0.464000 0.760000 +0.050000 -0.251000 0.003400 0.512000 0.320000 0.792000 +0.050000 -0.253500 0.000000 0.448000 -0.608000 0.648000 +0.054200 -0.251000 0.000000 0.552000 0.192000 0.800000 +0.050000 -0.286400 -0.060900 0.528000 -0.720000 0.440000 +0.100000 -0.251000 -0.044600 0.544000 -0.608000 0.568000 +0.100000 -0.256900 -0.060900 0.456000 -0.800000 0.368000 +0.050000 -0.286400 -0.060900 0.528000 -0.720000 0.440000 +0.100000 -0.284500 -0.121900 0.464000 -0.744000 0.472000 +0.050000 -0.301200 -0.085900 0.528000 -0.704000 0.464000 +0.074000 -0.301200 -0.121900 0.536000 -0.792000 0.264000 +0.100000 -0.284500 -0.121900 0.464000 -0.744000 0.472000 +0.088900 -0.301200 -0.182900 0.488000 -0.864000 0.072000 +0.100000 -0.295100 -0.182900 0.440000 -0.880000 0.144000 +0.091700 -0.301200 -0.243900 0.488000 -0.864000 -0.008000 +0.100000 -0.296900 -0.243900 0.408000 -0.912000 0.000000 +0.085600 -0.301200 -0.304800 0.544000 -0.768000 -0.320000 +0.100000 -0.292600 -0.304800 0.432000 -0.840000 -0.304000 +0.052200 -0.301200 -0.365800 0.552000 -0.720000 -0.416000 +0.100000 -0.263400 -0.365800 0.480000 -0.672000 -0.544000 +0.100000 -0.263400 -0.365800 0.480000 -0.672000 -0.544000 +-0.100000 -0.200800 0.005100 0.056000 0.344000 0.936000 +-0.100000 -0.200800 0.005100 0.056000 0.344000 0.936000 +-0.050000 -0.200800 0.008600 0.032000 0.536000 0.840000 +-0.100000 -0.188700 0.000000 0.176000 0.408000 0.888000 +-0.050000 -0.190400 0.000000 0.096000 0.648000 0.744000 +-0.100000 -0.150600 -0.019000 0.512000 0.456000 0.720000 +-0.050000 -0.150600 -0.033100 0.152000 0.512000 0.840000 +-0.050000 -0.190400 0.000000 0.096000 0.648000 0.744000 +0.000000 -0.150600 -0.047300 0.168000 0.600000 0.768000 +0.000000 -0.198800 0.000000 0.160000 0.688000 0.704000 +0.050000 -0.150600 -0.053500 0.160000 0.448000 0.872000 +0.006800 -0.200800 0.000000 0.232000 0.576000 0.776000 +0.050000 -0.200800 -0.016400 0.232000 0.648000 0.720000 +0.050000 -0.244100 0.000000 0.488000 0.320000 0.800000 +0.100000 -0.200800 -0.044900 0.416000 0.232000 0.872000 +0.054200 -0.251000 0.000000 0.552000 0.192000 0.800000 +0.100000 -0.251000 -0.044600 0.544000 -0.608000 0.568000 +0.100000 -0.251000 -0.044600 0.544000 -0.608000 0.568000 +-0.100000 -0.200800 0.005100 0.056000 0.344000 0.936000 +-0.100000 -0.200800 0.005100 0.056000 0.344000 0.936000 +-0.100000 -0.251000 0.029400 -0.128000 0.120000 0.976000 +-0.050000 -0.200800 0.008600 0.032000 0.536000 0.840000 +-0.050000 -0.251000 0.040700 0.136000 0.064000 0.984000 +0.000000 -0.200800 0.002300 0.160000 0.560000 0.808000 +0.000000 -0.251000 0.031300 0.424000 -0.232000 0.872000 +0.006800 -0.200800 0.000000 0.232000 0.576000 0.776000 +0.050000 -0.251000 0.003400 0.512000 0.320000 0.792000 +0.050000 -0.244100 0.000000 0.488000 0.320000 0.800000 +0.054200 -0.251000 0.000000 0.552000 0.192000 0.800000 +0.054200 -0.251000 0.000000 0.552000 0.192000 0.800000 +-0.050000 -0.190400 0.000000 0.096000 0.648000 0.744000 +-0.050000 -0.190400 0.000000 0.096000 0.648000 0.744000 +-0.050000 -0.200800 0.008600 0.032000 0.536000 0.840000 +0.000000 -0.198800 0.000000 0.160000 0.688000 0.704000 +0.000000 -0.200800 0.002300 0.160000 0.560000 0.808000 +0.006800 -0.200800 0.000000 0.232000 0.576000 0.776000 +0.006800 -0.200800 0.000000 0.232000 0.576000 0.776000 +0.500000 0.245700 0.000000 -0.568000 0.120000 0.808000 +0.500000 0.245700 0.000000 -0.568000 0.120000 0.808000 +0.500000 0.200800 0.008600 -0.576000 -0.176000 0.792000 +0.488800 0.200800 0.000000 -0.512000 0.024000 0.856000 +0.500000 0.181600 0.000000 -0.600000 -0.304000 0.728000 +0.500000 0.181600 0.000000 -0.600000 -0.304000 0.728000 +0.550000 0.174700 0.060900 -0.744000 -0.320000 0.576000 +0.550000 0.174700 0.060900 -0.744000 -0.320000 0.576000 +0.560700 0.150600 0.060900 -0.704000 -0.368000 0.592000 +0.550000 0.150600 0.048400 -0.632000 -0.416000 0.640000 +0.550000 0.150600 0.048400 -0.632000 -0.416000 0.640000 +0.641200 0.050200 0.060900 -0.600000 -0.608000 0.512000 +0.641200 0.050200 0.060900 -0.600000 -0.608000 0.512000 +0.600000 0.093600 0.060900 -0.624000 -0.616000 0.464000 +0.602900 0.050200 0.000000 -0.576000 -0.704000 0.400000 +0.600000 0.053300 0.000000 -0.472000 -0.712000 0.512000 +0.600000 0.050200 -0.005300 -0.440000 -0.752000 0.480000 +0.600000 0.050200 -0.005300 -0.440000 -0.752000 0.480000 +-0.915700 -0.150600 0.000000 -0.696000 -0.672000 0.232000 +-0.915700 -0.150600 0.000000 -0.696000 -0.672000 0.232000 +-0.950000 -0.123700 0.000000 -0.488000 -0.840000 0.216000 +-0.932400 -0.150600 -0.060900 -0.688000 -0.696000 0.176000 +-0.950000 -0.136200 -0.060900 -0.528000 -0.832000 0.152000 +-0.943100 -0.150600 -0.121900 -0.672000 -0.720000 0.120000 +-0.950000 -0.144800 -0.121900 -0.536000 -0.832000 0.120000 +-0.950000 -0.150600 -0.169000 -0.584000 -0.792000 0.136000 +-0.943100 -0.150600 -0.121900 -0.672000 -0.720000 0.120000 +-0.950000 -0.152700 -0.182900 -0.600000 -0.784000 0.144000 +-0.903800 -0.200800 -0.121900 -0.696000 -0.704000 0.120000 +-0.907400 -0.200800 -0.182900 -0.688000 -0.712000 0.072000 +-0.950000 -0.152700 -0.182900 -0.600000 -0.784000 0.144000 +-0.914100 -0.200800 -0.243900 -0.664000 -0.728000 0.128000 +-0.950000 -0.161800 -0.243900 -0.584000 -0.784000 0.176000 +-0.931500 -0.200800 -0.304800 -0.648000 -0.520000 -0.544000 +-0.950000 -0.180000 -0.304800 -0.552000 -0.600000 -0.568000 +-0.900000 -0.200800 -0.331500 -0.576000 -0.328000 -0.736000 +-0.950000 -0.150600 -0.330800 -0.416000 -0.432000 -0.792000 +-0.900000 -0.150600 -0.338300 -0.216000 -0.104000 -0.968000 +-0.900000 -0.200800 -0.331500 -0.576000 -0.328000 -0.736000 +-0.850000 -0.150600 -0.349400 0.072000 0.056000 -0.992000 +-0.850000 -0.200800 -0.351200 -0.168000 0.112000 -0.976000 +-0.800000 -0.150600 -0.340500 0.312000 0.288000 -0.896000 +-0.800000 -0.200800 -0.355700 0.080000 0.256000 -0.960000 +-0.750000 -0.150600 -0.317800 0.416000 0.384000 -0.816000 +-0.750000 -0.200800 -0.348300 0.272000 0.384000 -0.872000 +-0.731900 -0.150600 -0.304800 0.424000 0.400000 -0.808000 +-0.700000 -0.200800 -0.326900 0.208000 0.528000 -0.816000 +-0.700000 -0.175200 -0.304800 0.352000 0.528000 -0.768000 +-0.651700 -0.200800 -0.304800 0.320000 0.544000 -0.768000 +-0.700000 -0.150600 -0.284500 0.376000 0.392000 -0.832000 +-0.650000 -0.200800 -0.303800 0.136000 0.680000 -0.712000 +-0.650000 -0.150600 -0.267500 0.376000 0.464000 -0.792000 +-0.650000 -0.150600 -0.267500 0.376000 0.464000 -0.792000 +-0.895700 -0.200800 -0.060900 -0.864000 -0.480000 0.136000 +-0.895700 -0.200800 -0.060900 -0.864000 -0.480000 0.136000 +-0.882700 -0.200800 0.000000 -0.840000 -0.496000 0.192000 +-0.860100 -0.251000 -0.060900 -0.808000 -0.568000 0.112000 +-0.852600 -0.251000 0.000000 -0.800000 -0.568000 0.168000 +-0.852600 -0.251000 0.000000 -0.800000 -0.568000 0.168000 +-0.700000 -0.502100 -0.057900 -0.752000 -0.512000 0.400000 +-0.700000 -0.502100 -0.057900 -0.752000 -0.512000 0.400000 +-0.700000 -0.507800 -0.060900 -0.864000 -0.200000 0.448000 +-0.701200 -0.502100 -0.060900 -0.816000 -0.416000 0.392000 +-0.700000 -0.552300 -0.082500 -0.736000 -0.280000 0.608000 +-0.723300 -0.502100 -0.121900 -0.896000 -0.224000 0.368000 +-0.750000 -0.552300 -0.119400 0.072000 0.512000 0.848000 +-0.750000 -0.549900 -0.121900 0.080000 0.648000 0.752000 +-0.800000 -0.552300 -0.095900 0.424000 0.264000 0.864000 +-0.800000 -0.539500 -0.121900 0.176000 0.680000 0.704000 +-0.850000 -0.552300 -0.082300 -0.704000 -0.480000 0.504000 +-0.850000 -0.519700 -0.121900 0.200000 0.624000 0.752000 +-0.868200 -0.552300 -0.121900 -0.520000 -0.224000 0.816000 +-0.850000 -0.502100 -0.144600 0.400000 0.776000 0.480000 +-0.900000 -0.511500 -0.121900 -0.520000 -0.664000 0.528000 +-0.878700 -0.502100 -0.121900 0.408000 0.368000 0.832000 +-0.900000 -0.502100 -0.104000 -0.752000 0.000000 0.656000 +-0.900000 -0.492700 -0.121900 -0.520000 0.712000 0.448000 +-0.906100 -0.502100 -0.121900 -0.920000 0.072000 0.376000 +-0.900000 -0.462200 -0.182900 0.320000 0.888000 0.304000 +-0.925200 -0.502100 -0.182900 -0.976000 -0.008000 0.208000 +-0.900000 -0.451900 -0.229200 0.512000 0.832000 0.168000 +-0.929300 -0.502100 -0.243900 -0.992000 0.064000 -0.008000 +-0.921000 -0.451900 -0.243900 -0.184000 0.968000 0.160000 +-0.920600 -0.502100 -0.304800 -0.888000 -0.288000 -0.344000 +-0.912200 -0.451900 -0.304800 -0.496000 0.720000 -0.464000 +-0.900000 -0.502100 -0.352600 -0.672000 0.128000 -0.720000 +-0.900000 -0.451900 -0.318500 0.104000 0.872000 -0.464000 +-0.864000 -0.502100 -0.365800 -0.304000 0.480000 -0.816000 +-0.891000 -0.451900 -0.304800 0.528000 0.824000 -0.192000 +-0.850000 -0.496800 -0.365800 -0.176000 0.616000 -0.760000 +-0.850000 -0.473200 -0.304800 0.272000 0.896000 -0.336000 +-0.800000 -0.496400 -0.365800 -0.664000 0.416000 -0.608000 +-0.800000 -0.473000 -0.304800 -0.736000 0.648000 -0.168000 +-0.786000 -0.451900 -0.365800 -0.872000 0.080000 -0.472000 +-0.787800 -0.451900 -0.304800 -0.984000 0.136000 -0.040000 +-0.796500 -0.401700 -0.365800 -0.952000 -0.168000 -0.232000 +-0.797400 -0.401700 -0.304800 -0.928000 -0.344000 0.056000 +-0.800000 -0.388500 -0.365800 -0.864000 -0.288000 -0.400000 +-0.800000 -0.395700 -0.304800 -0.920000 -0.376000 0.000000 +-0.797400 -0.401700 -0.304800 -0.928000 -0.344000 0.056000 +-0.800000 -0.365300 -0.243900 -0.880000 -0.440000 0.160000 +-0.781800 -0.401700 -0.243900 -0.912000 -0.336000 0.208000 +-0.800000 -0.355500 -0.182900 -0.872000 -0.472000 0.032000 +-0.775200 -0.401700 -0.182900 -0.904000 -0.400000 0.120000 +-0.800000 -0.354700 -0.121900 -0.848000 -0.512000 0.080000 +-0.771000 -0.401700 -0.121900 -0.872000 -0.456000 0.128000 +-0.800000 -0.351500 -0.101400 -0.840000 -0.528000 0.104000 +-0.762700 -0.401700 -0.060900 -0.840000 -0.496000 0.168000 +-0.794800 -0.351500 -0.060900 -0.816000 -0.552000 0.144000 +-0.800000 -0.351500 -0.101400 -0.840000 -0.528000 0.104000 +-0.800000 -0.343900 -0.060900 -0.816000 -0.552000 0.128000 +-0.800000 -0.343900 -0.060900 -0.816000 -0.552000 0.128000 +-0.700000 0.150600 -0.043600 0.552000 0.712000 0.424000 +-0.700000 0.150600 -0.043600 0.552000 0.712000 0.424000 +-0.700000 0.159000 -0.060900 0.600000 0.776000 0.184000 +-0.689800 0.150600 -0.060900 0.640000 0.736000 0.192000 +-0.700000 0.150600 -0.089800 0.592000 0.744000 -0.280000 +-0.650000 0.112000 -0.060900 0.672000 0.704000 0.200000 +-0.700000 0.140000 -0.121900 0.536000 0.728000 -0.408000 +-0.650000 0.100400 -0.098000 0.720000 0.624000 -0.288000 +-0.657700 0.100400 -0.121900 0.728000 0.576000 -0.360000 +-0.650000 0.089500 -0.121900 0.728000 0.552000 -0.384000 +-0.700000 0.100400 -0.182100 0.536000 0.592000 -0.592000 +-0.650000 0.050200 -0.178200 0.664000 0.544000 -0.504000 +-0.700000 0.099700 -0.182900 0.504000 0.560000 -0.640000 +-0.652800 0.050200 -0.182900 0.592000 0.536000 -0.592000 +-0.700000 0.050200 -0.235800 0.504000 0.432000 -0.744000 +-0.650000 0.045800 -0.182900 0.672000 0.432000 -0.592000 +-0.700000 0.037400 -0.243900 0.440000 0.392000 -0.800000 +-0.650000 0.000000 -0.224600 0.632000 0.368000 -0.672000 +-0.669700 0.000000 -0.243900 0.480000 0.312000 -0.808000 +-0.700000 0.037400 -0.243900 0.440000 0.392000 -0.800000 +-0.700000 0.000000 -0.262900 0.392000 0.288000 -0.864000 +-0.700000 0.000000 -0.262900 0.392000 0.288000 -0.864000 +-0.650000 -0.541900 0.000000 -0.528000 -0.600000 0.592000 +-0.650000 -0.541900 0.000000 -0.528000 -0.600000 0.592000 +-0.633400 -0.552300 0.000000 -0.384000 -0.672000 0.624000 +-0.650000 -0.552300 -0.012600 -0.496000 -0.592000 0.624000 +-0.650000 -0.552300 -0.012600 -0.496000 -0.592000 0.624000 +-0.452400 -0.100400 -0.060900 -0.344000 0.936000 -0.016000 +-0.452400 -0.100400 -0.060900 -0.344000 0.936000 -0.016000 +-0.450000 -0.099400 -0.060900 -0.760000 0.616000 0.160000 +-0.450000 -0.100400 -0.057100 -0.400000 0.872000 0.264000 +-0.406900 -0.050200 -0.060900 -0.848000 0.520000 0.000000 +-0.434300 -0.100400 0.000000 -0.648000 0.720000 0.208000 +-0.400000 -0.050200 -0.003200 -0.712000 0.672000 0.168000 +-0.400000 -0.050900 0.000000 -0.776000 0.576000 0.224000 +-0.399300 -0.050200 0.000000 -0.696000 0.680000 0.184000 +-0.399300 -0.050200 0.000000 -0.696000 0.680000 0.184000 +-0.466200 -0.502100 0.000000 0.712000 -0.616000 0.320000 +-0.466200 -0.502100 0.000000 0.712000 -0.616000 0.320000 +-0.450000 -0.489500 0.000000 0.584000 -0.760000 0.264000 +-0.450000 -0.502100 -0.045100 0.560000 -0.696000 0.432000 +-0.403800 -0.451900 0.000000 0.744000 -0.560000 0.352000 +-0.400000 -0.502100 -0.024700 0.848000 -0.224000 0.464000 +-0.400000 -0.451900 -0.009600 0.744000 -0.536000 0.376000 +-0.403800 -0.451900 0.000000 0.744000 -0.560000 0.352000 +-0.400000 -0.447100 0.000000 0.720000 -0.584000 0.344000 +-0.400000 -0.451900 -0.009600 0.744000 -0.536000 0.376000 +-0.350000 -0.427600 0.000000 0.560000 -0.752000 0.336000 +-0.350000 -0.451900 -0.058800 0.248000 -0.624000 0.728000 +-0.350000 -0.451900 -0.058800 0.248000 -0.624000 0.728000 +-0.500000 -0.552300 -0.009400 0.352000 -0.840000 0.400000 +-0.500000 -0.552300 -0.009400 0.352000 -0.840000 0.400000 +-0.478800 -0.552300 -0.060900 0.704000 -0.592000 0.376000 +-0.500000 -0.570000 -0.060900 0.480000 -0.800000 0.328000 +-0.452200 -0.552300 -0.121900 0.864000 0.184000 0.464000 +-0.500000 -0.589900 -0.121900 0.408000 -0.832000 0.352000 +-0.450000 -0.552300 -0.127200 0.616000 -0.144000 0.768000 +-0.500000 -0.602500 -0.155300 0.000000 -0.920000 0.376000 +-0.450000 -0.558900 -0.121900 0.808000 0.320000 0.488000 +-0.474100 -0.602500 -0.121900 -0.520000 -0.712000 0.456000 +-0.450000 -0.602500 -0.084100 -0.232000 -0.736000 0.624000 +-0.450000 -0.612400 -0.121900 0.032000 -0.944000 0.312000 +-0.410500 -0.602500 -0.121900 0.456000 -0.632000 0.616000 +-0.450000 -0.629600 -0.182900 -0.344000 -0.872000 0.320000 +-0.400000 -0.602500 -0.131300 0.560000 -0.576000 0.584000 +-0.400000 -0.651500 -0.182900 -0.552000 -0.472000 0.672000 +-0.386500 -0.602500 -0.182900 0.376000 -0.032000 0.920000 +-0.400000 -0.652700 -0.184800 -0.640000 -0.536000 0.536000 +-0.350000 -0.647900 -0.182900 0.008000 0.768000 0.624000 +-0.396000 -0.652700 -0.182900 -0.176000 0.000000 0.984000 +-0.350000 -0.652700 -0.168800 -0.864000 0.056000 0.488000 +-0.350700 -0.703000 -0.182900 -0.792000 -0.176000 0.576000 +-0.350000 -0.703000 -0.180700 -0.616000 -0.504000 0.592000 +-0.350000 -0.704300 -0.182900 -0.112000 -0.808000 0.576000 +-0.300000 -0.703000 -0.173800 0.616000 -0.544000 0.552000 +-0.300000 -0.708000 -0.182900 0.360000 -0.768000 0.520000 +-0.293800 -0.703000 -0.182900 0.608000 -0.624000 0.488000 +-0.300000 -0.736500 -0.243900 0.320000 -0.832000 0.440000 +-0.256000 -0.703000 -0.243900 0.696000 -0.392000 0.584000 +-0.300000 -0.753200 -0.286100 0.088000 -0.928000 0.352000 +-0.250000 -0.703000 -0.252700 0.704000 -0.368000 0.600000 +-0.281500 -0.753200 -0.304800 0.312000 -0.920000 -0.216000 +-0.250000 -0.737300 -0.304800 0.568000 -0.808000 -0.112000 +-0.300000 -0.753200 -0.317300 0.136000 -0.840000 -0.512000 +-0.250000 -0.703000 -0.346500 0.432000 -0.280000 -0.848000 +-0.300000 -0.703000 -0.365100 0.056000 -0.232000 -0.968000 +-0.250000 -0.652700 -0.361600 0.240000 -0.216000 -0.944000 +-0.300000 -0.687100 -0.365800 0.104000 -0.048000 -0.992000 +-0.282800 -0.652700 -0.365800 0.080000 -0.160000 -0.976000 +-0.300000 -0.652700 -0.367500 0.064000 -0.112000 -0.984000 +-0.300000 -0.687100 -0.365800 0.104000 -0.048000 -0.992000 +-0.350000 -0.652700 -0.376000 0.560000 0.160000 -0.808000 +-0.350000 -0.679200 -0.365800 -0.072000 -0.176000 -0.976000 +-0.400000 -0.652700 -0.368100 -0.128000 -0.872000 -0.456000 +-0.400000 -0.653700 -0.365800 -0.176000 -0.888000 -0.416000 +-0.405700 -0.652700 -0.365800 -0.144000 -0.920000 -0.344000 +-0.400000 -0.672200 -0.304800 -0.400000 -0.904000 -0.128000 +-0.450000 -0.652700 -0.319500 -0.256000 -0.952000 -0.136000 +-0.450000 -0.654300 -0.304800 -0.272000 -0.952000 0.040000 +-0.455200 -0.652700 -0.304800 -0.280000 -0.952000 0.040000 +-0.450000 -0.652700 -0.293400 -0.288000 -0.936000 0.160000 +-0.500000 -0.637800 -0.304800 -0.208000 -0.976000 -0.032000 +-0.450000 -0.644000 -0.243900 -0.352000 -0.912000 0.200000 +-0.500000 -0.625200 -0.243900 -0.096000 -0.960000 0.240000 +-0.450000 -0.629600 -0.182900 -0.344000 -0.872000 0.320000 +-0.500000 -0.610400 -0.182900 -0.136000 -0.936000 0.304000 +-0.450000 -0.612400 -0.121900 0.032000 -0.944000 0.312000 +-0.500000 -0.602500 -0.155300 0.000000 -0.920000 0.376000 +-0.474100 -0.602500 -0.121900 -0.520000 -0.712000 0.456000 +-0.474100 -0.602500 -0.121900 -0.520000 -0.712000 0.456000 +-0.350000 0.148000 -0.060900 -0.504000 0.552000 0.656000 +-0.350000 0.148000 -0.060900 -0.504000 0.552000 0.656000 +-0.350000 0.100400 -0.017600 -0.744000 0.352000 0.552000 +-0.361800 0.100400 -0.060900 -0.920000 0.112000 -0.352000 +-0.350000 0.077100 0.000000 -0.776000 0.256000 0.568000 +-0.358600 0.050200 -0.060900 -0.920000 0.168000 -0.328000 +-0.355100 0.050200 0.000000 -0.872000 0.216000 0.416000 +-0.355100 0.050200 0.000000 -0.872000 0.216000 0.416000 +-0.307400 0.401700 -0.060900 -0.696000 0.688000 -0.152000 +-0.307400 0.401700 -0.060900 -0.696000 0.688000 -0.152000 +-0.300000 0.408800 -0.060900 -0.664000 0.712000 -0.184000 +-0.300000 0.401700 -0.053800 -0.512000 0.520000 0.672000 +-0.250000 0.447500 -0.060900 -0.512000 0.744000 0.408000 +-0.250000 0.401700 -0.023000 -0.400000 -0.016000 0.912000 +-0.242600 0.451900 -0.060900 -0.440000 0.728000 0.512000 +-0.208400 0.401700 0.000000 -0.424000 0.248000 0.864000 +-0.200000 0.451900 -0.034900 -0.360000 0.584000 0.720000 +-0.200000 0.408700 0.000000 -0.112000 0.496000 0.856000 +-0.150000 0.451900 -0.004000 -0.136000 0.584000 0.792000 +-0.185900 0.401700 0.000000 0.264000 0.248000 0.928000 +-0.150000 0.401700 -0.011900 0.240000 0.256000 0.928000 +-0.150000 0.451900 -0.004000 -0.136000 0.584000 0.792000 +-0.100000 0.401700 -0.042400 0.232000 -0.088000 0.960000 +-0.100000 0.451900 -0.019200 0.136000 0.056000 0.984000 +-0.050000 0.401700 -0.052300 0.176000 0.040000 0.976000 +-0.050000 0.451900 -0.049700 0.432000 0.024000 0.896000 +-0.100000 0.451900 -0.019200 0.136000 0.056000 0.984000 +-0.050000 0.502100 -0.046900 0.400000 0.496000 0.760000 +-0.100000 0.502100 -0.041900 -0.080000 0.528000 0.840000 +-0.050000 0.515300 -0.060900 0.432000 0.792000 0.408000 +-0.100000 0.517800 -0.060900 -0.120000 0.976000 0.136000 +-0.100000 0.502100 -0.041900 -0.080000 0.528000 0.840000 +-0.146800 0.502100 -0.060900 -0.272000 0.960000 0.016000 +-0.100000 0.451900 -0.019200 0.136000 0.056000 0.984000 +-0.150000 0.501300 -0.060900 -0.376000 0.880000 -0.280000 +-0.150000 0.451900 -0.004000 -0.136000 0.584000 0.792000 +-0.200000 0.477600 -0.060900 -0.544000 0.808000 -0.208000 +-0.200000 0.451900 -0.034900 -0.360000 0.584000 0.720000 +-0.242600 0.451900 -0.060900 -0.440000 0.728000 0.512000 +-0.200000 0.477600 -0.060900 -0.544000 0.808000 -0.208000 +-0.200000 0.451900 -0.081300 -0.400000 0.504000 -0.752000 +-0.200000 0.451900 -0.081300 -0.400000 0.504000 -0.752000 +-0.321000 0.100400 0.000000 -0.264000 0.416000 0.864000 +-0.321000 0.100400 0.000000 -0.264000 0.416000 0.864000 +-0.350000 0.077100 0.000000 -0.776000 0.256000 0.568000 +-0.350000 0.100400 -0.017600 -0.744000 0.352000 0.552000 +-0.350000 0.100400 -0.017600 -0.744000 0.352000 0.552000 +-0.250000 0.351500 -0.004200 0.040000 0.000000 0.992000 +-0.250000 0.351500 -0.004200 0.040000 0.000000 0.992000 +-0.300000 0.351500 -0.024700 -0.384000 0.216000 0.896000 +-0.250000 0.301200 -0.005700 0.112000 -0.104000 0.984000 +-0.300000 0.301200 -0.020200 -0.184000 0.032000 0.976000 +-0.250000 0.251000 -0.029400 0.176000 -0.456000 0.864000 +-0.300000 0.251000 -0.020200 0.208000 -0.160000 0.960000 +-0.250000 0.219300 -0.060900 0.304000 -0.640000 0.696000 +-0.300000 0.200800 -0.040500 0.440000 0.208000 0.864000 +-0.277600 0.200800 -0.060900 0.584000 -0.072000 0.800000 +-0.250000 0.219300 -0.060900 0.304000 -0.640000 0.696000 +-0.250000 0.200800 -0.094600 -0.184000 -0.064000 0.976000 +-0.200000 0.206100 -0.060900 -0.448000 -0.184000 0.872000 +-0.200000 0.200800 -0.062300 -0.304000 0.376000 0.864000 +-0.198000 0.200800 -0.060900 -0.464000 0.288000 0.832000 +-0.200000 0.199100 -0.060900 -0.320000 0.504000 0.792000 +-0.200000 0.200800 -0.062300 -0.304000 0.376000 0.864000 +-0.250000 0.177000 -0.060900 -0.096000 0.568000 0.808000 +-0.250000 0.200800 -0.094600 -0.184000 -0.064000 0.976000 +-0.277600 0.200800 -0.060900 0.584000 -0.072000 0.800000 +-0.277600 0.200800 -0.060900 0.584000 -0.072000 0.800000 +-0.250000 -0.351500 -0.038300 0.104000 -0.504000 0.848000 +-0.250000 -0.351500 -0.038300 0.104000 -0.504000 0.848000 +-0.300000 -0.351500 -0.012600 0.872000 -0.352000 0.320000 +-0.250000 -0.401700 -0.058800 -0.096000 -0.136000 0.984000 +-0.300000 -0.401700 -0.045100 0.792000 -0.248000 0.544000 +-0.250000 -0.451900 -0.040500 -0.352000 -0.008000 0.928000 +-0.300000 -0.435300 -0.060900 -0.192000 -0.360000 0.912000 +-0.287100 -0.451900 -0.060900 -0.448000 -0.328000 0.824000 +-0.300000 -0.451900 -0.070300 -0.328000 -0.392000 0.856000 +-0.279200 -0.502100 -0.060900 -0.688000 -0.328000 0.640000 +-0.300000 -0.502100 -0.097100 -0.592000 -0.576000 0.560000 +-0.250000 -0.533000 -0.060900 -0.336000 -0.760000 0.544000 +-0.300000 -0.516400 -0.121900 -0.256000 -0.872000 0.400000 +-0.250000 -0.552300 -0.101500 -0.080000 -0.904000 0.400000 +-0.260200 -0.552300 -0.121900 -0.560000 -0.752000 0.336000 +-0.250000 -0.559400 -0.121900 -0.088000 -0.912000 0.384000 +-0.285200 -0.552300 -0.182900 -0.616000 -0.680000 0.384000 +-0.250000 -0.581300 -0.182900 -0.104000 -0.888000 0.440000 +-0.300000 -0.552300 -0.209900 -0.624000 -0.616000 0.456000 +-0.250000 -0.602500 -0.226600 0.288000 -0.512000 0.800000 +-0.300000 -0.594300 -0.243900 -0.424000 -0.464000 0.768000 +-0.286800 -0.602500 -0.243900 -0.320000 0.232000 0.912000 +-0.300000 -0.602500 -0.250000 -0.408000 0.368000 0.824000 +-0.300000 -0.607200 -0.243900 -0.248000 0.672000 0.688000 +-0.344900 -0.602500 -0.304800 -0.744000 0.664000 -0.032000 +-0.350000 -0.630200 -0.243900 -0.144000 0.776000 0.600000 +-0.350000 -0.605300 -0.304800 0.248000 0.960000 -0.032000 +-0.371400 -0.602500 -0.243900 0.928000 0.016000 0.352000 +-0.351600 -0.602500 -0.304800 0.944000 0.304000 0.024000 +-0.363900 -0.552300 -0.243900 0.816000 -0.480000 0.304000 +-0.350000 -0.594300 -0.304800 0.520000 -0.800000 0.280000 +-0.350000 -0.552300 -0.283400 -0.096000 -0.680000 0.720000 +-0.344900 -0.602500 -0.304800 -0.744000 0.664000 -0.032000 +-0.317500 -0.552300 -0.243900 -0.600000 -0.648000 0.448000 +-0.300000 -0.602500 -0.250000 -0.408000 0.368000 0.824000 +-0.300000 -0.594300 -0.243900 -0.424000 -0.464000 0.768000 +-0.317500 -0.552300 -0.243900 -0.600000 -0.648000 0.448000 +-0.300000 -0.552300 -0.209900 -0.624000 -0.616000 0.456000 +-0.350000 -0.535600 -0.243900 0.360000 -0.840000 0.384000 +-0.300000 -0.538300 -0.182900 -0.584000 -0.696000 0.408000 +-0.350000 -0.518400 -0.182900 -0.088000 -0.928000 0.360000 +-0.300000 -0.516400 -0.121900 -0.256000 -0.872000 0.400000 +-0.350000 -0.503000 -0.121900 0.232000 -0.880000 0.400000 +-0.300000 -0.502100 -0.097100 -0.592000 -0.576000 0.560000 +-0.350000 -0.502100 -0.119400 0.240000 -0.864000 0.424000 +-0.300000 -0.451900 -0.070300 -0.328000 -0.392000 0.856000 +-0.350000 -0.453900 -0.060900 0.248000 -0.624000 0.728000 +-0.338500 -0.451900 -0.060900 0.112000 -0.632000 0.760000 +-0.300000 -0.451900 -0.070300 -0.328000 -0.392000 0.856000 +-0.300000 -0.435300 -0.060900 -0.192000 -0.360000 0.912000 +-0.300000 -0.435300 -0.060900 -0.192000 -0.360000 0.912000 +-0.287100 -0.451900 -0.060900 -0.448000 -0.328000 0.824000 +-0.287100 -0.451900 -0.060900 -0.448000 -0.328000 0.824000 +-0.279200 -0.502100 -0.060900 -0.688000 -0.328000 0.640000 +-0.250000 -0.451900 -0.040500 -0.352000 -0.008000 0.928000 +-0.250000 -0.502100 -0.016400 -0.320000 -0.344000 0.872000 +-0.200000 -0.451900 -0.018000 0.376000 -0.112000 0.912000 +-0.200000 -0.502100 -0.039000 0.512000 -0.608000 0.592000 +-0.250000 -0.502100 -0.016400 -0.320000 -0.344000 0.872000 +-0.200000 -0.511900 -0.060900 0.416000 -0.800000 0.424000 +-0.250000 -0.533000 -0.060900 -0.336000 -0.760000 0.544000 +-0.200000 -0.534300 -0.121900 0.456000 -0.832000 0.296000 +-0.250000 -0.552300 -0.101500 -0.080000 -0.904000 0.400000 +-0.235800 -0.552300 -0.121900 0.448000 -0.816000 0.336000 +-0.250000 -0.559400 -0.121900 -0.088000 -0.912000 0.384000 +-0.204600 -0.552300 -0.182900 0.504000 -0.776000 0.360000 +-0.250000 -0.581300 -0.182900 -0.104000 -0.888000 0.440000 +-0.200000 -0.552300 -0.190900 0.520000 -0.768000 0.360000 +-0.250000 -0.602500 -0.226600 0.288000 -0.512000 0.800000 +-0.200000 -0.579600 -0.243900 0.568000 -0.648000 0.496000 +-0.233200 -0.602500 -0.243900 0.608000 -0.320000 0.720000 +-0.200000 -0.602500 -0.268600 0.488000 -0.432000 0.752000 +-0.241600 -0.652700 -0.243900 0.680000 -0.216000 0.688000 +-0.200000 -0.652700 -0.286600 0.488000 -0.272000 0.824000 +-0.250000 -0.679700 -0.243900 0.728000 -0.208000 0.640000 +-0.200000 -0.693500 -0.304800 0.872000 -0.464000 -0.120000 +-0.250000 -0.703000 -0.252700 0.704000 -0.368000 0.600000 +-0.204300 -0.703000 -0.304800 0.856000 -0.496000 -0.088000 +-0.250000 -0.737300 -0.304800 0.568000 -0.808000 -0.112000 +-0.250000 -0.703000 -0.346500 0.432000 -0.280000 -0.848000 +-0.204300 -0.703000 -0.304800 0.856000 -0.496000 -0.088000 +-0.250000 -0.652700 -0.361600 0.240000 -0.216000 -0.944000 +-0.200000 -0.693500 -0.304800 0.872000 -0.464000 -0.120000 +-0.200000 -0.652700 -0.326500 0.488000 -0.272000 -0.824000 +-0.171500 -0.652700 -0.304800 0.576000 -0.304000 0.752000 +-0.200000 -0.693500 -0.304800 0.872000 -0.464000 -0.120000 +-0.200000 -0.652700 -0.286600 0.488000 -0.272000 0.824000 +-0.200000 -0.652700 -0.286600 0.488000 -0.272000 0.824000 +-0.279200 -0.502100 -0.060900 -0.688000 -0.328000 0.640000 +-0.279200 -0.502100 -0.060900 -0.688000 -0.328000 0.640000 +-0.250000 -0.502100 -0.016400 -0.320000 -0.344000 0.872000 +-0.250000 -0.533000 -0.060900 -0.336000 -0.760000 0.544000 +-0.250000 -0.533000 -0.060900 -0.336000 -0.760000 0.544000 +-0.200000 0.351500 -0.009600 0.208000 -0.208000 0.952000 +-0.200000 0.351500 -0.009600 0.208000 -0.208000 0.952000 +-0.250000 0.351500 -0.004200 0.040000 0.000000 0.992000 +-0.200000 0.301200 -0.022600 0.056000 -0.176000 0.976000 +-0.250000 0.301200 -0.005700 0.112000 -0.104000 0.984000 +-0.200000 0.251000 -0.048300 -0.120000 -0.296000 0.944000 +-0.250000 0.251000 -0.029400 0.176000 -0.456000 0.864000 +-0.200000 0.206100 -0.060900 -0.448000 -0.184000 0.872000 +-0.250000 0.219300 -0.060900 0.304000 -0.640000 0.696000 +-0.250000 0.219300 -0.060900 0.304000 -0.640000 0.696000 +-0.200000 -0.351500 -0.031500 -0.320000 -0.128000 0.936000 +-0.200000 -0.351500 -0.031500 -0.320000 -0.128000 0.936000 +-0.250000 -0.351500 -0.038300 0.104000 -0.504000 0.848000 +-0.200000 -0.401700 -0.023400 -0.056000 -0.008000 0.992000 +-0.250000 -0.401700 -0.058800 -0.096000 -0.136000 0.984000 +-0.200000 -0.451900 -0.018000 0.376000 -0.112000 0.912000 +-0.250000 -0.451900 -0.040500 -0.352000 -0.008000 0.928000 +-0.250000 -0.451900 -0.040500 -0.352000 -0.008000 0.928000 +-0.200000 0.150600 -0.023100 -0.360000 0.472000 0.792000 +-0.200000 0.150600 -0.023100 -0.360000 0.472000 0.792000 +-0.200000 0.100400 -0.008800 0.176000 0.488000 0.848000 +-0.150000 0.150600 -0.037800 0.256000 -0.016000 0.960000 +-0.150000 0.100400 -0.027500 0.432000 0.296000 0.848000 +-0.114400 0.150600 -0.060900 0.520000 -0.344000 0.776000 +-0.122500 0.100400 -0.060900 0.768000 -0.048000 0.624000 +-0.100000 0.150600 -0.075000 0.592000 -0.416000 0.688000 +-0.100000 0.100400 -0.099400 0.760000 -0.264000 0.584000 +-0.067900 0.150600 -0.121900 0.736000 -0.432000 0.504000 +-0.089100 0.100400 -0.121900 0.816000 -0.232000 0.520000 +-0.050000 0.150600 -0.159500 0.712000 -0.480000 0.504000 +-0.053800 0.100400 -0.182900 0.984000 -0.072000 0.112000 +-0.050000 0.116900 -0.182900 0.944000 -0.304000 0.048000 +-0.051400 0.100400 -0.243900 0.776000 0.216000 -0.576000 +-0.050000 0.150600 -0.210200 0.840000 -0.208000 -0.496000 +-0.077600 0.150600 -0.243900 0.320000 0.328000 -0.880000 +-0.051400 0.100400 -0.243900 0.776000 0.216000 -0.576000 +-0.100000 0.150600 -0.251000 -0.024000 0.408000 -0.904000 +-0.100000 0.100400 -0.276400 0.032000 0.376000 -0.920000 +-0.126800 0.150600 -0.243900 -0.208000 0.496000 -0.832000 +-0.150000 0.100400 -0.267100 -0.312000 0.440000 -0.832000 +-0.150000 0.141700 -0.243900 -0.352000 0.528000 -0.768000 +-0.198500 0.100400 -0.243900 -0.376000 0.480000 -0.784000 +-0.150000 0.100400 -0.267100 -0.312000 0.440000 -0.832000 +-0.200000 0.099300 -0.243900 -0.456000 0.488000 -0.736000 +-0.150000 0.050200 -0.299600 -0.080000 0.408000 -0.904000 +-0.200000 0.050200 -0.277000 -0.312000 0.416000 -0.848000 +-0.150000 0.040500 -0.304800 -0.136000 0.416000 -0.896000 +-0.200000 0.008900 -0.304800 -0.304000 0.456000 -0.832000 +-0.150000 0.000000 -0.322200 0.064000 0.240000 -0.968000 +-0.200000 0.000000 -0.310700 -0.288000 0.424000 -0.848000 +-0.150000 -0.050200 -0.328000 0.128000 0.064000 -0.984000 +-0.200000 -0.050200 -0.330400 -0.144000 0.264000 -0.944000 +-0.150000 -0.100400 -0.338700 0.056000 -0.088000 -0.992000 +-0.200000 -0.100400 -0.330100 -0.024000 -0.008000 -0.992000 +-0.150000 -0.150600 -0.309500 -0.032000 -0.400000 -0.912000 +-0.200000 -0.150600 -0.333300 0.216000 -0.272000 -0.936000 +-0.200000 -0.100400 -0.330100 -0.024000 -0.008000 -0.992000 +-0.250000 -0.150600 -0.327500 -0.120000 0.152000 -0.976000 +-0.250000 -0.100400 -0.327300 -0.384000 0.152000 -0.904000 +-0.200000 -0.100400 -0.330100 -0.024000 -0.008000 -0.992000 +-0.250000 -0.050200 -0.318700 -0.440000 0.320000 -0.832000 +-0.200000 -0.050200 -0.330400 -0.144000 0.264000 -0.944000 +-0.250000 -0.028200 -0.304800 -0.400000 0.416000 -0.808000 +-0.200000 0.000000 -0.310700 -0.288000 0.424000 -0.848000 +-0.213400 0.000000 -0.304800 -0.304000 0.448000 -0.832000 +-0.200000 0.008900 -0.304800 -0.304000 0.456000 -0.832000 +-0.250000 0.000000 -0.286200 -0.320000 0.712000 -0.616000 +-0.200000 0.050200 -0.277000 -0.312000 0.416000 -0.848000 +-0.250000 0.050200 -0.254100 -0.584000 0.656000 -0.464000 +-0.200000 0.099300 -0.243900 -0.456000 0.488000 -0.736000 +-0.250000 0.055800 -0.243900 -0.560000 0.648000 -0.504000 +-0.250000 0.050200 -0.254100 -0.584000 0.656000 -0.464000 +-0.256300 0.050200 -0.243900 -0.592000 0.624000 -0.488000 +-0.256300 0.050200 -0.243900 -0.592000 0.624000 -0.488000 +-0.200000 -0.502100 -0.039000 0.512000 -0.608000 0.592000 +-0.200000 -0.502100 -0.039000 0.512000 -0.608000 0.592000 +-0.181900 -0.502100 -0.060900 0.504000 -0.680000 0.520000 +-0.200000 -0.511900 -0.060900 0.416000 -0.800000 0.424000 +-0.200000 -0.511900 -0.060900 0.416000 -0.800000 0.424000 +-0.100000 0.401700 -0.042400 0.232000 -0.088000 0.960000 +-0.100000 0.401700 -0.042400 0.232000 -0.088000 0.960000 +-0.150000 0.401700 -0.011900 0.240000 0.256000 0.928000 +-0.100000 0.351500 -0.035500 0.120000 0.000000 0.992000 +-0.150000 0.351500 -0.029900 0.096000 -0.168000 0.976000 +-0.100000 0.301200 -0.032000 0.168000 0.008000 0.984000 +-0.150000 0.301200 -0.033800 0.040000 -0.024000 0.992000 +-0.100000 0.251000 -0.029400 0.344000 -0.104000 0.928000 +-0.150000 0.251000 -0.027500 -0.136000 -0.104000 0.984000 +-0.100000 0.200800 -0.041900 0.456000 -0.304000 0.832000 +-0.150000 0.200800 -0.027500 -0.320000 -0.168000 0.928000 +-0.100000 0.167200 -0.060900 0.520000 -0.424000 0.736000 +-0.150000 0.150600 -0.037800 0.256000 -0.016000 0.960000 +-0.114400 0.150600 -0.060900 0.520000 -0.344000 0.776000 +-0.100000 0.167200 -0.060900 0.520000 -0.424000 0.736000 +-0.100000 0.150600 -0.075000 0.592000 -0.416000 0.688000 +-0.078700 0.200800 -0.060900 0.568000 -0.416000 0.704000 +-0.067900 0.150600 -0.121900 0.736000 -0.432000 0.504000 +-0.050000 0.200800 -0.090500 0.520000 -0.520000 0.672000 +-0.050000 0.170300 -0.121900 0.584000 -0.576000 0.560000 +-0.067900 0.150600 -0.121900 0.736000 -0.432000 0.504000 +-0.050000 0.150600 -0.159500 0.712000 -0.480000 0.504000 +-0.050000 0.150600 -0.159500 0.712000 -0.480000 0.504000 +-0.150000 0.100400 -0.027500 0.432000 0.296000 0.848000 +-0.150000 0.100400 -0.027500 0.432000 0.296000 0.848000 +-0.150000 0.050200 -0.012600 0.624000 0.240000 0.728000 +-0.122500 0.100400 -0.060900 0.768000 -0.048000 0.624000 +-0.123500 0.050200 -0.060900 0.888000 -0.104000 0.440000 +-0.100000 0.100400 -0.099400 0.760000 -0.264000 0.584000 +-0.100700 0.050200 -0.121900 0.856000 0.048000 0.504000 +-0.100000 0.054100 -0.121900 0.816000 -0.176000 0.544000 +-0.100000 0.050200 -0.123300 0.696000 -0.176000 0.688000 +-0.089100 0.100400 -0.121900 0.816000 -0.232000 0.520000 +-0.051100 0.050200 -0.182900 0.712000 0.184000 0.664000 +-0.053800 0.100400 -0.182900 0.984000 -0.072000 0.112000 +-0.050000 0.050200 -0.189300 0.800000 0.488000 0.336000 +-0.051400 0.100400 -0.243900 0.776000 0.216000 -0.576000 +-0.050000 0.095100 -0.243900 0.808000 0.256000 -0.520000 +-0.100000 0.100400 -0.276400 0.032000 0.376000 -0.920000 +-0.050000 0.050200 -0.257500 0.608000 0.208000 -0.760000 +-0.100000 0.050200 -0.292200 0.304000 0.312000 -0.896000 +-0.050000 0.000000 -0.288000 0.256000 0.560000 -0.776000 +-0.100000 0.022400 -0.304800 0.184000 0.304000 -0.928000 +-0.077600 0.000000 -0.304800 0.248000 0.344000 -0.896000 +-0.100000 0.000000 -0.309600 0.168000 0.152000 -0.968000 +-0.050000 -0.015100 -0.304800 0.280000 0.536000 -0.784000 +-0.100000 -0.050200 -0.318600 0.080000 0.144000 -0.984000 +-0.050000 -0.050200 -0.321000 0.120000 0.280000 -0.944000 +-0.100000 -0.100400 -0.323700 -0.040000 -0.152000 -0.984000 +-0.050000 -0.100400 -0.342800 0.056000 -0.032000 -0.992000 +-0.100000 -0.150600 -0.315000 -0.456000 -0.064000 -0.880000 +-0.050000 -0.150600 -0.332400 0.016000 -0.080000 -0.992000 +-0.050000 -0.100400 -0.342800 0.056000 -0.032000 -0.992000 +0.000000 -0.150600 -0.318000 0.160000 0.016000 -0.984000 +0.000000 -0.100400 -0.336000 0.328000 -0.184000 -0.920000 +0.050000 -0.150600 -0.318000 0.352000 0.312000 -0.872000 +0.039400 -0.100400 -0.304800 0.408000 0.224000 -0.880000 +0.050000 -0.119800 -0.304800 0.416000 0.264000 -0.864000 +0.050000 -0.100400 -0.298100 0.360000 0.248000 -0.896000 +0.096000 -0.150600 -0.304800 0.176000 0.336000 -0.920000 +0.100000 -0.100400 -0.298900 0.040000 0.136000 -0.984000 +0.100000 -0.150600 -0.303900 -0.176000 0.088000 -0.976000 +0.114400 -0.100400 -0.304800 -0.344000 0.128000 -0.928000 +0.101900 -0.150600 -0.304800 -0.296000 0.368000 -0.872000 +0.100000 -0.150600 -0.303900 -0.176000 0.088000 -0.976000 +0.100000 -0.151600 -0.304800 -0.176000 0.536000 -0.816000 +0.096000 -0.150600 -0.304800 0.176000 0.336000 -0.920000 +0.096000 -0.150600 -0.304800 0.176000 0.336000 -0.920000 +-0.150000 0.050200 -0.012600 0.624000 0.240000 0.728000 +-0.150000 0.050200 -0.012600 0.624000 0.240000 0.728000 +-0.150000 0.000000 -0.001200 0.744000 0.064000 0.656000 +-0.123500 0.050200 -0.060900 0.888000 -0.104000 0.440000 +-0.120900 0.000000 -0.060900 0.800000 0.080000 0.592000 +-0.100700 0.050200 -0.121900 0.856000 0.048000 0.504000 +-0.100000 0.000000 -0.110200 0.808000 0.176000 0.552000 +-0.100000 0.044900 -0.121900 0.816000 0.112000 0.552000 +-0.089600 0.000000 -0.121900 0.568000 0.512000 0.632000 +-0.100000 0.050200 -0.123300 0.696000 -0.176000 0.688000 +-0.050000 0.000000 -0.158900 0.584000 0.336000 0.728000 +-0.051100 0.050200 -0.182900 0.712000 0.184000 0.664000 +-0.050000 0.047900 -0.182900 0.488000 0.480000 0.720000 +-0.050000 0.050200 -0.189300 0.800000 0.488000 0.336000 +0.000000 0.039200 -0.182900 0.256000 0.544000 0.792000 +0.000000 0.050200 -0.198900 0.168000 0.840000 0.504000 +0.050000 0.005700 -0.182900 0.312000 0.584000 0.744000 +0.046000 0.050200 -0.243900 0.728000 0.480000 -0.472000 +0.050000 0.042300 -0.243900 0.688000 0.376000 -0.616000 +0.000000 0.050200 -0.275900 0.288000 0.416000 -0.856000 +0.050000 0.000000 -0.258500 0.448000 0.256000 -0.848000 +0.000000 0.000000 -0.289100 0.520000 0.272000 -0.800000 +0.050000 -0.050200 -0.279200 0.280000 0.320000 -0.896000 +0.000000 -0.038700 -0.304800 0.368000 0.192000 -0.904000 +0.004800 -0.050200 -0.304800 0.368000 0.176000 -0.904000 +0.000000 -0.050200 -0.306900 0.320000 0.152000 -0.928000 +0.039400 -0.100400 -0.304800 0.408000 0.224000 -0.880000 +0.000000 -0.100400 -0.336000 0.328000 -0.184000 -0.920000 +0.000000 -0.050200 -0.306900 0.320000 0.152000 -0.928000 +-0.050000 -0.100400 -0.342800 0.056000 -0.032000 -0.992000 +-0.050000 -0.050200 -0.321000 0.120000 0.280000 -0.944000 +0.000000 -0.050200 -0.306900 0.320000 0.152000 -0.928000 +-0.050000 -0.015100 -0.304800 0.280000 0.536000 -0.784000 +0.000000 -0.038700 -0.304800 0.368000 0.192000 -0.904000 +-0.050000 0.000000 -0.288000 0.256000 0.560000 -0.776000 +0.000000 0.000000 -0.289100 0.520000 0.272000 -0.800000 +-0.050000 0.050200 -0.257500 0.608000 0.208000 -0.760000 +0.000000 0.050200 -0.275900 0.288000 0.416000 -0.856000 +-0.050000 0.095100 -0.243900 0.808000 0.256000 -0.520000 +0.000000 0.087200 -0.243900 0.456000 0.816000 -0.344000 +-0.050000 0.050200 -0.189300 0.800000 0.488000 0.336000 +0.000000 0.050200 -0.198900 0.168000 0.840000 0.504000 +0.000000 0.087200 -0.243900 0.456000 0.816000 -0.344000 +0.046000 0.050200 -0.243900 0.728000 0.480000 -0.472000 +0.000000 0.050200 -0.275900 0.288000 0.416000 -0.856000 +0.000000 0.050200 -0.275900 0.288000 0.416000 -0.856000 +-0.150000 0.000000 -0.001200 0.744000 0.064000 0.656000 +-0.150000 0.000000 -0.001200 0.744000 0.064000 0.656000 +-0.150000 -0.050200 -0.005700 0.768000 -0.024000 0.632000 +-0.120900 0.000000 -0.060900 0.800000 0.080000 0.592000 +-0.114700 -0.050200 -0.060900 0.632000 0.112000 0.760000 +-0.100000 0.000000 -0.110200 0.808000 0.176000 0.552000 +-0.100000 -0.050200 -0.077100 0.584000 0.232000 0.768000 +-0.089600 0.000000 -0.121900 0.568000 0.512000 0.632000 +-0.050000 -0.050200 -0.098600 0.240000 0.488000 0.832000 +-0.050000 -0.024600 -0.121900 0.296000 0.656000 0.688000 +0.000000 -0.050200 -0.114000 0.064000 0.408000 0.904000 +0.000000 -0.035500 -0.121900 0.072000 0.496000 0.856000 +0.050000 -0.050200 -0.115700 0.016000 0.416000 0.904000 +0.050000 -0.038600 -0.121900 0.000000 0.528000 0.840000 +0.100000 -0.050200 -0.113200 -0.016000 0.464000 0.880000 +0.100000 -0.037100 -0.121900 -0.016000 0.544000 0.832000 +0.150000 -0.050200 -0.113700 0.032000 0.448000 0.888000 +0.150000 -0.036300 -0.121900 0.008000 0.488000 0.864000 +0.100000 -0.037100 -0.121900 -0.016000 0.544000 0.832000 +0.150000 0.000000 -0.166100 -0.096000 0.688000 0.712000 +0.100000 0.000000 -0.179900 0.000000 0.528000 0.840000 +0.150000 0.016800 -0.182900 -0.152000 0.840000 0.520000 +0.100000 0.004900 -0.182900 -0.288000 0.864000 0.400000 +0.150000 0.015400 -0.243900 -0.208000 0.728000 -0.640000 +0.100000 0.000000 -0.203800 -0.256000 0.936000 -0.224000 +0.113100 0.000000 -0.243900 -0.392000 0.768000 -0.496000 +0.100000 -0.005500 -0.243900 -0.184000 0.760000 -0.616000 +0.150000 0.000000 -0.257100 -0.208000 0.552000 -0.800000 +0.100000 -0.050200 -0.272200 -0.136000 0.384000 -0.904000 +0.150000 -0.050200 -0.298400 -0.176000 0.328000 -0.920000 +0.100000 -0.100400 -0.298900 0.040000 0.136000 -0.984000 +0.150000 -0.064700 -0.304800 -0.200000 0.328000 -0.912000 +0.114400 -0.100400 -0.304800 -0.344000 0.128000 -0.928000 +0.114400 -0.100400 -0.304800 -0.344000 0.128000 -0.928000 +-0.150000 -0.050200 -0.005700 0.768000 -0.024000 0.632000 +-0.150000 -0.050200 -0.005700 0.768000 -0.024000 0.632000 +-0.150000 -0.100400 -0.001300 0.848000 0.032000 0.520000 +-0.114700 -0.050200 -0.060900 0.632000 0.112000 0.760000 +-0.104300 -0.100400 -0.060900 0.528000 0.416000 0.728000 +-0.100000 -0.050200 -0.077100 0.584000 0.232000 0.768000 +-0.100000 -0.100400 -0.064700 0.496000 0.416000 0.752000 +-0.050000 -0.050200 -0.098600 0.240000 0.488000 0.832000 +-0.050000 -0.100400 -0.073900 0.136000 0.480000 0.864000 +0.000000 -0.050200 -0.114000 0.064000 0.408000 0.904000 +0.000000 -0.100400 -0.085100 0.096000 0.456000 0.880000 +0.050000 -0.050200 -0.115700 0.016000 0.416000 0.904000 +0.050000 -0.100400 -0.083400 0.000000 0.440000 0.888000 +0.100000 -0.050200 -0.113200 -0.016000 0.464000 0.880000 +0.100000 -0.100400 -0.084200 0.032000 0.360000 0.928000 +0.150000 -0.050200 -0.113700 0.032000 0.448000 0.888000 +0.150000 -0.100400 -0.080500 0.184000 0.336000 0.920000 +0.100000 -0.100400 -0.084200 0.032000 0.360000 0.928000 +0.150000 -0.150600 -0.071000 0.136000 0.176000 0.968000 +0.100000 -0.150600 -0.068400 0.184000 0.416000 0.888000 +0.150000 -0.200800 -0.071800 0.312000 -0.208000 0.920000 +0.100000 -0.170000 -0.060900 0.256000 0.296000 0.912000 +0.130700 -0.200800 -0.060900 0.504000 0.008000 0.856000 +0.150000 -0.200800 -0.071800 0.312000 -0.208000 0.920000 +0.110300 -0.251000 -0.060900 0.504000 -0.760000 0.392000 +0.150000 -0.251000 -0.118100 0.224000 -0.792000 0.560000 +0.150000 -0.251000 -0.118100 0.224000 -0.792000 0.560000 +-0.100000 -0.188700 0.000000 0.176000 0.408000 0.888000 +-0.100000 -0.188700 0.000000 0.176000 0.408000 0.888000 +-0.129500 -0.150600 0.000000 0.416000 0.264000 0.864000 +-0.100000 -0.150600 -0.019000 0.512000 0.456000 0.720000 +-0.100000 -0.150600 -0.019000 0.512000 0.456000 0.720000 +-0.150000 -0.346200 0.000000 -0.392000 -0.160000 0.904000 +-0.150000 -0.346200 0.000000 -0.392000 -0.160000 0.904000 +-0.150000 -0.351500 -0.001100 -0.192000 -0.352000 0.912000 +-0.100000 -0.344900 0.000000 0.072000 -0.528000 0.840000 +-0.100000 -0.351500 -0.005700 0.248000 -0.576000 0.776000 +-0.050000 -0.329200 0.000000 0.264000 -0.624000 0.720000 +-0.050000 -0.351500 -0.027000 0.488000 -0.688000 0.528000 +-0.100000 -0.351500 -0.005700 0.248000 -0.576000 0.776000 +-0.050000 -0.370100 -0.060900 0.592000 -0.672000 0.424000 +-0.100000 -0.401700 -0.044900 0.592000 -0.496000 0.624000 +-0.087700 -0.401700 -0.060900 0.608000 -0.600000 0.504000 +-0.100000 -0.415900 -0.060900 0.680000 -0.544000 0.480000 +-0.054100 -0.401700 -0.121900 0.656000 -0.688000 0.280000 +-0.100000 -0.451900 -0.117700 0.624000 -0.664000 0.392000 +-0.098000 -0.451900 -0.121900 0.712000 -0.680000 0.120000 +-0.100000 -0.453500 -0.121900 0.600000 -0.776000 0.168000 +-0.098100 -0.451900 -0.182900 0.736000 -0.672000 0.032000 +-0.100000 -0.453800 -0.182900 0.696000 -0.712000 0.024000 +-0.094700 -0.451900 -0.243900 0.784000 -0.568000 0.216000 +-0.100000 -0.458900 -0.243900 0.744000 -0.632000 0.192000 +-0.061500 -0.451900 -0.304800 0.928000 -0.352000 0.088000 +-0.100000 -0.502100 -0.283200 0.616000 -0.376000 0.680000 +-0.074100 -0.502100 -0.304800 0.864000 -0.480000 0.112000 +-0.100000 -0.549700 -0.304800 0.696000 -0.392000 0.592000 +-0.100000 -0.502100 -0.325200 0.520000 -0.368000 -0.760000 +-0.101500 -0.552300 -0.304800 0.552000 -0.392000 0.720000 +-0.147100 -0.502100 -0.365800 0.472000 -0.192000 -0.848000 +-0.150000 -0.552300 -0.337600 0.424000 -0.304000 -0.840000 +-0.150000 -0.505900 -0.365800 0.272000 -0.320000 -0.904000 +-0.196100 -0.552300 -0.365800 0.320000 -0.272000 -0.904000 +-0.150000 -0.502100 -0.367300 0.088000 -0.320000 -0.936000 +-0.200000 -0.552300 -0.367100 0.360000 -0.232000 -0.896000 +-0.200000 -0.502100 -0.370700 0.184000 -0.352000 -0.912000 +-0.200000 -0.502100 -0.370700 0.184000 -0.352000 -0.912000 +-0.100000 -0.351500 -0.005700 0.248000 -0.576000 0.776000 +-0.100000 -0.351500 -0.005700 0.248000 -0.576000 0.776000 +-0.150000 -0.351500 -0.001100 -0.192000 -0.352000 0.912000 +-0.100000 -0.401700 -0.044900 0.592000 -0.496000 0.624000 +-0.150000 -0.401700 -0.019000 0.408000 -0.232000 0.880000 +-0.100000 -0.415900 -0.060900 0.680000 -0.544000 0.480000 +-0.150000 -0.451900 -0.041900 0.560000 -0.440000 0.696000 +-0.133200 -0.451900 -0.060900 0.584000 -0.656000 0.464000 +-0.150000 -0.470000 -0.060900 0.568000 -0.552000 0.600000 +-0.100000 -0.451900 -0.117700 0.624000 -0.664000 0.392000 +-0.150000 -0.502100 -0.111600 0.592000 -0.752000 0.280000 +-0.100000 -0.453500 -0.121900 0.600000 -0.776000 0.168000 +-0.146100 -0.502100 -0.121900 0.616000 -0.744000 0.232000 +-0.100000 -0.453800 -0.182900 0.696000 -0.712000 0.024000 +-0.141200 -0.502100 -0.182900 0.696000 -0.688000 0.184000 +-0.100000 -0.458900 -0.243900 0.744000 -0.632000 0.192000 +-0.125700 -0.502100 -0.243900 0.664000 -0.408000 0.624000 +-0.100000 -0.502100 -0.283200 0.616000 -0.376000 0.680000 +-0.150000 -0.530700 -0.243900 0.632000 -0.664000 0.392000 +-0.100000 -0.549700 -0.304800 0.696000 -0.392000 0.592000 +-0.150000 -0.552300 -0.270100 0.544000 -0.504000 0.656000 +-0.101500 -0.552300 -0.304800 0.552000 -0.392000 0.720000 +-0.150000 -0.602500 -0.302600 0.392000 -0.240000 0.880000 +-0.145700 -0.602500 -0.304800 0.824000 -0.528000 0.192000 +-0.150000 -0.609400 -0.304800 0.840000 -0.512000 0.152000 +-0.150000 -0.602500 -0.307600 0.456000 -0.280000 -0.840000 +-0.145700 -0.602500 -0.304800 0.824000 -0.528000 0.192000 +-0.150000 -0.552300 -0.337600 0.424000 -0.304000 -0.840000 +-0.101500 -0.552300 -0.304800 0.552000 -0.392000 0.720000 +-0.101500 -0.552300 -0.304800 0.552000 -0.392000 0.720000 +-0.050000 0.401700 -0.052300 0.176000 0.040000 0.976000 +-0.050000 0.401700 -0.052300 0.176000 0.040000 0.976000 +-0.100000 0.401700 -0.042400 0.232000 -0.088000 0.960000 +-0.050000 0.351500 -0.043600 0.248000 0.032000 0.960000 +-0.100000 0.351500 -0.035500 0.120000 0.000000 0.992000 +-0.050000 0.301200 -0.044600 0.440000 -0.008000 0.896000 +-0.100000 0.301200 -0.032000 0.168000 0.008000 0.984000 +-0.050000 0.251000 -0.047300 0.528000 -0.360000 0.760000 +-0.100000 0.251000 -0.029400 0.344000 -0.104000 0.928000 +-0.050000 0.236000 -0.060900 0.536000 -0.496000 0.672000 +-0.100000 0.200800 -0.041900 0.456000 -0.304000 0.832000 +-0.078700 0.200800 -0.060900 0.568000 -0.416000 0.704000 +-0.100000 0.167200 -0.060900 0.520000 -0.424000 0.736000 +-0.100000 0.167200 -0.060900 0.520000 -0.424000 0.736000 +-0.027600 0.301200 -0.060900 0.456000 -0.208000 0.856000 +-0.027600 0.301200 -0.060900 0.456000 -0.208000 0.856000 +-0.050000 0.301200 -0.044600 0.440000 -0.008000 0.896000 +-0.035000 0.251000 -0.060900 0.512000 -0.448000 0.728000 +-0.050000 0.251000 -0.047300 0.528000 -0.360000 0.760000 +-0.050000 0.236000 -0.060900 0.536000 -0.496000 0.672000 +-0.050000 0.236000 -0.060900 0.536000 -0.496000 0.672000 +-0.002200 -0.301200 0.000000 0.384000 -0.648000 0.648000 +-0.002200 -0.301200 0.000000 0.384000 -0.648000 0.648000 +0.000000 -0.299000 0.000000 0.440000 -0.464000 0.760000 +0.000000 -0.301200 -0.001900 0.408000 -0.704000 0.568000 +0.050000 -0.253500 0.000000 0.448000 -0.608000 0.648000 +0.032200 -0.301200 -0.060900 0.552000 -0.696000 0.448000 +0.050000 -0.286400 -0.060900 0.528000 -0.720000 0.440000 +0.050000 -0.301200 -0.085900 0.528000 -0.704000 0.464000 +0.050000 -0.301200 -0.085900 0.528000 -0.704000 0.464000 +-0.050000 -0.351500 -0.027000 0.488000 -0.688000 0.528000 +-0.050000 -0.351500 -0.027000 0.488000 -0.688000 0.528000 +-0.029100 -0.351500 -0.060900 0.584000 -0.680000 0.424000 +-0.050000 -0.370100 -0.060900 0.592000 -0.672000 0.424000 +0.000000 -0.351500 -0.112600 0.544000 -0.704000 0.448000 +-0.050000 -0.398200 -0.121900 0.592000 -0.704000 0.368000 +0.000000 -0.356400 -0.121900 0.560000 -0.728000 0.384000 +-0.050000 -0.389600 -0.182900 0.656000 -0.736000 -0.128000 +0.000000 -0.353400 -0.182900 0.520000 -0.832000 -0.160000 +-0.050000 -0.380500 -0.243900 0.664000 -0.736000 -0.104000 +0.000000 -0.351500 -0.193300 0.504000 -0.832000 -0.176000 +-0.013800 -0.351500 -0.243900 0.552000 -0.808000 -0.168000 +0.000000 -0.343100 -0.243900 0.464000 -0.864000 -0.160000 +-0.026900 -0.351500 -0.304800 0.608000 -0.688000 -0.384000 +0.000000 -0.336000 -0.304800 0.392000 -0.872000 -0.264000 +-0.050000 -0.351500 -0.336900 0.024000 -0.576000 -0.808000 +0.000000 -0.316900 -0.365800 0.224000 -0.832000 -0.496000 +-0.050000 -0.309800 -0.365800 -0.336000 -0.416000 -0.840000 +0.000000 -0.301200 -0.413400 -0.392000 -0.192000 -0.896000 +-0.050000 -0.301200 -0.370400 -0.392000 -0.264000 -0.872000 +0.000000 -0.251000 -0.386300 -0.352000 0.496000 -0.792000 +-0.050000 -0.266900 -0.365800 -0.288000 0.088000 -0.944000 +-0.044700 -0.251000 -0.365800 -0.216000 0.376000 -0.896000 +-0.050000 -0.251000 -0.364300 -0.216000 0.352000 -0.904000 +0.000000 -0.238800 -0.365800 -0.192000 0.648000 -0.728000 +-0.050000 -0.200800 -0.320900 -0.056000 0.280000 -0.952000 +0.000000 -0.200800 -0.332000 -0.296000 0.528000 -0.784000 +0.000000 -0.238800 -0.365800 -0.192000 0.648000 -0.728000 +0.050000 -0.200800 -0.360800 -0.016000 0.576000 -0.808000 +0.050000 -0.206300 -0.365800 -0.112000 0.608000 -0.776000 +0.000000 -0.238800 -0.365800 -0.192000 0.648000 -0.728000 +0.050000 -0.251000 -0.406500 0.232000 -0.312000 -0.912000 +0.000000 -0.251000 -0.386300 -0.352000 0.496000 -0.792000 +0.050000 -0.301200 -0.369000 0.376000 -0.768000 -0.512000 +0.000000 -0.301200 -0.413400 -0.392000 -0.192000 -0.896000 +0.050000 -0.303000 -0.365800 0.400000 -0.792000 -0.448000 +0.000000 -0.316900 -0.365800 0.224000 -0.832000 -0.496000 +0.050000 -0.326800 -0.304800 0.424000 -0.880000 -0.184000 +0.000000 -0.336000 -0.304800 0.392000 -0.872000 -0.264000 +0.050000 -0.327900 -0.243900 0.480000 -0.872000 0.000000 +0.000000 -0.343100 -0.243900 0.464000 -0.864000 -0.160000 +0.050000 -0.327900 -0.182900 0.552000 -0.824000 0.048000 +0.000000 -0.351500 -0.193300 0.504000 -0.832000 -0.176000 +0.003100 -0.351500 -0.182900 0.504000 -0.840000 -0.160000 +0.000000 -0.353400 -0.182900 0.520000 -0.832000 -0.160000 +0.006400 -0.351500 -0.121900 0.552000 -0.776000 0.288000 +0.000000 -0.356400 -0.121900 0.560000 -0.728000 0.384000 +0.000000 -0.351500 -0.112600 0.544000 -0.704000 0.448000 +0.000000 -0.351500 -0.112600 0.544000 -0.704000 0.448000 +0.000000 0.351500 -0.051600 0.280000 -0.248000 0.920000 +0.000000 0.351500 -0.051600 0.280000 -0.248000 0.920000 +0.000000 0.393800 -0.060900 0.224000 0.176000 0.952000 +0.042100 0.351500 -0.060900 0.160000 -0.080000 0.976000 +0.000000 0.401700 -0.062800 0.256000 0.176000 0.944000 +0.050000 0.351500 -0.062500 0.000000 -0.264000 0.960000 +0.050000 0.401700 -0.062500 -0.008000 0.136000 0.984000 +0.065700 0.351500 -0.060900 -0.064000 -0.312000 0.944000 +0.100000 0.401700 -0.066700 -0.048000 0.000000 0.992000 +0.100000 0.368600 -0.060900 0.104000 0.120000 0.984000 +0.150000 0.401700 -0.062100 -0.392000 -0.400000 0.816000 +0.111400 0.351500 -0.060900 0.184000 -0.224000 0.952000 +0.150000 0.351500 -0.070300 -0.056000 -0.480000 0.872000 +0.100000 0.345700 -0.060900 0.056000 -0.392000 0.912000 +0.150000 0.301200 -0.094700 0.096000 -0.408000 0.904000 +0.100000 0.301200 -0.081200 0.144000 -0.392000 0.904000 +0.150000 0.253300 -0.121900 0.144000 -0.672000 0.712000 +0.100000 0.251000 -0.119300 0.048000 -0.664000 0.736000 +0.134200 0.251000 -0.121900 0.072000 -0.752000 0.648000 +0.100000 0.248700 -0.121900 0.064000 -0.824000 0.552000 +0.150000 0.251000 -0.128300 0.144000 -0.904000 0.392000 +0.100000 0.246100 -0.182900 0.136000 -0.488000 -0.856000 +0.150000 0.224100 -0.182900 0.056000 -0.672000 -0.728000 +0.100000 0.251000 -0.185300 0.160000 -0.296000 -0.936000 +0.150000 0.251000 -0.192500 0.112000 0.024000 -0.992000 +0.100000 0.301200 -0.188500 0.112000 0.128000 -0.984000 +0.150000 0.284700 -0.182900 0.352000 0.368000 -0.856000 +0.133500 0.301200 -0.182900 0.272000 0.264000 -0.920000 +0.150000 0.251000 -0.128300 0.144000 -0.904000 0.392000 +0.150000 0.301200 -0.172900 0.456000 0.432000 -0.768000 +0.134200 0.251000 -0.121900 0.072000 -0.752000 0.648000 +0.150000 0.253300 -0.121900 0.144000 -0.672000 0.712000 +0.150000 0.301200 -0.172900 0.456000 0.432000 -0.768000 +0.200000 0.269500 -0.121900 -0.008000 -0.896000 0.432000 +0.200000 0.301200 -0.179700 -0.152000 -0.352000 -0.920000 +0.250000 0.256500 -0.121900 -0.200000 -0.800000 0.552000 +0.215700 0.301200 -0.182900 -0.120000 -0.160000 -0.976000 +0.250000 0.284000 -0.182900 -0.096000 -0.256000 -0.952000 +0.250000 0.301200 -0.184400 -0.080000 -0.056000 -0.992000 +0.215700 0.301200 -0.182900 -0.120000 -0.160000 -0.976000 +0.250000 0.351500 -0.189100 -0.160000 0.168000 -0.968000 +0.226900 0.351500 -0.182900 -0.224000 0.192000 -0.952000 +0.250000 0.370000 -0.182900 -0.184000 0.304000 -0.928000 +0.200000 0.351500 -0.169700 -0.320000 0.304000 -0.888000 +0.250000 0.401700 -0.172700 -0.016000 0.288000 -0.952000 +0.200000 0.401700 -0.169400 -0.056000 0.168000 -0.976000 +0.250000 0.451900 -0.137900 0.128000 0.536000 -0.824000 +0.200000 0.451900 -0.151000 0.136000 0.400000 -0.896000 +0.250000 0.466900 -0.121900 0.232000 0.968000 0.016000 +0.200000 0.484800 -0.121900 0.312000 0.872000 0.360000 +0.250000 0.451900 -0.094000 0.248000 0.784000 0.552000 +0.200000 0.453000 -0.060900 0.112000 0.728000 0.672000 +0.203100 0.451900 -0.060900 0.264000 0.672000 0.680000 +0.200000 0.451900 -0.059700 0.136000 0.632000 0.760000 +0.250000 0.432000 -0.060900 0.224000 0.624000 0.736000 +0.200000 0.401700 -0.033800 -0.352000 0.000000 0.928000 +0.250000 0.401700 -0.026800 -0.216000 0.176000 0.952000 +0.200000 0.352900 -0.060900 -0.368000 -0.496000 0.776000 +0.250000 0.351500 -0.020200 -0.488000 -0.416000 0.760000 +0.201200 0.351500 -0.060900 -0.488000 -0.576000 0.648000 +0.250000 0.317900 -0.060900 -0.432000 -0.680000 0.584000 +0.200000 0.351500 -0.062100 -0.312000 -0.640000 0.696000 +0.250000 0.301200 -0.083600 -0.096000 -0.744000 0.648000 +0.200000 0.301200 -0.098800 -0.120000 -0.584000 0.800000 +0.250000 0.256500 -0.121900 -0.200000 -0.800000 0.552000 +0.200000 0.269500 -0.121900 -0.008000 -0.896000 0.432000 +0.200000 0.301200 -0.098800 -0.120000 -0.584000 0.800000 +0.150000 0.253300 -0.121900 0.144000 -0.672000 0.712000 +0.150000 0.301200 -0.094700 0.096000 -0.408000 0.904000 +0.200000 0.301200 -0.098800 -0.120000 -0.584000 0.800000 +0.150000 0.351500 -0.070300 -0.056000 -0.480000 0.872000 +0.200000 0.351500 -0.062100 -0.312000 -0.640000 0.696000 +0.150000 0.401700 -0.062100 -0.392000 -0.400000 0.816000 +0.200000 0.352900 -0.060900 -0.368000 -0.496000 0.776000 +0.151400 0.401700 -0.060900 -0.480000 -0.416000 0.760000 +0.200000 0.401700 -0.033800 -0.352000 0.000000 0.928000 +0.150000 0.409600 -0.060900 -0.208000 -0.072000 0.968000 +0.200000 0.451900 -0.059700 0.136000 0.632000 0.760000 +0.150000 0.451900 -0.057100 -0.080000 0.496000 0.856000 +0.200000 0.453000 -0.060900 0.112000 0.728000 0.672000 +0.150000 0.456100 -0.060900 0.048000 0.664000 0.736000 +0.200000 0.484800 -0.121900 0.312000 0.872000 0.360000 +0.150000 0.502100 -0.119700 0.016000 0.656000 0.752000 +0.153400 0.502100 -0.121900 0.448000 0.824000 -0.336000 +0.150000 0.503100 -0.121900 0.272000 0.456000 -0.840000 +0.150000 0.502100 -0.123200 0.032000 0.424000 -0.896000 +0.138500 0.502100 -0.121900 -0.184000 0.952000 -0.216000 +0.150000 0.451900 -0.151900 0.184000 0.376000 -0.904000 +0.100000 0.494400 -0.121900 -0.184000 0.952000 -0.216000 +0.100000 0.451900 -0.146900 -0.088000 0.224000 -0.968000 +0.050000 0.485400 -0.121900 -0.032000 0.904000 -0.408000 +0.050000 0.451900 -0.139600 -0.080000 0.232000 -0.960000 +0.000000 0.493800 -0.121900 0.128000 0.960000 -0.232000 +0.000000 0.451900 -0.135500 0.000000 0.160000 -0.984000 +-0.050000 0.500300 -0.121900 -0.104000 0.896000 -0.424000 +-0.050000 0.451900 -0.137500 0.040000 0.112000 -0.992000 +-0.100000 0.479800 -0.121900 -0.288000 0.584000 -0.752000 +-0.100000 0.451900 -0.142300 -0.128000 0.312000 -0.936000 +-0.150000 0.453400 -0.121900 -0.320000 0.624000 -0.704000 +-0.150000 0.451900 -0.123200 -0.344000 0.512000 -0.784000 +-0.152100 0.451900 -0.121900 -0.424000 0.536000 -0.720000 +-0.150000 0.401700 -0.148200 -0.240000 0.400000 -0.872000 +-0.200000 0.409200 -0.121900 -0.400000 0.464000 -0.776000 +-0.200000 0.401700 -0.127400 -0.400000 0.440000 -0.800000 +-0.208300 0.401700 -0.121900 -0.432000 0.432000 -0.784000 +-0.200000 0.351500 -0.146000 -0.416000 0.224000 -0.872000 +-0.233300 0.351500 -0.121900 -0.616000 0.184000 -0.752000 +-0.200000 0.301200 -0.154100 -0.392000 0.112000 -0.904000 +-0.245300 0.301200 -0.121900 -0.680000 0.120000 -0.720000 +-0.200000 0.251000 -0.156200 -0.432000 0.168000 -0.880000 +-0.250000 0.268200 -0.121900 -0.464000 0.088000 -0.872000 +-0.250000 0.251000 -0.124000 -0.376000 0.088000 -0.920000 +-0.254200 0.251000 -0.121900 -0.384000 0.088000 -0.912000 +-0.250000 0.200800 -0.129700 -0.392000 0.152000 -0.904000 +-0.263400 0.200800 -0.121900 -0.480000 0.216000 -0.840000 +-0.250000 0.150600 -0.154100 -0.464000 0.344000 -0.808000 +-0.295300 0.150600 -0.121900 -0.728000 0.520000 -0.432000 +-0.250000 0.100400 -0.182000 -0.504000 0.488000 -0.704000 +-0.300000 0.144000 -0.121900 -0.728000 0.496000 -0.456000 +-0.300000 0.100400 -0.141500 -0.560000 0.512000 -0.640000 +-0.250000 0.100400 -0.182000 -0.504000 0.488000 -0.704000 +-0.300000 0.052000 -0.182900 -0.664000 0.464000 -0.568000 +-0.250000 0.099600 -0.182900 -0.488000 0.616000 -0.608000 +-0.250000 0.100400 -0.182000 -0.504000 0.488000 -0.704000 +-0.249100 0.100400 -0.182900 -0.576000 0.496000 -0.640000 +-0.250000 0.150600 -0.154100 -0.464000 0.344000 -0.808000 +-0.216700 0.150600 -0.182900 -0.560000 0.376000 -0.728000 +-0.250000 0.200800 -0.129700 -0.392000 0.152000 -0.904000 +-0.200000 0.172600 -0.182900 -0.488000 0.416000 -0.760000 +-0.200000 0.200800 -0.161600 -0.480000 0.384000 -0.776000 +-0.173800 0.200800 -0.182900 -0.480000 0.344000 -0.800000 +-0.200000 0.251000 -0.156200 -0.432000 0.168000 -0.880000 +-0.153800 0.251000 -0.182900 -0.312000 0.176000 -0.928000 +-0.200000 0.301200 -0.154100 -0.392000 0.112000 -0.904000 +-0.150000 0.257900 -0.182900 -0.288000 0.168000 -0.936000 +-0.150000 0.301200 -0.169700 -0.080000 0.248000 -0.960000 +-0.100000 0.273500 -0.182900 -0.112000 0.208000 -0.968000 +-0.100000 0.301200 -0.172200 -0.168000 0.416000 -0.888000 +-0.058500 0.301200 -0.182900 -0.128000 0.320000 -0.936000 +-0.100000 0.351500 -0.158200 0.008000 0.264000 -0.960000 +-0.050000 0.304700 -0.182900 -0.120000 0.336000 -0.928000 +-0.050000 0.351500 -0.155800 -0.048000 0.328000 -0.936000 +0.000000 0.313300 -0.182900 -0.064000 0.304000 -0.944000 +0.000000 0.351500 -0.164900 -0.080000 0.368000 -0.920000 +0.050000 0.327400 -0.182900 -0.016000 0.344000 -0.936000 +0.050000 0.351500 -0.166400 0.000000 0.392000 -0.912000 +0.100000 0.320500 -0.182900 0.096000 0.312000 -0.936000 +0.100000 0.351500 -0.169000 0.056000 0.272000 -0.952000 +0.133500 0.301200 -0.182900 0.272000 0.264000 -0.920000 +0.150000 0.351500 -0.160600 0.144000 0.128000 -0.976000 +0.150000 0.301200 -0.172900 0.456000 0.432000 -0.768000 +0.200000 0.351500 -0.169700 -0.320000 0.304000 -0.888000 +0.200000 0.301200 -0.179700 -0.152000 -0.352000 -0.920000 +0.226900 0.351500 -0.182900 -0.224000 0.192000 -0.952000 +0.215700 0.301200 -0.182900 -0.120000 -0.160000 -0.976000 +0.215700 0.301200 -0.182900 -0.120000 -0.160000 -0.976000 +0.000000 0.351500 -0.051600 0.280000 -0.248000 0.920000 +0.000000 0.351500 -0.051600 0.280000 -0.248000 0.920000 +0.042100 0.351500 -0.060900 0.160000 -0.080000 0.976000 +0.000000 0.334500 -0.060900 0.312000 -0.368000 0.864000 +0.050000 0.351500 -0.062500 0.000000 -0.264000 0.960000 +0.000000 0.301200 -0.076500 0.296000 -0.272000 0.904000 +0.050000 0.301200 -0.074400 0.160000 -0.248000 0.952000 +0.000000 0.251000 -0.086600 0.344000 -0.360000 0.864000 +0.050000 0.251000 -0.100200 0.224000 -0.464000 0.848000 +0.000000 0.211400 -0.121900 0.496000 -0.712000 0.480000 +0.050000 0.230600 -0.121900 0.312000 -0.824000 0.464000 +0.000000 0.200800 -0.169000 0.576000 -0.744000 0.320000 +0.050000 0.219300 -0.182900 0.280000 -0.632000 -0.712000 +0.008500 0.200800 -0.182900 0.416000 -0.688000 -0.584000 +0.050000 0.251000 -0.200200 0.040000 -0.232000 -0.968000 +0.000000 0.200800 -0.186400 0.272000 -0.456000 -0.840000 +0.000000 0.251000 -0.201400 0.024000 -0.152000 -0.984000 +-0.050000 0.200800 -0.204500 0.304000 -0.328000 -0.888000 +-0.050000 0.251000 -0.205600 -0.136000 0.216000 -0.960000 +-0.100000 0.200800 -0.221500 0.056000 0.392000 -0.912000 +-0.100000 0.251000 -0.188700 -0.192000 0.256000 -0.944000 +-0.150000 0.200800 -0.199200 -0.328000 0.272000 -0.896000 +-0.150000 0.251000 -0.184400 -0.280000 0.168000 -0.936000 +-0.173800 0.200800 -0.182900 -0.480000 0.344000 -0.800000 +-0.153800 0.251000 -0.182900 -0.312000 0.176000 -0.928000 +-0.150000 0.251000 -0.184400 -0.280000 0.168000 -0.936000 +-0.150000 0.257900 -0.182900 -0.288000 0.168000 -0.936000 +-0.100000 0.251000 -0.188700 -0.192000 0.256000 -0.944000 +-0.100000 0.273500 -0.182900 -0.112000 0.208000 -0.968000 +-0.050000 0.251000 -0.205600 -0.136000 0.216000 -0.960000 +-0.058500 0.301200 -0.182900 -0.128000 0.320000 -0.936000 +-0.050000 0.301200 -0.184300 -0.112000 0.296000 -0.944000 +-0.050000 0.304700 -0.182900 -0.120000 0.336000 -0.928000 +0.000000 0.301200 -0.186500 -0.056000 0.232000 -0.968000 +0.000000 0.313300 -0.182900 -0.064000 0.304000 -0.944000 +0.050000 0.301200 -0.192400 0.024000 0.192000 -0.976000 +0.050000 0.327400 -0.182900 -0.016000 0.344000 -0.936000 +0.100000 0.301200 -0.188500 0.112000 0.128000 -0.984000 +0.100000 0.320500 -0.182900 0.096000 0.312000 -0.936000 +0.133500 0.301200 -0.182900 0.272000 0.264000 -0.920000 +0.133500 0.301200 -0.182900 0.272000 0.264000 -0.920000 +0.000000 -0.301200 -0.001900 0.408000 -0.704000 0.568000 +0.000000 -0.301200 -0.001900 0.408000 -0.704000 0.568000 +0.032200 -0.301200 -0.060900 0.552000 -0.696000 0.448000 +0.000000 -0.326800 -0.060900 0.344000 -0.824000 0.432000 +0.000000 -0.326800 -0.060900 0.344000 -0.824000 0.432000 +0.065700 0.351500 -0.060900 -0.064000 -0.312000 0.944000 +0.065700 0.351500 -0.060900 -0.064000 -0.312000 0.944000 +0.100000 0.368600 -0.060900 0.104000 0.120000 0.984000 +0.100000 0.351500 -0.058100 0.120000 -0.240000 0.960000 +0.111400 0.351500 -0.060900 0.184000 -0.224000 0.952000 +0.100000 0.345700 -0.060900 0.056000 -0.392000 0.912000 +0.100000 0.351500 -0.058100 0.120000 -0.240000 0.960000 +0.065700 0.351500 -0.060900 -0.064000 -0.312000 0.944000 +0.100000 0.345700 -0.060900 0.056000 -0.392000 0.912000 +0.050000 0.351500 -0.062500 0.000000 -0.264000 0.960000 +0.100000 0.301200 -0.081200 0.144000 -0.392000 0.904000 +0.050000 0.301200 -0.074400 0.160000 -0.248000 0.952000 +0.100000 0.251000 -0.119300 0.048000 -0.664000 0.736000 +0.050000 0.251000 -0.100200 0.224000 -0.464000 0.848000 +0.100000 0.248700 -0.121900 0.064000 -0.824000 0.552000 +0.050000 0.230600 -0.121900 0.312000 -0.824000 0.464000 +0.100000 0.246100 -0.182900 0.136000 -0.488000 -0.856000 +0.050000 0.219300 -0.182900 0.280000 -0.632000 -0.712000 +0.100000 0.251000 -0.185300 0.160000 -0.296000 -0.936000 +0.050000 0.251000 -0.200200 0.040000 -0.232000 -0.968000 +0.100000 0.301200 -0.188500 0.112000 0.128000 -0.984000 +0.050000 0.301200 -0.192400 0.024000 0.192000 -0.976000 +0.050000 0.251000 -0.200200 0.040000 -0.232000 -0.968000 +0.000000 0.301200 -0.186500 -0.056000 0.232000 -0.968000 +0.000000 0.251000 -0.201400 0.024000 -0.152000 -0.984000 +-0.050000 0.301200 -0.184300 -0.112000 0.296000 -0.944000 +-0.050000 0.251000 -0.205600 -0.136000 0.216000 -0.960000 +-0.050000 0.251000 -0.205600 -0.136000 0.216000 -0.960000 +0.150000 0.456100 -0.060900 0.048000 0.664000 0.736000 +0.150000 0.456100 -0.060900 0.048000 0.664000 0.736000 +0.150000 0.451900 -0.057100 -0.080000 0.496000 0.856000 +0.121900 0.451900 -0.060900 -0.112000 0.472000 0.872000 +0.150000 0.409600 -0.060900 -0.208000 -0.072000 0.968000 +0.100000 0.451900 -0.066700 -0.192000 0.072000 0.976000 +0.150000 0.401700 -0.062100 -0.392000 -0.400000 0.816000 +0.100000 0.401700 -0.066700 -0.048000 0.000000 0.992000 +0.100000 0.451900 -0.066700 -0.192000 0.072000 0.976000 +0.050000 0.401700 -0.062500 -0.008000 0.136000 0.984000 +0.050000 0.451900 -0.077800 0.016000 0.408000 0.912000 +0.000000 0.401700 -0.062800 0.256000 0.176000 0.944000 +0.000000 0.451900 -0.081100 0.280000 0.456000 0.832000 +-0.005200 0.401700 -0.060900 0.264000 0.168000 0.944000 +-0.023600 0.451900 -0.060900 0.376000 0.152000 0.904000 +0.000000 0.451900 -0.081100 0.280000 0.456000 0.832000 +-0.033200 0.502100 -0.060900 0.616000 0.496000 0.600000 +0.000000 0.493800 -0.121900 0.128000 0.960000 -0.232000 +-0.050000 0.502100 -0.117100 -0.040000 0.912000 -0.392000 +-0.050000 0.500300 -0.121900 -0.104000 0.896000 -0.424000 +-0.100000 0.502100 -0.081300 -0.184000 0.840000 -0.488000 +-0.100000 0.479800 -0.121900 -0.288000 0.584000 -0.752000 +-0.100000 0.479800 -0.121900 -0.288000 0.584000 -0.752000 +0.350000 0.302200 -0.060900 -0.144000 -0.624000 0.760000 +0.350000 0.302200 -0.060900 -0.144000 -0.624000 0.760000 +0.300000 0.310700 -0.060900 -0.072000 -0.760000 0.640000 +0.350000 0.351500 -0.021800 0.032000 -0.048000 0.992000 +0.300000 0.351500 -0.009100 -0.016000 -0.144000 0.984000 +0.300000 0.351500 -0.009100 -0.016000 -0.144000 0.984000 +0.395100 0.251000 -0.060900 -0.344000 -0.184000 0.912000 +0.395100 0.251000 -0.060900 -0.344000 -0.184000 0.912000 +0.400000 0.251000 -0.058700 -0.328000 -0.176000 0.920000 +0.400000 0.242400 -0.060900 -0.352000 -0.192000 0.904000 +0.400000 0.242400 -0.060900 -0.352000 -0.192000 0.904000 +0.450000 0.401700 -0.038900 -0.120000 0.592000 0.784000 +0.450000 0.401700 -0.038900 -0.120000 0.592000 0.784000 +0.500000 0.401700 -0.057700 0.096000 0.864000 0.480000 +0.450000 0.414500 -0.060900 0.192000 0.928000 0.304000 +0.500000 0.403100 -0.060900 0.112000 0.944000 0.280000 +0.450000 0.422200 -0.121900 0.368000 0.832000 -0.392000 +0.500000 0.401700 -0.069300 0.168000 0.952000 -0.216000 +0.488600 0.401700 -0.121900 0.504000 0.776000 -0.368000 +0.450000 0.422200 -0.121900 0.368000 0.832000 -0.392000 +0.450000 0.401700 -0.160800 0.376000 0.656000 -0.640000 +0.450000 0.401700 -0.160800 0.376000 0.656000 -0.640000 +0.460500 0.150600 -0.060900 -0.624000 -0.512000 0.584000 +0.460500 0.150600 -0.060900 -0.624000 -0.512000 0.584000 +0.500000 0.150600 -0.020200 -0.704000 -0.472000 0.520000 +0.500000 0.107000 -0.060900 -0.608000 -0.480000 0.616000 +0.500000 0.107000 -0.060900 -0.608000 -0.480000 0.616000 +0.500000 0.000000 -0.045100 -0.376000 -0.208000 0.896000 +0.500000 0.000000 -0.045100 -0.376000 -0.208000 0.896000 +0.500000 0.050200 -0.057700 -0.560000 0.128000 0.816000 +0.478700 0.000000 -0.060900 -0.440000 -0.008000 0.888000 +0.495100 0.050200 -0.060900 -0.456000 0.136000 0.872000 +0.450000 0.000000 -0.073300 -0.344000 -0.088000 0.928000 +0.450000 0.050200 -0.077000 -0.360000 0.120000 0.920000 +0.400000 0.000000 -0.102200 -0.272000 0.176000 0.936000 +0.400000 0.050200 -0.114800 -0.552000 0.256000 0.784000 +0.351500 0.000000 -0.121900 -0.376000 0.528000 0.752000 +0.393200 0.050200 -0.121900 -0.648000 0.352000 0.664000 +0.350000 0.000000 -0.123200 -0.512000 0.592000 0.608000 +0.357200 0.050200 -0.182900 -0.736000 0.640000 0.184000 +0.350000 0.043300 -0.182900 -0.488000 0.704000 0.504000 +0.351400 0.050200 -0.243900 -0.480000 0.768000 -0.416000 +0.350000 0.049300 -0.243900 -0.512000 0.784000 -0.320000 +0.350000 0.043300 -0.182900 -0.488000 0.704000 0.504000 +0.300000 0.032100 -0.243900 -0.576000 0.680000 -0.432000 +0.300000 0.018000 -0.182900 -0.296000 0.768000 0.552000 +0.350000 0.043300 -0.182900 -0.488000 0.704000 0.504000 +0.300000 0.000000 -0.166100 -0.488000 0.464000 0.728000 +0.350000 0.000000 -0.123200 -0.512000 0.592000 0.608000 +0.300000 -0.050200 -0.130700 -0.504000 0.472000 0.720000 +0.350000 -0.001200 -0.121900 -0.472000 0.472000 0.736000 +0.307700 -0.050200 -0.121900 -0.592000 0.464000 0.648000 +0.350000 -0.050200 -0.093300 -0.312000 0.392000 0.856000 +0.300000 -0.060700 -0.121900 -0.512000 0.456000 0.720000 +0.350000 -0.100400 -0.081200 -0.280000 0.032000 0.952000 +0.300000 -0.100400 -0.098900 -0.360000 0.344000 0.856000 +0.350000 -0.150600 -0.101500 0.088000 -0.352000 0.928000 +0.300000 -0.150600 -0.090800 0.240000 -0.024000 0.968000 +0.350000 -0.182300 -0.121900 -0.032000 -0.520000 0.848000 +0.300000 -0.200800 -0.101500 0.424000 -0.216000 0.872000 +0.329200 -0.200800 -0.121900 0.376000 -0.264000 0.880000 +0.300000 -0.234400 -0.121900 0.104000 -0.472000 0.872000 +0.350000 -0.200800 -0.137500 0.248000 -0.232000 0.936000 +0.300000 -0.251000 -0.132800 -0.224000 -0.464000 0.856000 +0.350000 -0.234100 -0.121900 0.384000 0.224000 0.888000 +0.328900 -0.251000 -0.121900 -0.264000 -0.304000 0.912000 +0.350000 -0.251000 -0.114600 0.576000 -0.200000 0.784000 +0.350000 -0.260400 -0.121900 0.448000 -0.472000 0.752000 +0.354900 -0.251000 -0.121900 0.704000 -0.304000 0.632000 +0.350000 -0.251000 -0.114600 0.576000 -0.200000 0.784000 +0.350000 -0.234100 -0.121900 0.384000 0.224000 0.888000 +0.354900 -0.251000 -0.121900 0.704000 -0.304000 0.632000 +0.350000 -0.200800 -0.137500 0.248000 -0.232000 0.936000 +0.400000 -0.203000 -0.121900 -0.184000 -0.672000 0.712000 +0.391400 -0.200800 -0.121900 -0.176000 -0.648000 0.736000 +0.400000 -0.200800 -0.119100 -0.200000 -0.688000 0.688000 +0.350000 -0.182300 -0.121900 -0.032000 -0.520000 0.848000 +0.400000 -0.150600 -0.068400 -0.344000 -0.312000 0.880000 +0.350000 -0.150600 -0.101500 0.088000 -0.352000 0.928000 +0.400000 -0.100400 -0.080400 -0.024000 0.176000 0.976000 +0.350000 -0.100400 -0.081200 -0.280000 0.032000 0.952000 +0.400000 -0.050200 -0.089900 -0.128000 0.176000 0.968000 +0.350000 -0.050200 -0.093300 -0.312000 0.392000 0.856000 +0.400000 0.000000 -0.102200 -0.272000 0.176000 0.936000 +0.350000 -0.001200 -0.121900 -0.472000 0.472000 0.736000 +0.351500 0.000000 -0.121900 -0.376000 0.528000 0.752000 +0.350000 0.000000 -0.123200 -0.512000 0.592000 0.608000 +0.350000 0.000000 -0.123200 -0.512000 0.592000 0.608000 +0.478700 0.000000 -0.060900 -0.440000 -0.008000 0.888000 +0.478700 0.000000 -0.060900 -0.440000 -0.008000 0.888000 +0.500000 0.000000 -0.045100 -0.376000 -0.208000 0.896000 +0.500000 -0.026100 -0.060900 -0.336000 -0.328000 0.872000 +0.550000 0.000000 -0.046900 0.008000 -0.120000 0.992000 +0.550000 -0.046200 -0.060900 -0.104000 -0.168000 0.976000 +0.600000 0.000000 -0.044900 -0.016000 -0.720000 0.688000 +0.600000 -0.012300 -0.060900 0.104000 -0.576000 0.800000 +0.550000 -0.046200 -0.060900 -0.104000 -0.168000 0.976000 +0.600000 -0.050200 -0.088500 0.448000 -0.400000 0.792000 +0.550000 -0.050200 -0.061500 -0.064000 -0.152000 0.984000 +0.600000 -0.100400 -0.077400 0.584000 0.048000 0.800000 +0.550000 -0.100400 -0.076900 0.056000 0.056000 0.992000 +0.550000 -0.050200 -0.061500 -0.064000 -0.152000 0.984000 +0.500000 -0.100400 -0.086800 -0.048000 0.256000 0.960000 +0.500000 -0.050200 -0.068900 -0.136000 -0.144000 0.976000 +0.450000 -0.100400 -0.078400 -0.088000 0.200000 0.968000 +0.450000 -0.050200 -0.086300 -0.128000 -0.040000 0.984000 +0.400000 -0.100400 -0.080400 -0.024000 0.176000 0.976000 +0.400000 -0.050200 -0.089900 -0.128000 0.176000 0.968000 +0.450000 -0.050200 -0.086300 -0.128000 -0.040000 0.984000 +0.400000 0.000000 -0.102200 -0.272000 0.176000 0.936000 +0.450000 0.000000 -0.073300 -0.344000 -0.088000 0.928000 +0.450000 -0.050200 -0.086300 -0.128000 -0.040000 0.984000 +0.478700 0.000000 -0.060900 -0.440000 -0.008000 0.888000 +0.500000 -0.050200 -0.068900 -0.136000 -0.144000 0.976000 +0.500000 -0.026100 -0.060900 -0.336000 -0.328000 0.872000 +0.550000 -0.050200 -0.061500 -0.064000 -0.152000 0.984000 +0.550000 -0.046200 -0.060900 -0.104000 -0.168000 0.976000 +0.550000 -0.046200 -0.060900 -0.104000 -0.168000 0.976000 +0.500000 0.401700 -0.057700 0.096000 0.864000 0.480000 +0.500000 0.401700 -0.057700 0.096000 0.864000 0.480000 +0.500000 0.403100 -0.060900 0.112000 0.944000 0.280000 +0.517100 0.401700 -0.060900 0.080000 0.968000 0.224000 +0.500000 0.401700 -0.069300 0.168000 0.952000 -0.216000 +0.500000 0.401700 -0.069300 0.168000 0.952000 -0.216000 +0.500000 0.266900 0.000000 -0.760000 -0.040000 0.640000 +0.500000 0.266900 0.000000 -0.760000 -0.040000 0.640000 +0.500800 0.251000 0.000000 -0.792000 -0.016000 0.608000 +0.500000 0.251000 -0.000900 -0.496000 0.112000 0.856000 +0.500000 0.251000 -0.000900 -0.496000 0.112000 0.856000 +0.500000 0.050200 -0.057700 -0.560000 0.128000 0.816000 +0.500000 0.050200 -0.057700 -0.560000 0.128000 0.816000 +0.500000 0.000000 -0.045100 -0.376000 -0.208000 0.896000 +0.550000 0.050200 -0.037800 -0.320000 -0.688000 0.640000 +0.550000 0.000000 -0.046900 0.008000 -0.120000 0.992000 +0.600000 0.050200 -0.005300 -0.440000 -0.752000 0.480000 +0.600000 0.000000 -0.044900 -0.016000 -0.720000 0.688000 +0.600000 0.000000 -0.044900 -0.016000 -0.720000 0.688000 +0.550000 0.104000 0.000000 -0.664000 -0.568000 0.464000 +0.550000 0.104000 0.000000 -0.664000 -0.568000 0.464000 +0.553100 0.100400 0.000000 -0.664000 -0.576000 0.464000 +0.550000 0.100400 -0.005700 -0.672000 -0.576000 0.448000 +0.550000 0.100400 -0.005700 -0.672000 -0.576000 0.448000 +0.550000 -0.200800 -0.034900 0.016000 -0.040000 0.992000 +0.550000 -0.200800 -0.034900 0.016000 -0.040000 0.992000 +0.600000 -0.200800 -0.056500 0.336000 0.448000 0.816000 +0.550000 -0.159500 -0.060900 0.248000 0.472000 0.840000 +0.600000 -0.194800 -0.060900 0.352000 0.496000 0.784000 +0.550000 -0.150600 -0.067100 0.240000 0.480000 0.840000 +0.600000 -0.150600 -0.093600 0.304000 0.568000 0.752000 +0.600000 -0.194800 -0.060900 0.352000 0.496000 0.784000 +0.650000 -0.150600 -0.116200 0.720000 0.480000 0.488000 +0.608400 -0.200800 -0.060900 0.360000 0.488000 0.792000 +0.650000 -0.200800 -0.092600 0.656000 0.384000 0.640000 +0.650000 -0.242600 -0.060900 0.392000 0.384000 0.824000 +0.677400 -0.200800 -0.121900 0.528000 0.512000 0.672000 +0.657600 -0.251000 -0.060900 0.456000 -0.072000 0.880000 +0.700000 -0.217500 -0.121900 0.616000 0.552000 0.544000 +0.700000 -0.251000 -0.086700 0.608000 0.464000 0.632000 +0.719200 -0.251000 -0.121900 0.760000 0.456000 0.440000 +0.700000 -0.301200 -0.068800 0.336000 0.392000 0.848000 +0.750000 -0.297400 -0.121900 0.656000 0.584000 0.464000 +0.750000 -0.301200 -0.116500 0.704000 0.400000 0.568000 +0.752700 -0.301200 -0.121900 0.792000 0.344000 0.488000 +0.750000 -0.351500 -0.097900 0.640000 0.048000 0.760000 +0.775700 -0.351500 -0.121900 0.600000 0.328000 0.720000 +0.750000 -0.401700 -0.115900 -0.264000 -0.344000 0.896000 +0.800000 -0.391100 -0.121900 0.384000 0.416000 0.816000 +0.800000 -0.401700 -0.115500 0.392000 0.184000 0.896000 +0.810500 -0.401700 -0.121900 0.456000 0.104000 0.872000 +0.800000 -0.418600 -0.121900 0.304000 -0.320000 0.888000 +0.850000 -0.401700 -0.151500 0.608000 0.552000 0.560000 +0.800000 -0.451900 -0.135400 0.168000 -0.384000 0.904000 +0.850000 -0.451900 -0.123600 0.328000 0.296000 0.888000 +0.800000 -0.502100 -0.171200 -0.360000 -0.648000 0.664000 +0.850000 -0.502100 -0.142100 -0.224000 -0.520000 0.816000 +0.800000 -0.511100 -0.182900 -0.376000 -0.744000 0.544000 +0.850000 -0.533300 -0.182900 -0.416000 -0.736000 0.528000 +0.800000 -0.519900 -0.243900 -0.400000 -0.904000 -0.112000 +0.850000 -0.540400 -0.243900 -0.360000 -0.768000 -0.512000 +0.800000 -0.502100 -0.293400 -0.120000 -0.840000 -0.520000 +0.850000 -0.504700 -0.304800 -0.096000 -0.664000 -0.736000 +0.832800 -0.502100 -0.304800 -0.104000 -0.544000 -0.824000 +0.850000 -0.502100 -0.307100 0.032000 -0.240000 -0.968000 +0.850000 -0.490600 -0.304800 0.216000 0.112000 -0.968000 +0.856800 -0.502100 -0.304800 0.288000 0.144000 -0.944000 +0.850000 -0.451900 -0.293100 0.448000 0.248000 -0.848000 +0.900000 -0.502100 -0.284600 -0.008000 -0.096000 -0.992000 +0.900000 -0.451900 -0.272400 0.368000 0.408000 -0.824000 +0.950000 -0.502100 -0.277800 0.272000 0.288000 -0.912000 +0.950000 -0.451900 -0.300000 0.488000 0.464000 -0.728000 +1.000000 -0.502100 -0.271100 0.392000 0.584000 -0.696000 +0.980700 -0.451900 -0.243900 0.752000 0.648000 0.032000 +1.000000 -0.475100 -0.243900 0.736000 0.608000 -0.280000 +0.950000 -0.451900 -0.206400 0.504000 0.736000 0.440000 +1.000000 -0.502100 -0.189300 0.760000 0.568000 0.296000 +0.950000 -0.463500 -0.182900 0.464000 0.672000 0.568000 +0.998000 -0.502100 -0.182900 0.528000 0.664000 0.520000 +0.950000 -0.502100 -0.136000 -0.296000 0.400000 0.864000 +1.000000 -0.503200 -0.182900 0.400000 0.704000 0.576000 +0.950000 -0.531200 -0.121900 -0.376000 0.368000 0.840000 +1.000000 -0.544400 -0.121900 0.360000 0.712000 0.592000 +0.950000 -0.552300 -0.115100 -0.432000 -0.368000 0.816000 +1.000000 -0.552300 -0.111000 0.040000 -0.024000 0.992000 +0.950000 -0.560000 -0.121900 -0.400000 -0.536000 0.728000 +1.000000 -0.602500 -0.115100 -0.504000 -0.464000 0.712000 +0.992300 -0.602500 -0.121900 -0.520000 -0.480000 0.696000 +1.000000 -0.611000 -0.121900 -0.528000 -0.480000 0.696000 +0.950000 -0.602500 -0.169200 -0.536000 -0.520000 0.656000 +1.000000 -0.652700 -0.168000 -0.488000 -0.568000 0.656000 +0.950000 -0.619400 -0.182900 -0.632000 -0.592000 0.480000 +0.983200 -0.652700 -0.182900 -0.528000 -0.608000 0.584000 +0.950000 -0.619400 -0.243900 -0.600000 -0.584000 -0.536000 +0.979500 -0.652700 -0.243900 -0.672000 -0.664000 -0.304000 +0.950000 -0.602500 -0.260200 -0.544000 -0.504000 -0.664000 +1.000000 -0.652700 -0.268800 -0.592000 -0.512000 -0.608000 +0.990600 -0.602500 -0.304800 -0.488000 -0.376000 -0.784000 +1.000000 -0.614600 -0.304800 -0.488000 -0.376000 -0.776000 +1.000000 -0.602500 -0.311200 -0.448000 -0.336000 -0.816000 +0.990600 -0.602500 -0.304800 -0.488000 -0.376000 -0.784000 +1.000000 -0.552300 -0.319800 -0.248000 0.216000 -0.936000 +0.953900 -0.552300 -0.304800 -0.328000 0.312000 -0.888000 +1.000000 -0.525900 -0.304800 -0.248000 0.496000 -0.824000 +0.950000 -0.552300 -0.303200 -0.304000 0.392000 -0.864000 +1.000000 -0.502100 -0.271100 0.392000 0.584000 -0.696000 +0.950000 -0.502100 -0.277800 0.272000 0.288000 -0.912000 +0.950000 -0.552300 -0.303200 -0.304000 0.392000 -0.864000 +0.900000 -0.502100 -0.284600 -0.008000 -0.096000 -0.992000 +0.900000 -0.552300 -0.278500 -0.424000 -0.592000 -0.672000 +0.856800 -0.502100 -0.304800 0.288000 0.144000 -0.944000 +0.868400 -0.552300 -0.243900 -0.552000 -0.760000 -0.328000 +0.850000 -0.504700 -0.304800 -0.096000 -0.664000 -0.736000 +0.850000 -0.540400 -0.243900 -0.360000 -0.768000 -0.512000 +0.868400 -0.552300 -0.243900 -0.552000 -0.760000 -0.328000 +0.850000 -0.533300 -0.182900 -0.416000 -0.736000 0.528000 +0.876500 -0.552300 -0.182900 -0.528000 -0.672000 0.504000 +0.850000 -0.502100 -0.142100 -0.224000 -0.520000 0.816000 +0.900000 -0.552300 -0.159100 -0.496000 -0.592000 0.632000 +0.900000 -0.502100 -0.123800 -0.168000 -0.208000 0.960000 +0.940600 -0.552300 -0.121900 -0.512000 -0.272000 0.808000 +0.950000 -0.502100 -0.136000 -0.296000 0.400000 0.864000 +0.950000 -0.531200 -0.121900 -0.376000 0.368000 0.840000 +0.940600 -0.552300 -0.121900 -0.512000 -0.272000 0.808000 +0.950000 -0.552300 -0.115100 -0.432000 -0.368000 0.816000 +0.950000 -0.560000 -0.121900 -0.400000 -0.536000 0.728000 +0.940600 -0.552300 -0.121900 -0.512000 -0.272000 0.808000 +0.950000 -0.602500 -0.169200 -0.536000 -0.520000 0.656000 +0.900000 -0.552300 -0.159100 -0.496000 -0.592000 0.632000 +0.935000 -0.602500 -0.182900 -0.552000 -0.552000 0.608000 +0.900000 -0.573700 -0.182900 -0.608000 -0.704000 0.344000 +0.933200 -0.602500 -0.243900 -0.584000 -0.624000 -0.512000 +0.900000 -0.578300 -0.243900 -0.552000 -0.704000 -0.440000 +0.950000 -0.602500 -0.260200 -0.544000 -0.504000 -0.664000 +0.900000 -0.552300 -0.278500 -0.424000 -0.592000 -0.672000 +0.950000 -0.552300 -0.303200 -0.304000 0.392000 -0.864000 +0.950000 -0.602500 -0.260200 -0.544000 -0.504000 -0.664000 +0.953900 -0.552300 -0.304800 -0.328000 0.312000 -0.888000 +0.990600 -0.602500 -0.304800 -0.488000 -0.376000 -0.784000 +0.990600 -0.602500 -0.304800 -0.488000 -0.376000 -0.784000 +0.550000 -0.242100 -0.060900 -0.400000 -0.536000 0.736000 +0.550000 -0.242100 -0.060900 -0.400000 -0.536000 0.736000 +0.550000 -0.200800 -0.034900 0.016000 -0.040000 0.992000 +0.562800 -0.251000 -0.060900 -0.368000 -0.568000 0.720000 +0.600000 -0.200800 -0.056500 0.336000 0.448000 0.816000 +0.600000 -0.251000 -0.042400 -0.104000 -0.208000 0.968000 +0.608400 -0.200800 -0.060900 0.360000 0.488000 0.792000 +0.650000 -0.251000 -0.056300 0.424000 -0.024000 0.896000 +0.650000 -0.242600 -0.060900 0.392000 0.384000 0.824000 +0.657600 -0.251000 -0.060900 0.456000 -0.072000 0.880000 +0.650000 -0.251000 -0.056300 0.424000 -0.024000 0.896000 +0.650000 -0.258100 -0.060900 0.392000 -0.456000 0.792000 +0.600000 -0.251000 -0.042400 -0.104000 -0.208000 0.968000 +0.600000 -0.272000 -0.060900 -0.264000 -0.632000 0.720000 +0.562800 -0.251000 -0.060900 -0.368000 -0.568000 0.720000 +0.600000 -0.301200 -0.098800 -0.176000 -0.576000 0.792000 +0.550000 -0.251000 -0.069700 -0.416000 -0.584000 0.688000 +0.552600 -0.301200 -0.121900 -0.368000 -0.384000 0.840000 +0.550000 -0.300100 -0.121900 -0.624000 -0.616000 0.472000 +0.550000 -0.301200 -0.123600 -0.624000 -0.440000 0.632000 +0.552600 -0.301200 -0.121900 -0.368000 -0.384000 0.840000 +0.550000 -0.317100 -0.121900 -0.368000 0.064000 0.920000 +0.600000 -0.333000 -0.121900 0.024000 -0.312000 0.944000 +0.558500 -0.351500 -0.121900 0.208000 -0.648000 0.728000 +0.600000 -0.351500 -0.136300 0.144000 -0.792000 0.584000 +0.550000 -0.353000 -0.121900 -0.032000 -0.832000 0.536000 +0.600000 -0.392700 -0.182900 -0.184000 -0.752000 0.624000 +0.550000 -0.389500 -0.182900 -0.304000 -0.784000 0.528000 +0.600000 -0.401700 -0.203000 -0.208000 -0.872000 0.432000 +0.550000 -0.401700 -0.218900 -0.128000 -0.904000 0.392000 +0.600000 -0.414700 -0.243900 -0.184000 -0.936000 0.272000 +0.550000 -0.409700 -0.243900 -0.144000 -0.944000 0.272000 +0.600000 -0.422100 -0.304800 -0.120000 -0.768000 -0.616000 +0.550000 -0.415900 -0.304800 -0.192000 -0.848000 -0.480000 +0.600000 -0.401700 -0.327900 -0.024000 -0.544000 -0.832000 +0.550000 -0.401700 -0.333700 -0.144000 -0.688000 -0.704000 +0.600000 -0.351500 -0.337900 0.040000 -0.080000 -0.992000 +0.550000 -0.351500 -0.364500 0.120000 -0.104000 -0.984000 +0.600000 -0.301200 -0.352300 -0.528000 -0.312000 -0.776000 +0.550000 -0.316300 -0.304800 -0.472000 0.688000 -0.536000 +0.567500 -0.301200 -0.304800 -0.696000 0.400000 -0.584000 +0.550000 -0.301200 -0.279200 -0.712000 0.120000 -0.680000 +0.550000 -0.272400 -0.304800 -0.680000 -0.440000 -0.576000 +0.550000 -0.272400 -0.304800 -0.680000 -0.440000 -0.576000 +0.616700 0.401700 0.000000 0.496000 0.864000 -0.032000 +0.616700 0.401700 0.000000 0.496000 0.864000 -0.032000 +0.650000 0.368200 0.000000 0.792000 0.584000 -0.144000 +0.600000 0.401700 -0.057700 0.168000 0.920000 -0.344000 +0.650000 0.351500 -0.057700 0.800000 0.552000 -0.208000 +0.600000 0.400600 -0.060900 -0.072000 0.912000 -0.384000 +0.648900 0.351500 -0.060900 0.576000 0.600000 -0.544000 +0.600000 0.351500 -0.101600 0.448000 0.496000 -0.736000 +0.650000 0.350500 -0.060900 0.712000 0.536000 -0.440000 +0.600000 0.310600 -0.121900 0.480000 0.424000 -0.760000 +0.650000 0.301200 -0.100800 0.528000 0.504000 -0.672000 +0.608400 0.301200 -0.121900 0.448000 0.488000 -0.744000 +0.600000 0.310600 -0.121900 0.480000 0.424000 -0.760000 +0.600000 0.301200 -0.128700 0.472000 0.520000 -0.704000 +0.600000 0.301200 -0.128700 0.472000 0.520000 -0.704000 +0.648900 0.351500 -0.060900 0.576000 0.600000 -0.544000 +0.648900 0.351500 -0.060900 0.576000 0.600000 -0.544000 +0.650000 0.350500 -0.060900 0.712000 0.536000 -0.440000 +0.650000 0.351500 -0.057700 0.800000 0.552000 -0.208000 +0.680100 0.301200 -0.060900 0.752000 0.544000 -0.368000 +0.660900 0.351500 0.000000 0.832000 0.512000 -0.176000 +0.685300 0.301200 0.000000 0.832000 0.536000 -0.104000 +0.680100 0.301200 -0.060900 0.752000 0.544000 -0.368000 +0.700000 0.279600 0.000000 0.792000 0.600000 -0.048000 +0.700000 0.278700 -0.060900 0.648000 0.584000 -0.472000 +0.700000 0.278700 -0.060900 0.648000 0.584000 -0.472000 +0.600000 -0.194800 -0.060900 0.352000 0.496000 0.784000 +0.600000 -0.194800 -0.060900 0.352000 0.496000 0.784000 +0.608400 -0.200800 -0.060900 0.360000 0.488000 0.792000 +0.600000 -0.200800 -0.056500 0.336000 0.448000 0.816000 +0.600000 -0.200800 -0.056500 0.336000 0.448000 0.816000 +0.650000 0.368200 0.000000 0.792000 0.584000 -0.144000 +0.650000 0.368200 0.000000 0.792000 0.584000 -0.144000 +0.650000 0.351500 -0.057700 0.800000 0.552000 -0.208000 +0.660900 0.351500 0.000000 0.832000 0.512000 -0.176000 +0.660900 0.351500 0.000000 0.832000 0.512000 -0.176000 +0.650000 0.000000 -0.040500 0.104000 -0.944000 0.296000 +0.650000 0.000000 -0.040500 0.104000 -0.944000 0.296000 +0.686800 0.000000 -0.060900 0.208000 -0.960000 0.144000 +0.650000 -0.010200 -0.060900 0.168000 -0.784000 0.592000 +0.698200 0.000000 -0.121900 0.296000 -0.952000 0.032000 +0.650000 -0.033500 -0.121900 0.512000 -0.672000 0.520000 +0.687300 0.000000 -0.182900 0.648000 -0.600000 -0.456000 +0.650000 -0.048900 -0.182900 0.792000 -0.584000 0.152000 +0.653800 0.000000 -0.243900 0.576000 -0.112000 -0.808000 +0.650000 -0.016900 -0.243900 0.704000 -0.184000 -0.672000 +0.650000 -0.048900 -0.182900 0.792000 -0.584000 0.152000 +0.637200 -0.050200 -0.243900 0.840000 -0.080000 -0.528000 +0.649100 -0.050200 -0.182900 0.816000 -0.544000 0.144000 +0.650000 -0.048900 -0.182900 0.792000 -0.584000 0.152000 +0.638000 -0.050200 -0.121900 0.800000 -0.536000 0.256000 +0.650000 -0.033500 -0.121900 0.512000 -0.672000 0.520000 +0.650000 -0.033500 -0.121900 0.512000 -0.672000 0.520000 +0.800000 -0.015400 0.000000 -0.560000 -0.800000 0.184000 +0.800000 -0.015400 0.000000 -0.560000 -0.800000 0.184000 +0.772100 0.000000 0.000000 -0.504000 -0.832000 0.224000 +0.800000 -0.024700 -0.060900 -0.616000 -0.776000 0.088000 +0.753100 0.000000 -0.060900 -0.472000 -0.872000 0.000000 +0.800000 -0.027900 -0.121900 -0.664000 -0.736000 -0.072000 +0.756600 0.000000 -0.121900 -0.496000 -0.856000 -0.080000 +0.800000 -0.017800 -0.182900 -0.616000 -0.680000 -0.376000 +0.776700 0.000000 -0.182900 -0.576000 -0.728000 -0.360000 +0.800000 0.000000 -0.217200 -0.656000 -0.464000 -0.584000 +0.800000 0.000000 -0.217200 -0.656000 -0.464000 -0.584000 +0.900000 0.131100 0.000000 0.480000 0.848000 0.192000 +0.900000 0.131100 0.000000 0.480000 0.848000 0.192000 +0.950000 0.102000 0.000000 0.472000 0.864000 0.120000 +0.900000 0.143500 -0.060900 0.528000 0.808000 -0.240000 +0.950000 0.106300 -0.060900 0.576000 0.776000 -0.240000 +0.900000 0.127900 -0.121900 0.560000 0.776000 -0.264000 +0.950000 0.100400 -0.078300 0.560000 0.768000 -0.304000 +0.931600 0.100400 -0.121900 0.600000 0.744000 -0.272000 +0.950000 0.086300 -0.121900 0.544000 0.784000 -0.280000 +0.912000 0.100400 -0.182900 0.600000 0.704000 -0.360000 +0.950000 0.069900 -0.182900 0.544000 0.736000 -0.392000 +0.900000 0.100400 -0.203200 0.536000 0.688000 -0.472000 +0.950000 0.050200 -0.224500 0.472000 0.712000 -0.504000 +0.900000 0.070800 -0.243900 -0.096000 0.744000 -0.656000 +0.929600 0.050200 -0.243900 0.432000 0.672000 -0.584000 +0.900000 0.050200 -0.268900 0.208000 0.672000 -0.696000 +0.950000 0.037500 -0.243900 0.432000 0.688000 -0.576000 +0.900000 0.016700 -0.304800 -0.152000 0.720000 -0.664000 +0.950000 0.000000 -0.291100 0.424000 0.536000 -0.720000 +0.927400 0.000000 -0.304800 0.400000 0.560000 -0.720000 +0.950000 -0.016600 -0.304800 0.448000 0.520000 -0.720000 +0.900000 0.000000 -0.329500 -0.080000 0.648000 -0.744000 +0.950000 -0.050200 -0.338500 0.440000 0.400000 -0.800000 +0.900000 -0.050200 -0.348300 -0.256000 0.192000 -0.944000 +0.950000 -0.100400 -0.351000 0.336000 0.064000 -0.936000 +0.900000 -0.100400 -0.341700 -0.464000 -0.104000 -0.872000 +0.950000 -0.150600 -0.345500 -0.032000 0.064000 -0.992000 +0.900000 -0.150600 -0.332000 -0.672000 -0.328000 -0.656000 +0.900000 -0.150600 -0.332000 -0.672000 -0.328000 -0.656000 +0.995800 -0.200800 0.000000 -0.648000 -0.704000 0.264000 +0.995800 -0.200800 0.000000 -0.648000 -0.704000 0.264000 +0.950000 -0.168100 0.000000 -0.640000 -0.744000 0.184000 +0.973000 -0.200800 -0.060900 -0.584000 -0.760000 0.264000 +0.950000 -0.183700 -0.060900 -0.632000 -0.728000 0.232000 +0.950500 -0.200800 -0.121900 -0.632000 -0.744000 0.192000 +0.950000 -0.200400 -0.121900 -0.720000 -0.672000 0.136000 +0.950000 -0.200800 -0.124000 -0.680000 -0.712000 0.160000 +0.950000 -0.200800 -0.124000 -0.680000 -0.712000 0.160000 +-0.910500 0.251000 -0.121900 0.344000 0.880000 -0.304000 +-0.910500 0.251000 -0.121900 0.344000 0.880000 -0.304000 +-0.900000 0.246900 -0.121900 0.360000 0.872000 -0.304000 +-0.900000 0.251000 -0.101700 0.376000 0.896000 -0.216000 +-0.900000 0.251000 -0.101700 0.376000 0.896000 -0.216000 +-0.900000 -0.502100 -0.104000 -0.752000 0.000000 0.656000 +-0.900000 -0.502100 -0.104000 -0.752000 0.000000 0.656000 +-0.900000 -0.511500 -0.121900 -0.520000 -0.664000 0.528000 +-0.906100 -0.502100 -0.121900 -0.920000 0.072000 0.376000 +-0.900000 -0.542100 -0.182900 -0.808000 -0.560000 0.136000 +-0.925200 -0.502100 -0.182900 -0.976000 -0.008000 0.208000 +-0.900000 -0.551700 -0.243900 -0.808000 -0.568000 -0.120000 +-0.929300 -0.502100 -0.243900 -0.992000 0.064000 -0.008000 +-0.900000 -0.539600 -0.304800 -0.720000 -0.488000 -0.480000 +-0.920600 -0.502100 -0.304800 -0.888000 -0.288000 -0.344000 +-0.900000 -0.502100 -0.352600 -0.672000 0.128000 -0.720000 +-0.900000 -0.539600 -0.304800 -0.720000 -0.488000 -0.480000 +-0.864000 -0.502100 -0.365800 -0.304000 0.480000 -0.816000 +-0.891900 -0.552300 -0.304800 -0.800000 -0.568000 -0.136000 +-0.860100 -0.552300 -0.365800 -0.680000 -0.432000 -0.584000 +-0.850000 -0.602000 -0.304800 -0.640000 -0.736000 -0.184000 +-0.850000 -0.564700 -0.365800 -0.608000 -0.528000 -0.584000 +-0.849200 -0.602500 -0.304800 -0.536000 -0.720000 -0.432000 +-0.806700 -0.602500 -0.365800 -0.520000 -0.656000 -0.536000 +-0.800000 -0.636000 -0.304800 -0.536000 -0.792000 -0.272000 +-0.800000 -0.607700 -0.365800 -0.488000 -0.640000 -0.584000 +-0.750000 -0.652200 -0.304800 -0.040000 -0.952000 -0.288000 +-0.750000 -0.628000 -0.365800 -0.232000 -0.808000 -0.528000 +-0.734200 -0.652700 -0.304800 -0.024000 -0.976000 -0.192000 +-0.700000 -0.639000 -0.365800 -0.040000 -0.920000 -0.376000 +-0.700000 -0.652700 -0.309000 0.024000 -0.952000 -0.296000 +-0.650000 -0.641900 -0.365800 -0.024000 -0.952000 -0.280000 +-0.688500 -0.652700 -0.304800 0.080000 -0.992000 -0.064000 +-0.650000 -0.650400 -0.304800 0.048000 -0.992000 0.096000 +-0.700000 -0.652700 -0.298900 0.056000 -0.976000 0.184000 +-0.650000 -0.641500 -0.243900 0.040000 -0.976000 0.168000 +-0.700000 -0.645500 -0.243900 -0.008000 -0.984000 0.160000 +-0.650000 -0.630900 -0.182900 0.008000 -0.968000 0.232000 +-0.700000 -0.633400 -0.182900 -0.064000 -0.960000 0.248000 +-0.650000 -0.615500 -0.121900 -0.008000 -0.952000 0.304000 +-0.700000 -0.614700 -0.121900 -0.136000 -0.888000 0.424000 +-0.650000 -0.602500 -0.069700 -0.072000 -0.800000 0.584000 +-0.700000 -0.602500 -0.083600 -0.192000 -0.680000 0.704000 +-0.650000 -0.594800 -0.060900 -0.368000 -0.640000 0.664000 +-0.700000 -0.552300 -0.082500 -0.736000 -0.280000 0.608000 +-0.685200 -0.552300 -0.060900 -0.696000 -0.384000 0.592000 +-0.700000 -0.507800 -0.060900 -0.864000 -0.200000 0.448000 +-0.700000 -0.507800 -0.060900 -0.864000 -0.200000 0.448000 +-0.868200 -0.552300 -0.121900 -0.520000 -0.224000 0.816000 +-0.868200 -0.552300 -0.121900 -0.520000 -0.224000 0.816000 +-0.850000 -0.552300 -0.082300 -0.704000 -0.480000 0.504000 +-0.850000 -0.569100 -0.121900 -0.488000 -0.776000 0.384000 +-0.800000 -0.552300 -0.095900 0.424000 0.264000 0.864000 +-0.800000 -0.584500 -0.121900 -0.288000 -0.544000 0.776000 +-0.750000 -0.552300 -0.119400 0.072000 0.512000 0.848000 +-0.764000 -0.602500 -0.121900 -0.176000 -0.816000 0.544000 +-0.750000 -0.602500 -0.116200 -0.176000 -0.808000 0.544000 +-0.750000 -0.605000 -0.121900 -0.152000 -0.872000 0.456000 +-0.700000 -0.602500 -0.083600 -0.192000 -0.680000 0.704000 +-0.700000 -0.614700 -0.121900 -0.136000 -0.888000 0.424000 +-0.750000 -0.605000 -0.121900 -0.152000 -0.872000 0.456000 +-0.700000 -0.633400 -0.182900 -0.064000 -0.960000 0.248000 +-0.750000 -0.630100 -0.182900 -0.144000 -0.912000 0.360000 +-0.700000 -0.645500 -0.243900 -0.008000 -0.984000 0.160000 +-0.750000 -0.646000 -0.243900 -0.088000 -0.984000 0.144000 +-0.700000 -0.652700 -0.298900 0.056000 -0.976000 0.184000 +-0.750000 -0.652200 -0.304800 -0.040000 -0.952000 -0.288000 +-0.734200 -0.652700 -0.304800 -0.024000 -0.976000 -0.192000 +-0.700000 -0.652700 -0.298900 0.056000 -0.976000 0.184000 +-0.700000 -0.653800 -0.304800 0.056000 -0.992000 -0.080000 +-0.688500 -0.652700 -0.304800 0.080000 -0.992000 -0.064000 +-0.700000 -0.652700 -0.309000 0.024000 -0.952000 -0.296000 +-0.700000 -0.653800 -0.304800 0.056000 -0.992000 -0.080000 +-0.734200 -0.652700 -0.304800 -0.024000 -0.976000 -0.192000 +-0.734200 -0.652700 -0.304800 -0.024000 -0.976000 -0.192000 +-0.804300 0.200800 -0.121900 0.384000 0.872000 -0.288000 +-0.804300 0.200800 -0.121900 0.384000 0.872000 -0.288000 +-0.800000 0.198900 -0.121900 0.384000 0.872000 -0.288000 +-0.800000 0.200800 -0.113900 0.392000 0.880000 -0.256000 +-0.800000 0.200800 -0.113900 0.392000 0.880000 -0.256000 +-0.762700 -0.401700 -0.060900 -0.840000 -0.496000 0.168000 +-0.762700 -0.401700 -0.060900 -0.840000 -0.496000 0.168000 +-0.771000 -0.401700 -0.121900 -0.872000 -0.456000 0.128000 +-0.750000 -0.426100 -0.060900 -0.864000 -0.448000 0.200000 +-0.750000 -0.448400 -0.121900 -0.880000 -0.432000 0.160000 +-0.735400 -0.451900 -0.060900 -0.768000 -0.512000 0.360000 +-0.748200 -0.451900 -0.121900 -0.880000 -0.440000 0.160000 +-0.701200 -0.502100 -0.060900 -0.816000 -0.416000 0.392000 +-0.723300 -0.502100 -0.121900 -0.896000 -0.224000 0.368000 +-0.748200 -0.451900 -0.121900 -0.880000 -0.440000 0.160000 +-0.749300 -0.502100 -0.182900 -0.920000 -0.232000 0.288000 +-0.750000 -0.451900 -0.133400 -0.896000 -0.392000 0.184000 +-0.750000 -0.499500 -0.182900 -0.936000 -0.200000 0.264000 +-0.757600 -0.451900 -0.182900 -0.952000 -0.232000 0.184000 +-0.750000 -0.502100 -0.184800 -0.496000 0.696000 0.496000 +-0.769800 -0.451900 -0.243900 -0.952000 -0.080000 0.272000 +-0.800000 -0.502100 -0.227500 0.432000 0.824000 0.352000 +-0.800000 -0.496000 -0.243900 0.424000 0.840000 0.320000 +-0.820300 -0.502100 -0.182900 0.496000 0.792000 0.344000 +-0.850000 -0.480800 -0.243900 0.376000 0.912000 0.152000 +-0.850000 -0.490700 -0.182900 0.328000 0.896000 0.288000 +-0.896800 -0.451900 -0.243900 0.600000 0.776000 0.136000 +-0.900000 -0.462200 -0.182900 0.320000 0.888000 0.304000 +-0.900000 -0.451900 -0.229200 0.512000 0.832000 0.168000 +-0.896800 -0.451900 -0.243900 0.600000 0.776000 0.136000 +-0.900000 -0.449600 -0.243900 0.496000 0.856000 0.136000 +-0.891000 -0.451900 -0.304800 0.528000 0.824000 -0.192000 +-0.900000 -0.446300 -0.304800 0.160000 0.912000 -0.360000 +-0.900000 -0.451900 -0.318500 0.104000 0.872000 -0.464000 +-0.912200 -0.451900 -0.304800 -0.496000 0.720000 -0.464000 +-0.900000 -0.446300 -0.304800 0.160000 0.912000 -0.360000 +-0.921000 -0.451900 -0.243900 -0.184000 0.968000 0.160000 +-0.900000 -0.449600 -0.243900 0.496000 0.856000 0.136000 +-0.900000 -0.451900 -0.229200 0.512000 0.832000 0.168000 +-0.900000 -0.451900 -0.229200 0.512000 0.832000 0.168000 +-0.700000 -0.602500 -0.083600 -0.192000 -0.680000 0.704000 +-0.700000 -0.602500 -0.083600 -0.192000 -0.680000 0.704000 +-0.750000 -0.602500 -0.116200 -0.176000 -0.808000 0.544000 +-0.700000 -0.552300 -0.082500 -0.736000 -0.280000 0.608000 +-0.750000 -0.552300 -0.119400 0.072000 0.512000 0.848000 +-0.750000 -0.552300 -0.119400 0.072000 0.512000 0.848000 +-0.650000 -0.594800 -0.060900 -0.368000 -0.640000 0.664000 +-0.650000 -0.594800 -0.060900 -0.368000 -0.640000 0.664000 +-0.650000 -0.602500 -0.069700 -0.072000 -0.800000 0.584000 +-0.600000 -0.601900 -0.060900 -0.072000 -0.808000 0.568000 +-0.600000 -0.602500 -0.062100 -0.056000 -0.816000 0.560000 +-0.550000 -0.588500 -0.060900 0.224000 -0.888000 0.384000 +-0.550000 -0.602500 -0.100200 0.256000 -0.912000 0.288000 +-0.500000 -0.570000 -0.060900 0.480000 -0.800000 0.328000 +-0.531000 -0.602500 -0.121900 0.248000 -0.920000 0.272000 +-0.500000 -0.589900 -0.121900 0.408000 -0.832000 0.352000 +-0.500000 -0.602500 -0.155300 0.000000 -0.920000 0.376000 +-0.531000 -0.602500 -0.121900 0.248000 -0.920000 0.272000 +-0.500000 -0.610400 -0.182900 -0.136000 -0.936000 0.304000 +-0.550000 -0.606400 -0.121900 0.192000 -0.952000 0.216000 +-0.550000 -0.618800 -0.182900 0.168000 -0.944000 0.272000 +-0.600000 -0.616000 -0.121900 0.080000 -0.960000 0.256000 +-0.600000 -0.629300 -0.182900 0.072000 -0.968000 0.224000 +-0.650000 -0.615500 -0.121900 -0.008000 -0.952000 0.304000 +-0.650000 -0.630900 -0.182900 0.008000 -0.968000 0.232000 +-0.600000 -0.629300 -0.182900 0.072000 -0.968000 0.224000 +-0.650000 -0.641500 -0.243900 0.040000 -0.976000 0.168000 +-0.600000 -0.640700 -0.243900 0.080000 -0.976000 0.192000 +-0.650000 -0.650400 -0.304800 0.048000 -0.992000 0.096000 +-0.600000 -0.650800 -0.304800 0.064000 -0.992000 0.000000 +-0.650000 -0.641900 -0.365800 -0.024000 -0.952000 -0.280000 +-0.600000 -0.645500 -0.365800 0.016000 -0.968000 -0.216000 +-0.650000 -0.621300 -0.426800 -0.080000 -0.904000 -0.400000 +-0.600000 -0.630300 -0.426800 -0.072000 -0.944000 -0.312000 +-0.600000 -0.645500 -0.365800 0.016000 -0.968000 -0.216000 +-0.550000 -0.626200 -0.426800 0.144000 -0.960000 -0.232000 +-0.550000 -0.637200 -0.365800 0.152000 -0.968000 -0.168000 +-0.500000 -0.621400 -0.426800 0.072000 -0.968000 -0.232000 +-0.500000 -0.633000 -0.365800 -0.088000 -0.968000 -0.200000 +-0.450000 -0.629300 -0.426800 -0.048000 -0.904000 -0.416000 +-0.450000 -0.645700 -0.365800 -0.144000 -0.904000 -0.392000 +-0.400000 -0.621700 -0.426800 0.392000 -0.856000 -0.304000 +-0.405700 -0.652700 -0.365800 -0.144000 -0.920000 -0.344000 +-0.400000 -0.652700 -0.368100 -0.128000 -0.872000 -0.456000 +-0.400000 -0.652700 -0.368100 -0.128000 -0.872000 -0.456000 +-0.650000 -0.602500 -0.069700 -0.072000 -0.800000 0.584000 +-0.650000 -0.602500 -0.069700 -0.072000 -0.800000 0.584000 +-0.650000 -0.615500 -0.121900 -0.008000 -0.952000 0.304000 +-0.600000 -0.602500 -0.062100 -0.056000 -0.816000 0.560000 +-0.600000 -0.616000 -0.121900 0.080000 -0.960000 0.256000 +-0.550000 -0.602500 -0.100200 0.256000 -0.912000 0.288000 +-0.550000 -0.606400 -0.121900 0.192000 -0.952000 0.216000 +-0.531000 -0.602500 -0.121900 0.248000 -0.920000 0.272000 +-0.531000 -0.602500 -0.121900 0.248000 -0.920000 0.272000 +-0.554400 -0.050200 -0.060900 0.944000 0.280000 0.128000 +-0.554400 -0.050200 -0.060900 0.944000 0.280000 0.128000 +-0.586600 -0.050200 -0.121900 0.872000 0.224000 -0.424000 +-0.550000 -0.066800 -0.060900 0.944000 0.320000 -0.008000 +-0.578300 -0.100400 -0.121900 0.848000 0.312000 -0.424000 +-0.550000 -0.100400 -0.079500 0.552000 0.552000 -0.616000 +-0.550000 -0.145600 -0.121900 0.512000 0.792000 -0.312000 +-0.578300 -0.100400 -0.121900 0.848000 0.312000 -0.424000 +-0.550000 -0.150600 -0.142400 0.376000 0.896000 -0.200000 +-0.594100 -0.100400 -0.182900 0.816000 0.296000 -0.480000 +-0.561800 -0.150600 -0.182900 0.544000 0.784000 -0.280000 +-0.550000 -0.150600 -0.142400 0.376000 0.896000 -0.200000 +-0.550000 -0.155500 -0.182900 0.296000 0.920000 -0.232000 +-0.550000 -0.155500 -0.182900 0.296000 0.920000 -0.232000 +-0.452400 -0.100400 -0.060900 -0.344000 0.936000 -0.016000 +-0.452400 -0.100400 -0.060900 -0.344000 0.936000 -0.016000 +-0.450000 -0.100400 -0.065100 -0.512000 0.824000 -0.200000 +-0.450000 -0.099400 -0.060900 -0.760000 0.616000 0.160000 +-0.450000 -0.099400 -0.060900 -0.760000 0.616000 0.160000 +-0.450000 -0.512800 -0.060900 0.208000 -0.760000 0.608000 +-0.450000 -0.512800 -0.060900 0.208000 -0.760000 0.608000 +-0.478800 -0.552300 -0.060900 0.704000 -0.592000 0.376000 +-0.450000 -0.549200 -0.121900 -0.080000 -0.800000 0.584000 +-0.452200 -0.552300 -0.121900 0.864000 0.184000 0.464000 +-0.450000 -0.552300 -0.127200 0.616000 -0.144000 0.768000 +-0.450000 -0.549200 -0.121900 -0.080000 -0.800000 0.584000 +-0.440600 -0.552300 -0.121900 -0.264000 -0.768000 0.568000 +-0.450000 -0.512800 -0.060900 0.208000 -0.760000 0.608000 +-0.400000 -0.552300 -0.100200 0.624000 -0.512000 0.584000 +-0.400000 -0.527700 -0.060900 0.080000 -0.768000 0.624000 +-0.393200 -0.552300 -0.121900 0.872000 -0.352000 0.320000 +-0.380200 -0.502100 -0.060900 0.648000 -0.616000 0.432000 +-0.350000 -0.503000 -0.121900 0.232000 -0.880000 0.400000 +-0.350000 -0.502100 -0.119400 0.240000 -0.864000 0.424000 +-0.380200 -0.502100 -0.060900 0.648000 -0.616000 0.432000 +-0.350000 -0.453900 -0.060900 0.248000 -0.624000 0.728000 +-0.350000 -0.453900 -0.060900 0.248000 -0.624000 0.728000 +-0.450000 -0.602500 -0.084100 -0.232000 -0.736000 0.624000 +-0.450000 -0.602500 -0.084100 -0.232000 -0.736000 0.624000 +-0.450000 -0.558900 -0.121900 0.808000 0.320000 0.488000 +-0.410500 -0.602500 -0.121900 0.456000 -0.632000 0.616000 +-0.450000 -0.552300 -0.127200 0.616000 -0.144000 0.768000 +-0.400000 -0.602500 -0.131300 0.560000 -0.576000 0.584000 +-0.440600 -0.552300 -0.121900 -0.264000 -0.768000 0.568000 +-0.400000 -0.588000 -0.121900 0.672000 -0.144000 0.720000 +-0.400000 -0.552300 -0.100200 0.624000 -0.512000 0.584000 +-0.393200 -0.552300 -0.121900 0.872000 -0.352000 0.320000 +-0.400000 -0.588000 -0.121900 0.672000 -0.144000 0.720000 +-0.379200 -0.552300 -0.182900 0.864000 -0.416000 0.264000 +-0.400000 -0.602500 -0.131300 0.560000 -0.576000 0.584000 +-0.386500 -0.602500 -0.182900 0.376000 -0.032000 0.920000 +-0.379200 -0.552300 -0.182900 0.864000 -0.416000 0.264000 +-0.371400 -0.602500 -0.243900 0.928000 0.016000 0.352000 +-0.363900 -0.552300 -0.243900 0.816000 -0.480000 0.304000 +-0.379200 -0.552300 -0.182900 0.864000 -0.416000 0.264000 +-0.350000 -0.535600 -0.243900 0.360000 -0.840000 0.384000 +-0.350000 -0.518400 -0.182900 -0.088000 -0.928000 0.360000 +-0.379200 -0.552300 -0.182900 0.864000 -0.416000 0.264000 +-0.350000 -0.503000 -0.121900 0.232000 -0.880000 0.400000 +-0.393200 -0.552300 -0.121900 0.872000 -0.352000 0.320000 +-0.393200 -0.552300 -0.121900 0.872000 -0.352000 0.320000 +-0.350000 0.148000 -0.060900 -0.504000 0.552000 0.656000 +-0.350000 0.148000 -0.060900 -0.504000 0.552000 0.656000 +-0.361800 0.100400 -0.060900 -0.920000 0.112000 -0.352000 +-0.350000 0.100400 -0.076700 -0.736000 0.256000 -0.616000 +-0.358600 0.050200 -0.060900 -0.920000 0.168000 -0.328000 +-0.350000 0.050200 -0.078800 -0.832000 0.272000 -0.472000 +-0.350000 0.100400 -0.076700 -0.736000 0.256000 -0.616000 +-0.335400 0.050200 -0.121900 -0.752000 0.472000 -0.456000 +-0.317300 0.100400 -0.121900 -0.712000 0.264000 -0.640000 +-0.317300 0.100400 -0.121900 -0.712000 0.264000 -0.640000 +-0.377800 0.000000 -0.060900 -0.864000 0.424000 -0.248000 +-0.377800 0.000000 -0.060900 -0.864000 0.424000 -0.248000 +-0.400000 -0.037800 -0.060900 -0.728000 0.664000 0.152000 +-0.372200 0.000000 -0.121900 -0.848000 0.480000 -0.200000 +-0.400000 -0.050200 -0.118700 -0.832000 0.528000 -0.160000 +-0.399400 -0.050200 -0.121900 -0.760000 0.504000 -0.392000 +-0.400000 -0.050900 -0.121900 -0.736000 0.536000 -0.408000 +-0.400000 -0.050900 -0.121900 -0.736000 0.536000 -0.408000 +-0.350000 0.301200 -0.064600 -0.624000 0.064000 -0.768000 +-0.350000 0.301200 -0.064600 -0.624000 0.064000 -0.768000 +-0.300000 0.301200 -0.089300 -0.344000 0.056000 -0.936000 +-0.350000 0.251000 -0.067500 -0.624000 0.048000 -0.768000 +-0.300000 0.251000 -0.090000 -0.368000 0.088000 -0.920000 +-0.350000 0.200800 -0.076700 -0.368000 -0.104000 -0.920000 +-0.300000 0.200800 -0.077300 -0.504000 0.240000 -0.824000 +-0.350000 0.153200 -0.060900 -0.608000 -0.784000 0.016000 +-0.300000 0.150600 -0.105900 -0.768000 0.536000 -0.320000 +-0.346000 0.150600 -0.060900 -0.768000 -0.144000 0.616000 +-0.346000 0.150600 -0.060900 -0.768000 -0.144000 0.616000 +-0.300000 0.401700 -0.066400 -0.448000 0.440000 -0.768000 +-0.300000 0.401700 -0.066400 -0.448000 0.440000 -0.768000 +-0.250000 0.401700 -0.091800 -0.416000 0.456000 -0.776000 +-0.300000 0.351500 -0.083400 -0.432000 0.176000 -0.880000 +-0.250000 0.351500 -0.107800 -0.464000 0.176000 -0.864000 +-0.300000 0.301200 -0.089300 -0.344000 0.056000 -0.936000 +-0.250000 0.301200 -0.116200 -0.672000 0.120000 -0.720000 +-0.300000 0.251000 -0.090000 -0.368000 0.088000 -0.920000 +-0.250000 0.268200 -0.121900 -0.464000 0.088000 -0.872000 +-0.254200 0.251000 -0.121900 -0.384000 0.088000 -0.912000 +-0.300000 0.251000 -0.090000 -0.368000 0.088000 -0.920000 +-0.263400 0.200800 -0.121900 -0.480000 0.216000 -0.840000 +-0.300000 0.200800 -0.077300 -0.504000 0.240000 -0.824000 +-0.295300 0.150600 -0.121900 -0.728000 0.520000 -0.432000 +-0.300000 0.150600 -0.105900 -0.768000 0.536000 -0.320000 +-0.300000 0.144000 -0.121900 -0.728000 0.496000 -0.456000 +-0.300000 0.144000 -0.121900 -0.728000 0.496000 -0.456000 +-0.250000 0.401700 -0.091800 -0.416000 0.456000 -0.776000 +-0.250000 0.401700 -0.091800 -0.416000 0.456000 -0.776000 +-0.208300 0.401700 -0.121900 -0.432000 0.432000 -0.784000 +-0.250000 0.351500 -0.107800 -0.464000 0.176000 -0.864000 +-0.233300 0.351500 -0.121900 -0.616000 0.184000 -0.752000 +-0.250000 0.301200 -0.116200 -0.672000 0.120000 -0.720000 +-0.245300 0.301200 -0.121900 -0.680000 0.120000 -0.720000 +-0.250000 0.268200 -0.121900 -0.464000 0.088000 -0.872000 +-0.250000 0.268200 -0.121900 -0.464000 0.088000 -0.872000 +-0.104300 -0.100400 -0.060900 0.528000 0.416000 0.728000 +-0.104300 -0.100400 -0.060900 0.528000 0.416000 0.728000 +-0.100000 -0.100400 -0.064700 0.496000 0.416000 0.752000 +-0.100000 -0.105500 -0.060900 0.480000 0.464000 0.736000 +-0.050000 -0.100400 -0.073900 0.136000 0.480000 0.864000 +-0.050000 -0.119400 -0.060900 0.168000 0.528000 0.824000 +0.000000 -0.100400 -0.085100 0.096000 0.456000 0.880000 +0.000000 -0.136800 -0.060900 0.088000 0.520000 0.840000 +0.050000 -0.100400 -0.083400 0.000000 0.440000 0.888000 +0.050000 -0.140200 -0.060900 0.152000 0.504000 0.848000 +0.100000 -0.100400 -0.084200 0.032000 0.360000 0.928000 +0.076800 -0.150600 -0.060900 0.208000 0.432000 0.872000 +0.100000 -0.150600 -0.068400 0.184000 0.416000 0.888000 +0.100000 -0.170000 -0.060900 0.256000 0.296000 0.912000 +0.100000 -0.170000 -0.060900 0.256000 0.296000 0.912000 +-0.133200 -0.451900 -0.060900 0.584000 -0.656000 0.464000 +-0.133200 -0.451900 -0.060900 0.584000 -0.656000 0.464000 +-0.100000 -0.415900 -0.060900 0.680000 -0.544000 0.480000 +-0.100000 -0.451900 -0.117700 0.624000 -0.664000 0.392000 +-0.100000 -0.451900 -0.117700 0.624000 -0.664000 0.392000 +-0.150000 -0.502100 -0.111600 0.592000 -0.752000 0.280000 +-0.150000 -0.502100 -0.111600 0.592000 -0.752000 0.280000 +-0.146100 -0.502100 -0.121900 0.616000 -0.744000 0.232000 +-0.150000 -0.505100 -0.121900 0.584000 -0.768000 0.240000 +-0.141200 -0.502100 -0.182900 0.696000 -0.688000 0.184000 +-0.150000 -0.510100 -0.182900 0.616000 -0.760000 0.168000 +-0.125700 -0.502100 -0.243900 0.664000 -0.408000 0.624000 +-0.150000 -0.530700 -0.243900 0.632000 -0.664000 0.392000 +-0.150000 -0.530700 -0.243900 0.632000 -0.664000 0.392000 +-0.078700 0.200800 -0.060900 0.568000 -0.416000 0.704000 +-0.078700 0.200800 -0.060900 0.568000 -0.416000 0.704000 +-0.050000 0.236000 -0.060900 0.536000 -0.496000 0.672000 +-0.050000 0.200800 -0.090500 0.520000 -0.520000 0.672000 +-0.050000 0.200800 -0.090500 0.520000 -0.520000 0.672000 +-0.100000 0.100400 -0.099400 0.760000 -0.264000 0.584000 +-0.100000 0.100400 -0.099400 0.760000 -0.264000 0.584000 +-0.089100 0.100400 -0.121900 0.816000 -0.232000 0.520000 +-0.100000 0.054100 -0.121900 0.816000 -0.176000 0.544000 +-0.100000 0.054100 -0.121900 0.816000 -0.176000 0.544000 +-0.050000 -0.370100 -0.060900 0.592000 -0.672000 0.424000 +-0.050000 -0.370100 -0.060900 0.592000 -0.672000 0.424000 +-0.087700 -0.401700 -0.060900 0.608000 -0.600000 0.504000 +-0.050000 -0.398200 -0.121900 0.592000 -0.704000 0.368000 +-0.054100 -0.401700 -0.121900 0.656000 -0.688000 0.280000 +-0.050000 -0.389600 -0.182900 0.656000 -0.736000 -0.128000 +-0.061900 -0.401700 -0.182900 0.744000 -0.648000 -0.120000 +-0.050000 -0.380500 -0.243900 0.664000 -0.736000 -0.104000 +-0.071000 -0.401700 -0.243900 0.856000 -0.496000 -0.072000 +-0.050000 -0.374600 -0.304800 0.584000 -0.672000 -0.448000 +-0.073900 -0.401700 -0.304800 0.784000 -0.304000 -0.528000 +-0.050000 -0.351500 -0.336900 0.024000 -0.576000 -0.808000 +-0.100000 -0.401700 -0.330800 0.576000 -0.152000 -0.792000 +-0.100000 -0.351500 -0.338800 0.024000 -0.312000 -0.944000 +-0.150000 -0.401700 -0.364300 0.552000 0.080000 -0.824000 +-0.150000 -0.351500 -0.350300 0.512000 0.192000 -0.832000 +-0.100000 -0.351500 -0.338800 0.024000 -0.312000 -0.944000 +-0.150000 -0.301200 -0.318500 -0.024000 0.504000 -0.856000 +-0.100000 -0.301200 -0.349000 -0.368000 0.264000 -0.888000 +-0.150000 -0.286300 -0.304800 -0.184000 0.480000 -0.848000 +-0.100000 -0.251000 -0.333700 -0.512000 0.248000 -0.816000 +-0.123600 -0.251000 -0.304800 -0.536000 0.288000 -0.784000 +-0.100000 -0.200800 -0.311700 -0.496000 0.128000 -0.856000 +-0.108400 -0.200800 -0.304800 -0.496000 -0.048000 -0.856000 +-0.123600 -0.251000 -0.304800 -0.536000 0.288000 -0.784000 +-0.150000 -0.200800 -0.284500 0.024000 -0.216000 -0.968000 +-0.150000 -0.251000 -0.289400 -0.264000 0.272000 -0.920000 +-0.196100 -0.200800 -0.304800 0.360000 -0.200000 -0.904000 +-0.195100 -0.251000 -0.304800 0.376000 0.112000 -0.912000 +-0.150000 -0.251000 -0.289400 -0.264000 0.272000 -0.920000 +-0.150000 -0.286300 -0.304800 -0.184000 0.480000 -0.848000 +-0.123600 -0.251000 -0.304800 -0.536000 0.288000 -0.784000 +-0.123600 -0.251000 -0.304800 -0.536000 0.288000 -0.784000 +0.000000 0.393800 -0.060900 0.224000 0.176000 0.952000 +0.000000 0.393800 -0.060900 0.224000 0.176000 0.952000 +-0.005200 0.401700 -0.060900 0.264000 0.168000 0.944000 +0.000000 0.401700 -0.062800 0.256000 0.176000 0.944000 +0.000000 0.401700 -0.062800 0.256000 0.176000 0.944000 +0.000000 0.493800 -0.121900 0.128000 0.960000 -0.232000 +0.000000 0.493800 -0.121900 0.128000 0.960000 -0.232000 +0.000000 0.451900 -0.081100 0.280000 0.456000 0.832000 +0.050000 0.485400 -0.121900 -0.032000 0.904000 -0.408000 +0.050000 0.451900 -0.077800 0.016000 0.408000 0.912000 +0.100000 0.494400 -0.121900 -0.184000 0.952000 -0.216000 +0.100000 0.451900 -0.066700 -0.192000 0.072000 0.976000 +0.138500 0.502100 -0.121900 -0.184000 0.952000 -0.216000 +0.121900 0.451900 -0.060900 -0.112000 0.472000 0.872000 +0.150000 0.502100 -0.119700 0.016000 0.656000 0.752000 +0.150000 0.456100 -0.060900 0.048000 0.664000 0.736000 +0.150000 0.456100 -0.060900 0.048000 0.664000 0.736000 +0.150000 0.503100 -0.121900 0.272000 0.456000 -0.840000 +0.150000 0.503100 -0.121900 0.272000 0.456000 -0.840000 +0.150000 0.502100 -0.119700 0.016000 0.656000 0.752000 +0.138500 0.502100 -0.121900 -0.184000 0.952000 -0.216000 +0.138500 0.502100 -0.121900 -0.184000 0.952000 -0.216000 +0.150000 0.409600 -0.060900 -0.208000 -0.072000 0.968000 +0.150000 0.409600 -0.060900 -0.208000 -0.072000 0.968000 +0.151400 0.401700 -0.060900 -0.480000 -0.416000 0.760000 +0.150000 0.401700 -0.062100 -0.392000 -0.400000 0.816000 +0.150000 0.401700 -0.062100 -0.392000 -0.400000 0.816000 +0.150000 -0.251000 -0.118100 0.224000 -0.792000 0.560000 +0.150000 -0.251000 -0.118100 0.224000 -0.792000 0.560000 +0.161400 -0.251000 -0.121900 0.152000 -0.792000 0.576000 +0.150000 -0.253200 -0.121900 0.192000 -0.808000 0.552000 +0.150000 -0.253200 -0.121900 0.192000 -0.808000 0.552000 +0.250000 0.432000 -0.060900 0.224000 0.624000 0.736000 +0.250000 0.432000 -0.060900 0.224000 0.624000 0.736000 +0.203100 0.451900 -0.060900 0.264000 0.672000 0.680000 +0.250000 0.451900 -0.094000 0.248000 0.784000 0.552000 +0.250000 0.451900 -0.094000 0.248000 0.784000 0.552000 +0.200000 0.352900 -0.060900 -0.368000 -0.496000 0.776000 +0.200000 0.352900 -0.060900 -0.368000 -0.496000 0.776000 +0.201200 0.351500 -0.060900 -0.488000 -0.576000 0.648000 +0.200000 0.351500 -0.062100 -0.312000 -0.640000 0.696000 +0.200000 0.351500 -0.062100 -0.312000 -0.640000 0.696000 +0.200000 -0.041200 -0.121900 0.160000 0.488000 0.856000 +0.200000 -0.041200 -0.121900 0.160000 0.488000 0.856000 +0.222300 -0.050200 -0.121900 0.200000 0.432000 0.872000 +0.200000 -0.050200 -0.116900 0.136000 0.368000 0.912000 +0.200000 -0.050200 -0.116900 0.136000 0.368000 0.912000 +0.300000 0.451900 -0.106900 0.184000 0.864000 0.456000 +0.300000 0.451900 -0.106900 0.184000 0.864000 0.456000 +0.300000 0.458100 -0.121900 0.224000 0.952000 -0.176000 +0.323400 0.451900 -0.121900 0.248000 0.944000 -0.200000 +0.300000 0.451900 -0.131100 0.200000 0.712000 -0.664000 +0.300000 0.451900 -0.131100 0.200000 0.712000 -0.664000 +0.366500 0.200800 -0.121900 -0.760000 -0.624000 0.168000 +0.366500 0.200800 -0.121900 -0.760000 -0.624000 0.168000 +0.400000 0.200800 -0.077800 -0.600000 -0.432000 0.664000 +0.400000 0.152400 -0.121900 -0.688000 -0.712000 -0.048000 +0.400000 0.152400 -0.121900 -0.688000 -0.712000 -0.048000 +0.400000 0.072600 -0.121900 -0.632000 0.256000 0.720000 +0.400000 0.072600 -0.121900 -0.632000 0.256000 0.720000 +0.400000 0.050200 -0.114800 -0.552000 0.256000 0.784000 +0.393200 0.050200 -0.121900 -0.648000 0.352000 0.664000 +0.393200 0.050200 -0.121900 -0.648000 0.352000 0.664000 +0.450000 -0.100400 -0.078400 -0.088000 0.200000 0.968000 +0.450000 -0.100400 -0.078400 -0.088000 0.200000 0.968000 +0.400000 -0.100400 -0.080400 -0.024000 0.176000 0.976000 +0.450000 -0.150600 -0.064700 -0.192000 0.128000 0.968000 +0.400000 -0.150600 -0.068400 -0.344000 -0.312000 0.880000 +0.450000 -0.200800 -0.072200 -0.256000 -0.536000 0.800000 +0.400000 -0.200800 -0.119100 -0.200000 -0.688000 0.688000 +0.450000 -0.227100 -0.121900 -0.296000 -0.712000 0.624000 +0.400000 -0.203000 -0.121900 -0.184000 -0.672000 0.712000 +0.450000 -0.251000 -0.179900 -0.288000 -0.680000 0.664000 +0.400000 -0.249800 -0.182900 0.472000 -0.752000 0.448000 +0.415700 -0.251000 -0.182900 -0.088000 -0.872000 0.480000 +0.400000 -0.249400 -0.243900 0.760000 -0.472000 -0.424000 +0.450000 -0.251000 -0.203800 -0.216000 -0.960000 -0.144000 +0.450000 -0.248400 -0.243900 -0.224000 -0.888000 -0.384000 +0.459300 -0.251000 -0.243900 -0.280000 -0.864000 -0.400000 +0.459300 -0.251000 -0.243900 -0.280000 -0.864000 -0.400000 +0.450000 0.163500 -0.060900 -0.600000 -0.504000 0.608000 +0.450000 0.163500 -0.060900 -0.600000 -0.504000 0.608000 +0.460500 0.150600 -0.060900 -0.624000 -0.512000 0.584000 +0.450000 0.150600 -0.075000 -0.616000 -0.488000 0.608000 +0.450000 0.150600 -0.075000 -0.616000 -0.488000 0.608000 +0.504600 0.100400 -0.060900 -0.704000 -0.248000 0.656000 +0.504600 0.100400 -0.060900 -0.704000 -0.248000 0.656000 +0.500000 0.067400 -0.060900 -0.592000 0.120000 0.792000 +0.500000 0.100400 -0.067100 -0.632000 -0.296000 0.704000 +0.500000 0.100400 -0.067100 -0.632000 -0.296000 0.704000 +0.550000 -0.159500 -0.060900 0.248000 0.472000 0.840000 +0.550000 -0.159500 -0.060900 0.248000 0.472000 0.840000 +0.530700 -0.150600 -0.060900 0.208000 0.504000 0.832000 +0.550000 -0.150600 -0.067100 0.240000 0.480000 0.840000 +0.550000 -0.150600 -0.067100 0.240000 0.480000 0.840000 +0.546800 -0.351500 -0.121900 -0.560000 -0.304000 0.760000 +0.546800 -0.351500 -0.121900 -0.560000 -0.304000 0.760000 +0.550000 -0.317100 -0.121900 -0.368000 0.064000 0.920000 +0.550000 -0.351500 -0.118900 -0.368000 0.056000 0.920000 +0.558500 -0.351500 -0.121900 0.208000 -0.648000 0.728000 +0.550000 -0.353000 -0.121900 -0.032000 -0.832000 0.536000 +0.550000 -0.351500 -0.118900 -0.368000 0.056000 0.920000 +0.546800 -0.351500 -0.121900 -0.560000 -0.304000 0.760000 +0.550000 -0.353000 -0.121900 -0.032000 -0.832000 0.536000 +0.500000 -0.351500 -0.156800 -0.392000 -0.248000 0.880000 +0.550000 -0.389500 -0.182900 -0.304000 -0.784000 0.528000 +0.500000 -0.372900 -0.182900 -0.184000 -0.776000 0.592000 +0.550000 -0.401700 -0.218900 -0.128000 -0.904000 0.392000 +0.500000 -0.400600 -0.243900 0.024000 -0.920000 0.384000 +0.503900 -0.401700 -0.243900 -0.232000 -0.936000 0.256000 +0.500000 -0.400200 -0.304800 -0.176000 -0.672000 -0.712000 +0.502600 -0.401700 -0.304800 -0.320000 -0.840000 -0.416000 +0.500000 -0.351500 -0.354900 -0.384000 -0.472000 -0.784000 +0.550000 -0.401700 -0.333700 -0.144000 -0.688000 -0.704000 +0.550000 -0.351500 -0.364500 0.120000 -0.104000 -0.984000 +0.500000 -0.351500 -0.354900 -0.384000 -0.472000 -0.784000 +0.550000 -0.316300 -0.304800 -0.472000 0.688000 -0.536000 +0.500000 -0.333600 -0.304800 -0.408000 0.824000 -0.376000 +0.550000 -0.301200 -0.279200 -0.712000 0.120000 -0.680000 +0.500000 -0.310500 -0.243900 -0.600000 0.776000 -0.152000 +0.513800 -0.301200 -0.243900 -0.728000 0.592000 -0.328000 +0.500000 -0.316400 -0.182900 -0.704000 0.472000 0.520000 +0.511800 -0.301200 -0.182900 -0.912000 0.352000 0.176000 +0.500000 -0.351500 -0.156800 -0.392000 -0.248000 0.880000 +0.550000 -0.301200 -0.123600 -0.624000 -0.440000 0.632000 +0.546800 -0.351500 -0.121900 -0.560000 -0.304000 0.760000 +0.550000 -0.317100 -0.121900 -0.368000 0.064000 0.920000 +0.550000 -0.317100 -0.121900 -0.368000 0.064000 0.920000 +0.550000 -0.242100 -0.060900 -0.400000 -0.536000 0.736000 +0.550000 -0.242100 -0.060900 -0.400000 -0.536000 0.736000 +0.562800 -0.251000 -0.060900 -0.368000 -0.568000 0.720000 +0.550000 -0.251000 -0.069700 -0.416000 -0.584000 0.688000 +0.550000 -0.251000 -0.069700 -0.416000 -0.584000 0.688000 +0.552600 -0.301200 -0.121900 -0.368000 -0.384000 0.840000 +0.552600 -0.301200 -0.121900 -0.368000 -0.384000 0.840000 +0.600000 -0.301200 -0.098800 -0.176000 -0.576000 0.792000 +0.600000 -0.333000 -0.121900 0.024000 -0.312000 0.944000 +0.650000 -0.301200 -0.100200 0.264000 -0.568000 0.768000 +0.650000 -0.327200 -0.121900 -0.280000 -0.536000 0.792000 +0.700000 -0.301200 -0.068800 0.336000 0.392000 0.848000 +0.679500 -0.351500 -0.121900 -0.424000 -0.464000 0.768000 +0.700000 -0.351500 -0.108700 -0.352000 -0.464000 0.808000 +0.700000 -0.372000 -0.121900 -0.360000 -0.440000 0.816000 +0.750000 -0.351500 -0.097900 0.640000 0.048000 0.760000 +0.737900 -0.401700 -0.121900 -0.352000 -0.448000 0.816000 +0.750000 -0.401700 -0.115900 -0.264000 -0.344000 0.896000 +0.750000 -0.411100 -0.121900 -0.304000 -0.456000 0.824000 +0.800000 -0.401700 -0.115500 0.392000 0.184000 0.896000 +0.800000 -0.418600 -0.121900 0.304000 -0.320000 0.888000 +0.750000 -0.411100 -0.121900 -0.304000 -0.456000 0.824000 +0.800000 -0.451900 -0.135400 0.168000 -0.384000 0.904000 +0.750000 -0.451900 -0.153800 -0.384000 -0.528000 0.752000 +0.800000 -0.502100 -0.171200 -0.360000 -0.648000 0.664000 +0.750000 -0.479900 -0.182900 -0.456000 -0.632000 0.616000 +0.783200 -0.502100 -0.182900 -0.448000 -0.720000 0.512000 +0.750000 -0.502100 -0.236900 -0.448000 -0.776000 0.432000 +0.800000 -0.511100 -0.182900 -0.376000 -0.744000 0.544000 +0.750000 -0.505200 -0.243900 -0.480000 -0.856000 0.152000 +0.800000 -0.519900 -0.243900 -0.400000 -0.904000 -0.112000 +0.750000 -0.502100 -0.254300 -0.448000 -0.832000 -0.312000 +0.800000 -0.502100 -0.293400 -0.120000 -0.840000 -0.520000 +0.750000 -0.487000 -0.304800 -0.104000 -0.744000 -0.656000 +0.800000 -0.493800 -0.304800 0.032000 -0.688000 -0.720000 +0.750000 -0.451900 -0.330900 0.152000 -0.080000 -0.984000 +0.800000 -0.451900 -0.330300 0.328000 0.200000 -0.920000 +0.750000 -0.401700 -0.321600 0.336000 0.000000 -0.936000 +0.800000 -0.418300 -0.304800 0.408000 0.496000 -0.760000 +0.779200 -0.401700 -0.304800 0.400000 0.336000 -0.848000 +0.800000 -0.401700 -0.291400 0.440000 0.456000 -0.760000 +0.754800 -0.351500 -0.304800 0.424000 0.136000 -0.888000 +0.800000 -0.351500 -0.277300 0.568000 0.408000 -0.704000 +0.750000 -0.334300 -0.304800 0.512000 0.112000 -0.840000 +0.800000 -0.328800 -0.243900 0.640000 0.656000 -0.384000 +0.750000 -0.301200 -0.299800 0.512000 0.144000 -0.840000 +0.780500 -0.301200 -0.243900 0.848000 0.504000 -0.128000 +0.750000 -0.251000 -0.256700 0.824000 0.520000 -0.208000 +0.752500 -0.251000 -0.243900 0.840000 0.528000 -0.096000 +0.750000 -0.247000 -0.243900 0.832000 0.536000 -0.096000 +0.750000 -0.251000 -0.218200 0.840000 0.520000 0.096000 +0.717800 -0.200800 -0.243900 0.824000 0.560000 -0.064000 +0.746300 -0.251000 -0.182900 0.848000 0.496000 0.152000 +0.713600 -0.200800 -0.182900 0.824000 0.512000 0.224000 +0.719200 -0.251000 -0.121900 0.760000 0.456000 0.440000 +0.700000 -0.200800 -0.144600 0.696000 0.528000 0.480000 +0.700000 -0.217500 -0.121900 0.616000 0.552000 0.544000 +0.677400 -0.200800 -0.121900 0.528000 0.512000 0.672000 +0.700000 -0.200800 -0.144600 0.696000 0.528000 0.480000 +0.652900 -0.150600 -0.121900 0.752000 0.456000 0.464000 +0.700000 -0.178500 -0.182900 0.792000 0.568000 0.200000 +0.675300 -0.150600 -0.182900 0.768000 0.552000 0.296000 +0.700000 -0.175300 -0.243900 0.752000 0.600000 -0.240000 +0.674200 -0.150600 -0.243900 0.696000 0.600000 -0.384000 +0.674200 -0.150600 -0.243900 0.696000 0.600000 -0.384000 +0.600000 -0.272000 -0.060900 -0.264000 -0.632000 0.720000 +0.600000 -0.272000 -0.060900 -0.264000 -0.632000 0.720000 +0.600000 -0.301200 -0.098800 -0.176000 -0.576000 0.792000 +0.650000 -0.258100 -0.060900 0.392000 -0.456000 0.792000 +0.650000 -0.301200 -0.100200 0.264000 -0.568000 0.768000 +0.657600 -0.251000 -0.060900 0.456000 -0.072000 0.880000 +0.700000 -0.301200 -0.068800 0.336000 0.392000 0.848000 +0.700000 -0.251000 -0.086700 0.608000 0.464000 0.632000 +0.700000 -0.251000 -0.086700 0.608000 0.464000 0.632000 +0.650000 0.350500 -0.060900 0.712000 0.536000 -0.440000 +0.650000 0.350500 -0.060900 0.712000 0.536000 -0.440000 +0.650000 0.301200 -0.100800 0.528000 0.504000 -0.672000 +0.680100 0.301200 -0.060900 0.752000 0.544000 -0.368000 +0.680100 0.301200 -0.060900 0.752000 0.544000 -0.368000 +0.700000 0.251000 -0.093200 0.552000 0.600000 -0.568000 +0.700000 0.251000 -0.093200 0.552000 0.600000 -0.568000 +0.673000 0.251000 -0.121900 0.568000 0.576000 -0.584000 +0.700000 0.229200 -0.121900 0.528000 0.656000 -0.528000 +0.650000 0.251000 -0.154700 0.488000 0.640000 -0.584000 +0.700000 0.200800 -0.171600 0.480000 0.608000 -0.616000 +0.650000 0.227800 -0.182900 0.368000 0.576000 -0.720000 +0.687200 0.200800 -0.182900 0.432000 0.544000 -0.712000 +0.700000 0.200800 -0.171600 0.480000 0.608000 -0.616000 +0.700000 0.190400 -0.182900 0.432000 0.560000 -0.696000 +0.700000 0.190400 -0.182900 0.432000 0.560000 -0.696000 +0.650000 -0.200800 -0.092600 0.656000 0.384000 0.640000 +0.650000 -0.200800 -0.092600 0.656000 0.384000 0.640000 +0.650000 -0.150600 -0.116200 0.720000 0.480000 0.488000 +0.677400 -0.200800 -0.121900 0.528000 0.512000 0.672000 +0.652900 -0.150600 -0.121900 0.752000 0.456000 0.464000 +0.652900 -0.150600 -0.121900 0.752000 0.456000 0.464000 +0.734900 0.200800 -0.121900 0.552000 0.608000 -0.552000 +0.734900 0.200800 -0.121900 0.552000 0.608000 -0.552000 +0.750000 0.186400 -0.121900 0.504000 0.648000 -0.560000 +0.750000 0.200800 -0.104400 0.480000 0.680000 -0.544000 +0.750000 0.200800 -0.104400 0.480000 0.680000 -0.544000 +0.750000 -0.351500 -0.097900 0.640000 0.048000 0.760000 +0.750000 -0.351500 -0.097900 0.640000 0.048000 0.760000 +0.700000 -0.351500 -0.108700 -0.352000 -0.464000 0.808000 +0.750000 -0.301200 -0.116500 0.704000 0.400000 0.568000 +0.700000 -0.301200 -0.068800 0.336000 0.392000 0.848000 +0.700000 -0.301200 -0.068800 0.336000 0.392000 0.848000 +-0.950000 -0.150600 -0.169000 -0.584000 -0.792000 0.136000 +-0.950000 -0.150600 -0.169000 -0.584000 -0.792000 0.136000 +-0.950000 -0.152700 -0.182900 -0.600000 -0.784000 0.144000 +-0.952800 -0.150600 -0.182900 -0.568000 -0.808000 0.136000 +-0.950000 -0.161800 -0.243900 -0.584000 -0.784000 0.176000 +-0.966700 -0.150600 -0.243900 -0.472000 -0.864000 0.152000 +-0.950000 -0.180000 -0.304800 -0.552000 -0.600000 -0.568000 +-0.989000 -0.150600 -0.304800 -0.440000 -0.624000 -0.640000 +-0.950000 -0.150600 -0.330800 -0.416000 -0.432000 -0.792000 +-0.950000 -0.150600 -0.330800 -0.416000 -0.432000 -0.792000 +-0.900000 -0.492700 -0.121900 -0.520000 0.712000 0.448000 +-0.900000 -0.492700 -0.121900 -0.520000 0.712000 0.448000 +-0.900000 -0.462200 -0.182900 0.320000 0.888000 0.304000 +-0.878700 -0.502100 -0.121900 0.408000 0.368000 0.832000 +-0.850000 -0.490700 -0.182900 0.328000 0.896000 0.288000 +-0.850000 -0.502100 -0.144600 0.400000 0.776000 0.480000 +-0.820300 -0.502100 -0.182900 0.496000 0.792000 0.344000 +-0.850000 -0.519700 -0.121900 0.200000 0.624000 0.752000 +-0.800000 -0.513200 -0.182900 -0.080000 0.880000 0.456000 +-0.800000 -0.539500 -0.121900 0.176000 0.680000 0.704000 +-0.750000 -0.503000 -0.182900 -0.200000 0.848000 0.472000 +-0.750000 -0.549900 -0.121900 0.080000 0.648000 0.752000 +-0.749300 -0.502100 -0.182900 -0.920000 -0.232000 0.288000 +-0.723300 -0.502100 -0.121900 -0.896000 -0.224000 0.368000 +-0.723300 -0.502100 -0.121900 -0.896000 -0.224000 0.368000 +-0.900000 -0.511500 -0.121900 -0.520000 -0.664000 0.528000 +-0.900000 -0.511500 -0.121900 -0.520000 -0.664000 0.528000 +-0.900000 -0.542100 -0.182900 -0.808000 -0.560000 0.136000 +-0.868200 -0.552300 -0.121900 -0.520000 -0.224000 0.816000 +-0.892400 -0.552300 -0.182900 -0.760000 -0.624000 0.176000 +-0.850000 -0.569100 -0.121900 -0.488000 -0.776000 0.384000 +-0.850000 -0.592600 -0.182900 -0.520000 -0.800000 0.264000 +-0.800000 -0.584500 -0.121900 -0.288000 -0.544000 0.776000 +-0.832500 -0.602500 -0.182900 -0.576000 -0.768000 0.272000 +-0.800000 -0.602500 -0.136500 -0.416000 -0.648000 0.632000 +-0.800000 -0.620600 -0.182900 -0.312000 -0.880000 0.336000 +-0.764000 -0.602500 -0.121900 -0.176000 -0.816000 0.544000 +-0.750000 -0.630100 -0.182900 -0.144000 -0.912000 0.360000 +-0.750000 -0.605000 -0.121900 -0.152000 -0.872000 0.456000 +-0.750000 -0.605000 -0.121900 -0.152000 -0.872000 0.456000 +-0.802000 -0.351500 -0.121900 -0.840000 -0.520000 0.096000 +-0.802000 -0.351500 -0.121900 -0.840000 -0.520000 0.096000 +-0.832400 -0.301200 -0.121900 -0.840000 -0.528000 0.048000 +-0.802200 -0.351500 -0.182900 -0.872000 -0.480000 0.016000 +-0.831100 -0.301200 -0.182900 -0.848000 -0.520000 0.016000 +-0.807300 -0.351500 -0.243900 -0.864000 -0.472000 0.152000 +-0.834700 -0.301200 -0.243900 -0.840000 -0.504000 0.184000 +-0.834700 -0.301200 -0.243900 -0.840000 -0.504000 0.184000 +-0.779100 0.150600 -0.182900 0.400000 0.664000 -0.616000 +-0.779100 0.150600 -0.182900 0.400000 0.664000 -0.616000 +-0.750000 0.132600 -0.182900 0.408000 0.656000 -0.624000 +-0.750000 0.150600 -0.159200 0.432000 0.664000 -0.600000 +-0.750000 0.150600 -0.159200 0.432000 0.664000 -0.600000 +-0.750000 -0.448400 -0.121900 -0.880000 -0.432000 0.160000 +-0.750000 -0.448400 -0.121900 -0.880000 -0.432000 0.160000 +-0.750000 -0.451900 -0.133400 -0.896000 -0.392000 0.184000 +-0.771000 -0.401700 -0.121900 -0.872000 -0.456000 0.128000 +-0.757600 -0.451900 -0.182900 -0.952000 -0.232000 0.184000 +-0.775200 -0.401700 -0.182900 -0.904000 -0.400000 0.120000 +-0.769800 -0.451900 -0.243900 -0.952000 -0.080000 0.272000 +-0.781800 -0.401700 -0.243900 -0.912000 -0.336000 0.208000 +-0.787800 -0.451900 -0.304800 -0.984000 0.136000 -0.040000 +-0.797400 -0.401700 -0.304800 -0.928000 -0.344000 0.056000 +-0.797400 -0.401700 -0.304800 -0.928000 -0.344000 0.056000 +-0.800000 -0.584500 -0.121900 -0.288000 -0.544000 0.776000 +-0.800000 -0.584500 -0.121900 -0.288000 -0.544000 0.776000 +-0.764000 -0.602500 -0.121900 -0.176000 -0.816000 0.544000 +-0.800000 -0.602500 -0.136500 -0.416000 -0.648000 0.632000 +-0.800000 -0.602500 -0.136500 -0.416000 -0.648000 0.632000 +-0.750000 0.174400 -0.121900 0.448000 0.824000 -0.336000 +-0.750000 0.174400 -0.121900 0.448000 0.824000 -0.336000 +-0.750000 0.150600 -0.159200 0.432000 0.664000 -0.600000 +-0.715000 0.150600 -0.121900 0.512000 0.744000 -0.408000 +-0.715000 0.150600 -0.121900 0.512000 0.744000 -0.408000 +-0.700900 0.100400 -0.182900 0.440000 0.608000 -0.648000 +-0.700900 0.100400 -0.182900 0.440000 0.608000 -0.648000 +-0.700000 0.099700 -0.182900 0.504000 0.560000 -0.640000 +-0.700000 0.100400 -0.182100 0.536000 0.592000 -0.592000 +-0.700000 0.100400 -0.182100 0.536000 0.592000 -0.592000 +-0.750000 -0.448400 -0.121900 -0.880000 -0.432000 0.160000 +-0.750000 -0.448400 -0.121900 -0.880000 -0.432000 0.160000 +-0.748200 -0.451900 -0.121900 -0.880000 -0.440000 0.160000 +-0.750000 -0.451900 -0.133400 -0.896000 -0.392000 0.184000 +-0.750000 -0.451900 -0.133400 -0.896000 -0.392000 0.184000 +-0.700000 0.140000 -0.121900 0.536000 0.728000 -0.408000 +-0.700000 0.140000 -0.121900 0.536000 0.728000 -0.408000 +-0.700000 0.100400 -0.182100 0.536000 0.592000 -0.592000 +-0.657700 0.100400 -0.121900 0.728000 0.576000 -0.360000 +-0.657700 0.100400 -0.121900 0.728000 0.576000 -0.360000 +-0.652800 0.050200 -0.182900 0.592000 0.536000 -0.592000 +-0.652800 0.050200 -0.182900 0.592000 0.536000 -0.592000 +-0.650000 0.045800 -0.182900 0.672000 0.432000 -0.592000 +-0.650000 0.050200 -0.178200 0.664000 0.544000 -0.504000 +-0.621400 0.000000 -0.182900 0.848000 0.280000 -0.440000 +-0.614300 0.050200 -0.121900 0.720000 0.480000 -0.480000 +-0.601900 0.000000 -0.121900 0.848000 0.208000 -0.472000 +-0.601900 0.000000 -0.121900 0.848000 0.208000 -0.472000 +-0.650000 0.089500 -0.121900 0.728000 0.552000 -0.384000 +-0.650000 0.089500 -0.121900 0.728000 0.552000 -0.384000 +-0.650000 0.050200 -0.178200 0.664000 0.544000 -0.504000 +-0.614300 0.050200 -0.121900 0.720000 0.480000 -0.480000 +-0.614300 0.050200 -0.121900 0.720000 0.480000 -0.480000 +-0.491700 -0.150600 -0.182900 -0.448000 0.848000 -0.264000 +-0.491700 -0.150600 -0.182900 -0.448000 0.848000 -0.264000 +-0.500000 -0.150600 -0.154000 -0.424000 0.880000 -0.160000 +-0.500000 -0.154300 -0.182900 -0.320000 0.920000 -0.176000 +-0.500000 -0.154300 -0.182900 -0.320000 0.920000 -0.176000 +-0.372200 0.000000 -0.121900 -0.848000 0.480000 -0.200000 +-0.372200 0.000000 -0.121900 -0.848000 0.480000 -0.200000 +-0.350000 0.000000 -0.171400 -0.688000 0.416000 -0.584000 +-0.350000 0.031200 -0.121900 -0.744000 0.552000 -0.352000 +-0.350000 0.031200 -0.121900 -0.744000 0.552000 -0.352000 +-0.350000 -0.652700 -0.168800 -0.864000 0.056000 0.488000 +-0.350000 -0.652700 -0.168800 -0.864000 0.056000 0.488000 +-0.300000 -0.652700 -0.176500 0.496000 0.568000 0.648000 +-0.350000 -0.647900 -0.182900 0.008000 0.768000 0.624000 +-0.300000 -0.647500 -0.182900 0.464000 0.632000 0.616000 +-0.350000 -0.630200 -0.243900 -0.144000 0.776000 0.600000 +-0.300000 -0.607200 -0.243900 -0.248000 0.672000 0.688000 +-0.300000 -0.647500 -0.182900 0.464000 0.632000 0.616000 +-0.286800 -0.602500 -0.243900 -0.320000 0.232000 0.912000 +-0.293900 -0.652700 -0.182900 0.576000 0.496000 0.640000 +-0.250000 -0.602500 -0.226600 0.288000 -0.512000 0.800000 +-0.250000 -0.652700 -0.232900 0.624000 0.072000 0.768000 +-0.233200 -0.602500 -0.243900 0.608000 -0.320000 0.720000 +-0.241600 -0.652700 -0.243900 0.680000 -0.216000 0.688000 +-0.250000 -0.652700 -0.232900 0.624000 0.072000 0.768000 +-0.250000 -0.679700 -0.243900 0.728000 -0.208000 0.640000 +-0.293900 -0.652700 -0.182900 0.576000 0.496000 0.640000 +-0.256000 -0.703000 -0.243900 0.696000 -0.392000 0.584000 +-0.293800 -0.703000 -0.182900 0.608000 -0.624000 0.488000 +-0.293900 -0.652700 -0.182900 0.576000 0.496000 0.640000 +-0.300000 -0.703000 -0.173800 0.616000 -0.544000 0.552000 +-0.300000 -0.652700 -0.176500 0.496000 0.568000 0.648000 +-0.350000 -0.703000 -0.180700 -0.616000 -0.504000 0.592000 +-0.350000 -0.652700 -0.168800 -0.864000 0.056000 0.488000 +-0.350000 -0.652700 -0.168800 -0.864000 0.056000 0.488000 +-0.260200 -0.552300 -0.121900 -0.560000 -0.752000 0.336000 +-0.260200 -0.552300 -0.121900 -0.560000 -0.752000 0.336000 +-0.300000 -0.516400 -0.121900 -0.256000 -0.872000 0.400000 +-0.285200 -0.552300 -0.182900 -0.616000 -0.680000 0.384000 +-0.300000 -0.538300 -0.182900 -0.584000 -0.696000 0.408000 +-0.300000 -0.552300 -0.209900 -0.624000 -0.616000 0.456000 +-0.300000 -0.552300 -0.209900 -0.624000 -0.616000 0.456000 +-0.300000 -0.647500 -0.182900 0.464000 0.632000 0.616000 +-0.300000 -0.647500 -0.182900 0.464000 0.632000 0.616000 +-0.293900 -0.652700 -0.182900 0.576000 0.496000 0.640000 +-0.300000 -0.652700 -0.176500 0.496000 0.568000 0.648000 +-0.300000 -0.652700 -0.176500 0.496000 0.568000 0.648000 +-0.200000 0.251000 -0.156200 -0.432000 0.168000 -0.880000 +-0.200000 0.251000 -0.156200 -0.432000 0.168000 -0.880000 +-0.250000 0.251000 -0.124000 -0.376000 0.088000 -0.920000 +-0.200000 0.200800 -0.161600 -0.480000 0.384000 -0.776000 +-0.250000 0.200800 -0.129700 -0.392000 0.152000 -0.904000 +-0.250000 0.200800 -0.129700 -0.392000 0.152000 -0.904000 +-0.200000 -0.534300 -0.121900 0.456000 -0.832000 0.296000 +-0.200000 -0.534300 -0.121900 0.456000 -0.832000 0.296000 +-0.235800 -0.552300 -0.121900 0.448000 -0.816000 0.336000 +-0.200000 -0.549300 -0.182900 0.504000 -0.784000 0.344000 +-0.204600 -0.552300 -0.182900 0.504000 -0.776000 0.360000 +-0.200000 -0.552300 -0.190900 0.520000 -0.768000 0.360000 +-0.200000 -0.552300 -0.190900 0.520000 -0.768000 0.360000 +-0.200000 0.401700 -0.127400 -0.400000 0.440000 -0.800000 +-0.200000 0.401700 -0.127400 -0.400000 0.440000 -0.800000 +-0.150000 0.401700 -0.148200 -0.240000 0.400000 -0.872000 +-0.200000 0.351500 -0.146000 -0.416000 0.224000 -0.872000 +-0.150000 0.351500 -0.156300 -0.024000 0.152000 -0.984000 +-0.200000 0.301200 -0.154100 -0.392000 0.112000 -0.904000 +-0.150000 0.301200 -0.169700 -0.080000 0.248000 -0.960000 +-0.150000 0.351500 -0.156300 -0.024000 0.152000 -0.984000 +-0.100000 0.301200 -0.172200 -0.168000 0.416000 -0.888000 +-0.100000 0.351500 -0.158200 0.008000 0.264000 -0.960000 +-0.150000 0.351500 -0.156300 -0.024000 0.152000 -0.984000 +-0.100000 0.401700 -0.143600 0.056000 0.120000 -0.984000 +-0.150000 0.401700 -0.148200 -0.240000 0.400000 -0.872000 +-0.100000 0.451900 -0.142300 -0.128000 0.312000 -0.936000 +-0.150000 0.451900 -0.123200 -0.344000 0.512000 -0.784000 +-0.150000 0.451900 -0.123200 -0.344000 0.512000 -0.784000 +-0.100000 0.044900 -0.121900 0.816000 0.112000 0.552000 +-0.100000 0.044900 -0.121900 0.816000 0.112000 0.552000 +-0.100700 0.050200 -0.121900 0.856000 0.048000 0.504000 +-0.100000 0.050200 -0.123300 0.696000 -0.176000 0.688000 +-0.100000 0.050200 -0.123300 0.696000 -0.176000 0.688000 +-0.100000 0.451900 -0.142300 -0.128000 0.312000 -0.936000 +-0.100000 0.451900 -0.142300 -0.128000 0.312000 -0.936000 +-0.050000 0.451900 -0.137500 0.040000 0.112000 -0.992000 +-0.100000 0.401700 -0.143600 0.056000 0.120000 -0.984000 +-0.050000 0.401700 -0.142300 0.000000 0.168000 -0.984000 +-0.100000 0.351500 -0.158200 0.008000 0.264000 -0.960000 +-0.050000 0.351500 -0.155800 -0.048000 0.328000 -0.936000 +-0.050000 0.401700 -0.142300 0.000000 0.168000 -0.984000 +0.000000 0.351500 -0.164900 -0.080000 0.368000 -0.920000 +0.000000 0.401700 -0.144600 -0.056000 0.192000 -0.976000 +0.050000 0.351500 -0.166400 0.000000 0.392000 -0.912000 +0.050000 0.401700 -0.150400 -0.088000 0.216000 -0.968000 +0.100000 0.351500 -0.169000 0.056000 0.272000 -0.952000 +0.100000 0.401700 -0.152800 -0.048000 0.168000 -0.984000 +0.150000 0.351500 -0.160600 0.144000 0.128000 -0.976000 +0.150000 0.401700 -0.154900 -0.096000 0.088000 -0.984000 +0.200000 0.351500 -0.169700 -0.320000 0.304000 -0.888000 +0.200000 0.401700 -0.169400 -0.056000 0.168000 -0.976000 +0.150000 0.401700 -0.154900 -0.096000 0.088000 -0.984000 +0.200000 0.451900 -0.151000 0.136000 0.400000 -0.896000 +0.150000 0.451900 -0.151900 0.184000 0.376000 -0.904000 +0.200000 0.484800 -0.121900 0.312000 0.872000 0.360000 +0.150000 0.502100 -0.123200 0.032000 0.424000 -0.896000 +0.153400 0.502100 -0.121900 0.448000 0.824000 -0.336000 +0.153400 0.502100 -0.121900 0.448000 0.824000 -0.336000 +-0.089600 0.000000 -0.121900 0.568000 0.512000 0.632000 +-0.089600 0.000000 -0.121900 0.568000 0.512000 0.632000 +-0.050000 0.000000 -0.158900 0.584000 0.336000 0.728000 +-0.050000 -0.024600 -0.121900 0.296000 0.656000 0.688000 +0.000000 0.000000 -0.165000 0.096000 0.640000 0.752000 +0.000000 -0.035500 -0.121900 0.072000 0.496000 0.856000 +0.050000 0.000000 -0.179700 0.216000 0.504000 0.832000 +0.050000 -0.038600 -0.121900 0.000000 0.528000 0.840000 +0.100000 0.000000 -0.179900 0.000000 0.528000 0.840000 +0.100000 -0.037100 -0.121900 -0.016000 0.544000 0.832000 +0.100000 -0.037100 -0.121900 -0.016000 0.544000 0.832000 +-0.054100 -0.401700 -0.121900 0.656000 -0.688000 0.280000 +-0.054100 -0.401700 -0.121900 0.656000 -0.688000 0.280000 +-0.098000 -0.451900 -0.121900 0.712000 -0.680000 0.120000 +-0.061900 -0.401700 -0.182900 0.744000 -0.648000 -0.120000 +-0.098100 -0.451900 -0.182900 0.736000 -0.672000 0.032000 +-0.071000 -0.401700 -0.243900 0.856000 -0.496000 -0.072000 +-0.094700 -0.451900 -0.243900 0.784000 -0.568000 0.216000 +-0.073900 -0.401700 -0.304800 0.784000 -0.304000 -0.528000 +-0.061500 -0.451900 -0.304800 0.928000 -0.352000 0.088000 +-0.100000 -0.401700 -0.330800 0.576000 -0.152000 -0.792000 +-0.100000 -0.451900 -0.336100 0.496000 -0.048000 -0.856000 +-0.150000 -0.401700 -0.364300 0.552000 0.080000 -0.824000 +-0.145700 -0.451900 -0.365800 0.464000 0.040000 -0.880000 +-0.150000 -0.417500 -0.365800 0.544000 0.056000 -0.832000 +-0.150000 -0.451900 -0.368100 0.456000 -0.056000 -0.880000 +-0.145700 -0.451900 -0.365800 0.464000 0.040000 -0.880000 +-0.150000 -0.502100 -0.367300 0.088000 -0.320000 -0.936000 +-0.147100 -0.502100 -0.365800 0.472000 -0.192000 -0.848000 +-0.150000 -0.505900 -0.365800 0.272000 -0.320000 -0.904000 +-0.150000 -0.505900 -0.365800 0.272000 -0.320000 -0.904000 +-0.050000 0.401700 -0.142300 0.000000 0.168000 -0.984000 +-0.050000 0.401700 -0.142300 0.000000 0.168000 -0.984000 +-0.050000 0.451900 -0.137500 0.040000 0.112000 -0.992000 +0.000000 0.401700 -0.144600 -0.056000 0.192000 -0.976000 +0.000000 0.451900 -0.135500 0.000000 0.160000 -0.984000 +0.050000 0.401700 -0.150400 -0.088000 0.216000 -0.968000 +0.050000 0.451900 -0.139600 -0.080000 0.232000 -0.960000 +0.100000 0.401700 -0.152800 -0.048000 0.168000 -0.984000 +0.100000 0.451900 -0.146900 -0.088000 0.224000 -0.968000 +0.150000 0.401700 -0.154900 -0.096000 0.088000 -0.984000 +0.150000 0.451900 -0.151900 0.184000 0.376000 -0.904000 +0.150000 0.451900 -0.151900 0.184000 0.376000 -0.904000 +-0.012800 0.200800 -0.121900 0.688000 -0.616000 0.376000 +-0.012800 0.200800 -0.121900 0.688000 -0.616000 0.376000 +0.000000 0.211400 -0.121900 0.496000 -0.712000 0.480000 +0.000000 0.200800 -0.169000 0.576000 -0.744000 0.320000 +0.000000 0.200800 -0.169000 0.576000 -0.744000 0.320000 +-0.050000 0.150600 -0.159500 0.712000 -0.480000 0.504000 +-0.050000 0.150600 -0.159500 0.712000 -0.480000 0.504000 +-0.033200 0.150600 -0.182900 0.832000 -0.552000 -0.016000 +-0.050000 0.116900 -0.182900 0.944000 -0.304000 0.048000 +-0.050000 0.150600 -0.210200 0.840000 -0.208000 -0.496000 +-0.050000 0.150600 -0.210200 0.840000 -0.208000 -0.496000 +-0.050000 0.047900 -0.182900 0.488000 0.480000 0.720000 +-0.050000 0.047900 -0.182900 0.488000 0.480000 0.720000 +-0.050000 0.000000 -0.158900 0.584000 0.336000 0.728000 +0.000000 0.039200 -0.182900 0.256000 0.544000 0.792000 +0.000000 0.000000 -0.165000 0.096000 0.640000 0.752000 +0.050000 0.005700 -0.182900 0.312000 0.584000 0.744000 +0.050000 0.000000 -0.179700 0.216000 0.504000 0.832000 +0.100000 0.004900 -0.182900 -0.288000 0.864000 0.400000 +0.100000 0.000000 -0.179900 0.000000 0.528000 0.840000 +0.100000 0.000000 -0.179900 0.000000 0.528000 0.840000 +0.000000 0.200800 -0.169000 0.576000 -0.744000 0.320000 +0.000000 0.200800 -0.169000 0.576000 -0.744000 0.320000 +0.008500 0.200800 -0.182900 0.416000 -0.688000 -0.584000 +0.000000 0.195100 -0.182900 0.504000 -0.656000 -0.544000 +0.000000 0.200800 -0.186400 0.272000 -0.456000 -0.840000 +0.000000 0.200800 -0.186400 0.272000 -0.456000 -0.840000 +0.050000 -0.327900 -0.182900 0.552000 -0.824000 0.048000 +0.050000 -0.327900 -0.182900 0.552000 -0.824000 0.048000 +0.003100 -0.351500 -0.182900 0.504000 -0.840000 -0.160000 +0.050000 -0.321600 -0.121900 0.584000 -0.712000 0.376000 +0.006400 -0.351500 -0.121900 0.552000 -0.776000 0.288000 +0.006400 -0.351500 -0.121900 0.552000 -0.776000 0.288000 +0.150000 0.251000 -0.128300 0.144000 -0.904000 0.392000 +0.150000 0.251000 -0.128300 0.144000 -0.904000 0.392000 +0.150000 0.284700 -0.182900 0.352000 0.368000 -0.856000 +0.194700 0.251000 -0.182900 0.496000 -0.104000 -0.856000 +0.150000 0.251000 -0.192500 0.112000 0.024000 -0.992000 +0.150000 0.224100 -0.182900 0.056000 -0.672000 -0.728000 +0.194700 0.251000 -0.182900 0.496000 -0.104000 -0.856000 +0.150000 0.251000 -0.128300 0.144000 -0.904000 0.392000 +0.150000 0.251000 -0.128300 0.144000 -0.904000 0.392000 +0.211500 -0.301200 -0.182900 -0.568000 -0.672000 0.464000 +0.211500 -0.301200 -0.182900 -0.568000 -0.672000 0.464000 +0.250000 -0.301200 -0.149400 -0.376000 -0.584000 0.712000 +0.250000 -0.319600 -0.182900 -0.280000 -0.832000 0.472000 +0.300000 -0.301200 -0.149800 -0.024000 -0.480000 0.872000 +0.300000 -0.330300 -0.182900 -0.312000 -0.696000 0.632000 +0.350000 -0.301200 -0.148100 0.392000 -0.048000 0.912000 +0.331500 -0.351500 -0.182900 -0.432000 -0.576000 0.688000 +0.350000 -0.351500 -0.171100 -0.312000 -0.512000 0.792000 +0.350000 -0.366900 -0.182900 -0.368000 -0.552000 0.736000 +0.400000 -0.351500 -0.165500 0.064000 -0.056000 0.992000 +0.400000 -0.370500 -0.182900 -0.008000 -0.616000 0.776000 +0.450000 -0.351500 -0.174300 0.040000 0.080000 0.992000 +0.450000 -0.370700 -0.182900 -0.080000 -0.520000 0.848000 +0.500000 -0.351500 -0.156800 -0.392000 -0.248000 0.880000 +0.500000 -0.372900 -0.182900 -0.184000 -0.776000 0.592000 +0.450000 -0.370700 -0.182900 -0.080000 -0.520000 0.848000 +0.500000 -0.400600 -0.243900 0.024000 -0.920000 0.384000 +0.450000 -0.401700 -0.212100 0.240000 -0.816000 0.520000 +0.496800 -0.401700 -0.243900 0.256000 -0.880000 0.376000 +0.450000 -0.418500 -0.243900 -0.152000 -0.896000 0.400000 +0.492100 -0.401700 -0.304800 0.152000 -0.576000 -0.792000 +0.450000 -0.411100 -0.304800 -0.144000 -0.808000 -0.560000 +0.450000 -0.401700 -0.316200 -0.184000 -0.360000 -0.904000 +0.428900 -0.401700 -0.304800 -0.392000 -0.464000 -0.784000 +0.450000 -0.380500 -0.304800 -0.144000 0.256000 -0.952000 +0.400000 -0.401700 -0.257800 0.112000 -0.952000 -0.280000 +0.450000 -0.351500 -0.290700 -0.176000 0.632000 -0.744000 +0.400000 -0.388800 -0.304800 0.392000 -0.800000 -0.448000 +0.437100 -0.351500 -0.304800 0.688000 0.472000 -0.536000 +0.400000 -0.351500 -0.338800 0.360000 -0.568000 -0.728000 +0.401200 -0.301200 -0.304800 0.744000 0.488000 -0.440000 +0.400000 -0.301200 -0.307300 0.704000 0.496000 -0.496000 +0.400000 -0.299100 -0.304800 0.736000 0.472000 -0.472000 +0.401200 -0.301200 -0.304800 0.744000 0.488000 -0.440000 +0.400000 -0.252300 -0.243900 0.744000 0.488000 -0.440000 +0.429200 -0.301200 -0.243900 0.816000 0.544000 -0.176000 +0.400000 -0.252800 -0.182900 0.760000 0.464000 0.440000 +0.427100 -0.301200 -0.182900 0.776000 0.464000 0.416000 +0.400000 -0.301200 -0.149800 0.528000 0.376000 0.752000 +0.450000 -0.338000 -0.182900 0.248000 0.592000 0.752000 +0.400000 -0.351500 -0.165500 0.064000 -0.056000 0.992000 +0.450000 -0.351500 -0.174300 0.040000 0.080000 0.992000 +0.450000 -0.338000 -0.182900 0.248000 0.592000 0.752000 +0.500000 -0.351500 -0.156800 -0.392000 -0.248000 0.880000 +0.500000 -0.316400 -0.182900 -0.704000 0.472000 0.520000 +0.450000 -0.338000 -0.182900 0.248000 0.592000 0.752000 +0.500000 -0.310500 -0.243900 -0.600000 0.776000 -0.152000 +0.450000 -0.327300 -0.243900 -0.064000 0.864000 -0.488000 +0.500000 -0.333600 -0.304800 -0.408000 0.824000 -0.376000 +0.450000 -0.351500 -0.290700 -0.176000 0.632000 -0.744000 +0.458900 -0.351500 -0.304800 -0.472000 0.360000 -0.792000 +0.450000 -0.380500 -0.304800 -0.144000 0.256000 -0.952000 +0.500000 -0.400200 -0.304800 -0.176000 -0.672000 -0.712000 +0.492100 -0.401700 -0.304800 0.152000 -0.576000 -0.792000 +0.500000 -0.400600 -0.243900 0.024000 -0.920000 0.384000 +0.496800 -0.401700 -0.243900 0.256000 -0.880000 0.376000 +0.496800 -0.401700 -0.243900 0.256000 -0.880000 0.376000 +0.265700 0.200800 -0.182900 -0.312000 -0.760000 -0.552000 +0.265700 0.200800 -0.182900 -0.312000 -0.760000 -0.552000 +0.300000 0.218000 -0.182900 0.768000 0.424000 -0.464000 +0.300000 0.200800 -0.174500 0.536000 -0.360000 0.752000 +0.306800 0.200800 -0.182900 0.752000 -0.400000 -0.512000 +0.300000 0.193900 -0.182900 0.520000 -0.696000 -0.480000 +0.300000 0.200800 -0.185900 0.256000 -0.192000 -0.944000 +0.265700 0.200800 -0.182900 -0.312000 -0.760000 -0.552000 +0.300000 0.218000 -0.182900 0.768000 0.424000 -0.464000 +0.300000 0.200800 -0.185900 0.256000 -0.192000 -0.944000 +0.306800 0.200800 -0.182900 0.752000 -0.400000 -0.512000 +0.306800 0.200800 -0.182900 0.752000 -0.400000 -0.512000 +0.265700 0.200800 -0.182900 -0.312000 -0.760000 -0.552000 +0.265700 0.200800 -0.182900 -0.312000 -0.760000 -0.552000 +0.300000 0.200800 -0.174500 0.536000 -0.360000 0.752000 +0.300000 0.193900 -0.182900 0.520000 -0.696000 -0.480000 +0.300000 0.193900 -0.182900 0.520000 -0.696000 -0.480000 +0.300000 0.284000 -0.182900 -0.168000 -0.184000 -0.960000 +0.300000 0.284000 -0.182900 -0.168000 -0.184000 -0.960000 +0.300000 0.251000 -0.156100 -0.368000 -0.808000 -0.448000 +0.321900 0.251000 -0.182900 -0.240000 -0.296000 -0.920000 +0.321900 0.251000 -0.182900 -0.240000 -0.296000 -0.920000 +0.307700 -0.050200 -0.121900 -0.592000 0.464000 0.648000 +0.307700 -0.050200 -0.121900 -0.592000 0.464000 0.648000 +0.300000 -0.060700 -0.121900 -0.512000 0.456000 0.720000 +0.300000 -0.050200 -0.130700 -0.504000 0.472000 0.720000 +0.300000 -0.050200 -0.130700 -0.504000 0.472000 0.720000 +0.329200 -0.200800 -0.121900 0.376000 -0.264000 0.880000 +0.329200 -0.200800 -0.121900 0.376000 -0.264000 0.880000 +0.350000 -0.182300 -0.121900 -0.032000 -0.520000 0.848000 +0.350000 -0.200800 -0.137500 0.248000 -0.232000 0.936000 +0.391400 -0.200800 -0.121900 -0.176000 -0.648000 0.736000 +0.391400 -0.200800 -0.121900 -0.176000 -0.648000 0.736000 +0.400000 0.100400 -0.150800 -0.768000 0.376000 0.512000 +0.400000 0.100400 -0.150800 -0.768000 0.376000 0.512000 +0.381500 0.100400 -0.182900 -0.896000 0.440000 -0.008000 +0.400000 0.146600 -0.182900 -0.440000 0.464000 -0.760000 +0.400000 0.100400 -0.207800 -0.424000 0.688000 -0.576000 +0.400000 0.100400 -0.207800 -0.424000 0.688000 -0.576000 +0.400000 -0.203000 -0.121900 -0.184000 -0.672000 0.712000 +0.400000 -0.203000 -0.121900 -0.184000 -0.672000 0.712000 +0.354900 -0.251000 -0.121900 0.704000 -0.304000 0.632000 +0.400000 -0.249800 -0.182900 0.472000 -0.752000 0.448000 +0.398900 -0.251000 -0.182900 0.896000 -0.160000 0.400000 +0.400000 -0.249400 -0.243900 0.760000 -0.472000 -0.424000 +0.399000 -0.251000 -0.243900 0.912000 -0.008000 -0.392000 +0.399000 -0.251000 -0.243900 0.912000 -0.008000 -0.392000 +0.400000 -0.351500 -0.165500 0.064000 -0.056000 0.992000 +0.400000 -0.351500 -0.165500 0.064000 -0.056000 0.992000 +0.350000 -0.351500 -0.171100 -0.312000 -0.512000 0.792000 +0.400000 -0.301200 -0.149800 0.528000 0.376000 0.752000 +0.350000 -0.301200 -0.148100 0.392000 -0.048000 0.912000 +0.350000 -0.301200 -0.148100 0.392000 -0.048000 0.912000 +0.450000 -0.251000 -0.179900 -0.288000 -0.680000 0.664000 +0.450000 -0.251000 -0.179900 -0.288000 -0.680000 0.664000 +0.450000 -0.255300 -0.182900 -0.208000 -0.656000 0.712000 +0.415700 -0.251000 -0.182900 -0.088000 -0.872000 0.480000 +0.450000 -0.251000 -0.203800 -0.216000 -0.960000 -0.144000 +0.450000 -0.251000 -0.203800 -0.216000 -0.960000 -0.144000 +0.500000 0.355500 -0.182900 0.400000 0.616000 -0.664000 +0.500000 0.355500 -0.182900 0.400000 0.616000 -0.664000 +0.506000 0.351500 -0.182900 0.424000 0.584000 -0.680000 +0.500000 0.393600 -0.121900 0.504000 0.744000 -0.432000 +0.550000 0.351500 -0.135900 0.456000 0.632000 -0.616000 +0.550000 0.362300 -0.121900 0.400000 0.656000 -0.632000 +0.566700 0.351500 -0.121900 0.448000 0.536000 -0.704000 +0.566700 0.351500 -0.121900 0.448000 0.536000 -0.704000 +0.550000 0.351500 -0.135900 0.456000 0.632000 -0.616000 +0.550000 0.351500 -0.135900 0.456000 0.632000 -0.616000 +0.550000 0.301200 -0.167400 0.408000 0.504000 -0.752000 +0.506000 0.351500 -0.182900 0.424000 0.584000 -0.680000 +0.526000 0.301200 -0.182900 0.408000 0.312000 -0.848000 +0.500000 0.351500 -0.187300 0.416000 0.568000 -0.696000 +0.500000 0.301200 -0.193500 0.168000 0.072000 -0.976000 +0.526000 0.301200 -0.182900 0.408000 0.312000 -0.848000 +0.500000 0.251000 -0.199400 0.072000 0.096000 -0.984000 +0.550000 0.283200 -0.182900 0.320000 0.472000 -0.816000 +0.550000 0.251000 -0.199600 0.176000 0.288000 -0.936000 +0.500000 0.251000 -0.199400 0.072000 0.096000 -0.984000 +0.550000 0.200800 -0.211100 0.016000 0.048000 -0.992000 +0.500000 0.200800 -0.200200 -0.104000 -0.048000 -0.992000 +0.550000 0.150600 -0.215400 -0.144000 0.080000 -0.984000 +0.500000 0.150600 -0.194400 -0.208000 0.240000 -0.944000 +0.550000 0.100400 -0.212600 -0.200000 0.352000 -0.904000 +0.500000 0.100400 -0.210700 0.048000 0.704000 -0.704000 +0.550000 0.067800 -0.243900 0.024000 0.672000 -0.728000 +0.500000 0.082500 -0.243900 0.216000 0.832000 -0.504000 +0.550000 0.050200 -0.258400 0.160000 0.632000 -0.752000 +0.500000 0.050200 -0.303800 0.264000 0.816000 -0.504000 +0.550000 0.015600 -0.304800 0.472000 0.712000 -0.512000 +0.500000 0.049600 -0.304800 0.264000 0.736000 -0.616000 +0.550000 0.000000 -0.335900 0.576000 0.464000 -0.664000 +0.500000 0.014000 -0.365800 0.216000 0.784000 -0.568000 +0.524100 0.000000 -0.365800 0.648000 0.312000 -0.688000 +0.500000 0.000000 -0.393700 0.528000 0.072000 -0.840000 +0.500000 -0.027200 -0.365800 0.264000 -0.576000 -0.768000 +0.524100 0.000000 -0.365800 0.648000 0.312000 -0.688000 +0.500000 -0.050200 -0.339600 -0.136000 -0.672000 -0.720000 +0.550000 0.000000 -0.335900 0.576000 0.464000 -0.664000 +0.550000 -0.050200 -0.345500 0.192000 -0.560000 -0.792000 +0.550000 -0.050200 -0.345500 0.192000 -0.560000 -0.792000 +0.526000 0.301200 -0.182900 0.408000 0.312000 -0.848000 +0.526000 0.301200 -0.182900 0.408000 0.312000 -0.848000 +0.550000 0.283200 -0.182900 0.320000 0.472000 -0.816000 +0.550000 0.301200 -0.167400 0.408000 0.504000 -0.752000 +0.550000 0.301200 -0.167400 0.408000 0.504000 -0.752000 +0.500000 -0.250100 -0.121900 -0.432000 -0.712000 0.536000 +0.500000 -0.250100 -0.121900 -0.432000 -0.712000 0.536000 +0.501100 -0.251000 -0.121900 -0.552000 -0.624000 0.544000 +0.500000 -0.251000 -0.123800 -0.544000 -0.688000 0.456000 +0.500000 -0.251000 -0.123800 -0.544000 -0.688000 0.456000 +0.608400 0.251000 -0.182900 0.328000 0.488000 -0.800000 +0.608400 0.251000 -0.182900 0.328000 0.488000 -0.800000 +0.650000 0.227800 -0.182900 0.368000 0.576000 -0.720000 +0.650000 0.251000 -0.154700 0.488000 0.640000 -0.584000 +0.650000 0.251000 -0.154700 0.488000 0.640000 -0.584000 +0.600000 -0.333000 -0.121900 0.024000 -0.312000 0.944000 +0.600000 -0.333000 -0.121900 0.024000 -0.312000 0.944000 +0.600000 -0.351500 -0.136300 0.144000 -0.792000 0.584000 +0.650000 -0.327200 -0.121900 -0.280000 -0.536000 0.792000 +0.650000 -0.351500 -0.143500 -0.280000 -0.536000 0.784000 +0.679500 -0.351500 -0.121900 -0.424000 -0.464000 0.768000 +0.650000 -0.401700 -0.175000 -0.240000 -0.688000 0.680000 +0.700000 -0.372000 -0.121900 -0.360000 -0.440000 0.816000 +0.700000 -0.401700 -0.145100 -0.400000 -0.504000 0.752000 +0.737900 -0.401700 -0.121900 -0.352000 -0.448000 0.816000 +0.700000 -0.435200 -0.182900 -0.448000 -0.712000 0.536000 +0.750000 -0.411100 -0.121900 -0.304000 -0.456000 0.824000 +0.719600 -0.451900 -0.182900 -0.568000 -0.640000 0.512000 +0.750000 -0.451900 -0.153800 -0.384000 -0.528000 0.752000 +0.750000 -0.479900 -0.182900 -0.456000 -0.632000 0.616000 +0.719600 -0.451900 -0.182900 -0.568000 -0.640000 0.512000 +0.750000 -0.502100 -0.236900 -0.448000 -0.776000 0.432000 +0.700000 -0.451900 -0.215800 -0.528000 -0.696000 0.472000 +0.744200 -0.502100 -0.243900 -0.480000 -0.864000 0.128000 +0.700000 -0.472400 -0.243900 -0.560000 -0.816000 -0.016000 +0.750000 -0.502100 -0.254300 -0.448000 -0.832000 -0.312000 +0.700000 -0.481300 -0.304800 -0.240000 -0.712000 -0.656000 +0.750000 -0.487000 -0.304800 -0.104000 -0.744000 -0.656000 +0.700000 -0.451900 -0.321600 -0.136000 -0.312000 -0.936000 +0.750000 -0.451900 -0.330900 0.152000 -0.080000 -0.984000 +0.700000 -0.401700 -0.334100 0.120000 -0.128000 -0.976000 +0.750000 -0.401700 -0.321600 0.336000 0.000000 -0.936000 +0.700000 -0.351500 -0.333900 0.344000 -0.040000 -0.936000 +0.750000 -0.351500 -0.307800 0.512000 0.128000 -0.840000 +0.700000 -0.301200 -0.354900 0.160000 -0.240000 -0.952000 +0.750000 -0.334300 -0.304800 0.512000 0.112000 -0.840000 +0.744500 -0.301200 -0.304800 0.640000 0.104000 -0.760000 +0.750000 -0.301200 -0.299800 0.512000 0.144000 -0.840000 +0.728900 -0.251000 -0.304800 0.720000 0.440000 -0.528000 +0.750000 -0.251000 -0.256700 0.824000 0.520000 -0.208000 +0.700000 -0.211400 -0.304800 0.288000 0.624000 -0.720000 +0.750000 -0.247000 -0.243900 0.832000 0.536000 -0.096000 +0.700000 -0.200800 -0.294000 0.576000 0.608000 -0.536000 +0.717800 -0.200800 -0.243900 0.824000 0.560000 -0.064000 +0.700000 -0.175300 -0.243900 0.752000 0.600000 -0.240000 +0.713600 -0.200800 -0.182900 0.824000 0.512000 0.224000 +0.700000 -0.178500 -0.182900 0.792000 0.568000 0.200000 +0.700000 -0.200800 -0.144600 0.696000 0.528000 0.480000 +0.700000 -0.200800 -0.144600 0.696000 0.528000 0.480000 +0.600000 -0.351500 -0.136300 0.144000 -0.792000 0.584000 +0.600000 -0.351500 -0.136300 0.144000 -0.792000 0.584000 +0.650000 -0.351500 -0.143500 -0.280000 -0.536000 0.784000 +0.600000 -0.392700 -0.182900 -0.184000 -0.752000 0.624000 +0.650000 -0.401700 -0.175000 -0.240000 -0.688000 0.680000 +0.628900 -0.401700 -0.182900 -0.216000 -0.760000 0.608000 +0.650000 -0.407700 -0.182900 -0.272000 -0.728000 0.624000 +0.600000 -0.401700 -0.203000 -0.208000 -0.872000 0.432000 +0.650000 -0.436800 -0.243900 -0.416000 -0.848000 0.320000 +0.600000 -0.414700 -0.243900 -0.184000 -0.936000 0.272000 +0.650000 -0.449600 -0.304800 -0.280000 -0.432000 -0.848000 +0.600000 -0.422100 -0.304800 -0.120000 -0.768000 -0.616000 +0.650000 -0.401700 -0.330300 -0.240000 -0.360000 -0.896000 +0.600000 -0.401700 -0.327900 -0.024000 -0.544000 -0.832000 +0.650000 -0.351500 -0.332000 0.016000 -0.144000 -0.984000 +0.600000 -0.351500 -0.337900 0.040000 -0.080000 -0.992000 +0.650000 -0.301200 -0.350300 0.016000 -0.440000 -0.888000 +0.600000 -0.301200 -0.352300 -0.528000 -0.312000 -0.776000 +0.600000 -0.301200 -0.352300 -0.528000 -0.312000 -0.776000 +0.650000 0.278000 -0.121900 0.448000 0.624000 -0.624000 +0.650000 0.278000 -0.121900 0.448000 0.624000 -0.624000 +0.650000 0.251000 -0.154700 0.488000 0.640000 -0.584000 +0.673000 0.251000 -0.121900 0.568000 0.576000 -0.584000 +0.673000 0.251000 -0.121900 0.568000 0.576000 -0.584000 +0.700000 -0.401700 -0.145100 -0.400000 -0.504000 0.752000 +0.700000 -0.401700 -0.145100 -0.400000 -0.504000 0.752000 +0.650000 -0.401700 -0.175000 -0.240000 -0.688000 0.680000 +0.700000 -0.435200 -0.182900 -0.448000 -0.712000 0.536000 +0.650000 -0.407700 -0.182900 -0.272000 -0.728000 0.624000 +0.700000 -0.451900 -0.215800 -0.528000 -0.696000 0.472000 +0.650000 -0.436800 -0.243900 -0.416000 -0.848000 0.320000 +0.673600 -0.451900 -0.243900 -0.480000 -0.752000 0.448000 +0.650000 -0.449600 -0.304800 -0.280000 -0.432000 -0.848000 +0.653100 -0.451900 -0.304800 -0.336000 -0.480000 -0.800000 +0.650000 -0.401700 -0.330300 -0.240000 -0.360000 -0.896000 +0.700000 -0.451900 -0.321600 -0.136000 -0.312000 -0.936000 +0.700000 -0.401700 -0.334100 0.120000 -0.128000 -0.976000 +0.650000 -0.401700 -0.330300 -0.240000 -0.360000 -0.896000 +0.700000 -0.351500 -0.333900 0.344000 -0.040000 -0.936000 +0.650000 -0.351500 -0.332000 0.016000 -0.144000 -0.984000 +0.700000 -0.301200 -0.354900 0.160000 -0.240000 -0.952000 +0.650000 -0.301200 -0.350300 0.016000 -0.440000 -0.888000 +0.650000 -0.301200 -0.350300 0.016000 -0.440000 -0.888000 +0.719200 -0.251000 -0.121900 0.760000 0.456000 0.440000 +0.719200 -0.251000 -0.121900 0.760000 0.456000 0.440000 +0.750000 -0.297400 -0.121900 0.656000 0.584000 0.464000 +0.746300 -0.251000 -0.182900 0.848000 0.496000 0.152000 +0.750000 -0.257500 -0.182900 0.856000 0.488000 0.120000 +0.750000 -0.251000 -0.218200 0.840000 0.520000 0.096000 +0.777000 -0.301200 -0.182900 0.784000 0.536000 0.304000 +0.752500 -0.251000 -0.243900 0.840000 0.528000 -0.096000 +0.780500 -0.301200 -0.243900 0.848000 0.504000 -0.128000 +0.777000 -0.301200 -0.182900 0.784000 0.536000 0.304000 +0.800000 -0.328800 -0.243900 0.640000 0.656000 -0.384000 +0.800000 -0.333100 -0.182900 0.680000 0.680000 0.256000 +0.829500 -0.351500 -0.243900 0.648000 0.640000 -0.400000 +0.821300 -0.351500 -0.182900 0.624000 0.648000 0.416000 +0.850000 -0.375700 -0.243900 0.544000 0.616000 -0.552000 +0.850000 -0.381900 -0.182900 0.632000 0.696000 0.328000 +0.890600 -0.401700 -0.243900 0.576000 0.616000 -0.528000 +0.872200 -0.401700 -0.182900 0.632000 0.640000 0.416000 +0.900000 -0.412700 -0.243900 0.520000 0.640000 -0.552000 +0.900000 -0.433800 -0.182900 0.512000 0.688000 0.504000 +0.950000 -0.433400 -0.243900 0.528000 0.832000 0.152000 +0.933400 -0.451900 -0.182900 0.464000 0.712000 0.512000 +0.950000 -0.451900 -0.206400 0.504000 0.736000 0.440000 +0.950000 -0.463500 -0.182900 0.464000 0.672000 0.568000 +0.933400 -0.451900 -0.182900 0.464000 0.712000 0.512000 +0.950000 -0.502100 -0.136000 -0.296000 0.400000 0.864000 +0.900000 -0.451900 -0.156900 0.400000 0.632000 0.656000 +0.900000 -0.502100 -0.123800 -0.168000 -0.208000 0.960000 +0.850000 -0.451900 -0.123600 0.328000 0.296000 0.888000 +0.850000 -0.502100 -0.142100 -0.224000 -0.520000 0.816000 +0.850000 -0.502100 -0.142100 -0.224000 -0.520000 0.816000 +0.750000 -0.257500 -0.182900 0.856000 0.488000 0.120000 +0.750000 -0.257500 -0.182900 0.856000 0.488000 0.120000 +0.750000 -0.297400 -0.121900 0.656000 0.584000 0.464000 +0.777000 -0.301200 -0.182900 0.784000 0.536000 0.304000 +0.752700 -0.301200 -0.121900 0.792000 0.344000 0.488000 +0.800000 -0.333100 -0.182900 0.680000 0.680000 0.256000 +0.775700 -0.351500 -0.121900 0.600000 0.328000 0.720000 +0.800000 -0.351500 -0.149400 0.664000 0.512000 0.528000 +0.800000 -0.391100 -0.121900 0.384000 0.416000 0.816000 +0.821300 -0.351500 -0.182900 0.624000 0.648000 0.416000 +0.810500 -0.401700 -0.121900 0.456000 0.104000 0.872000 +0.850000 -0.381900 -0.182900 0.632000 0.696000 0.328000 +0.850000 -0.401700 -0.151500 0.608000 0.552000 0.560000 +0.872200 -0.401700 -0.182900 0.632000 0.640000 0.416000 +0.850000 -0.451900 -0.123600 0.328000 0.296000 0.888000 +0.900000 -0.433800 -0.182900 0.512000 0.688000 0.504000 +0.900000 -0.451900 -0.156900 0.400000 0.632000 0.656000 +0.933400 -0.451900 -0.182900 0.464000 0.712000 0.512000 +0.933400 -0.451900 -0.182900 0.464000 0.712000 0.512000 +0.783200 -0.502100 -0.182900 -0.448000 -0.720000 0.512000 +0.783200 -0.502100 -0.182900 -0.448000 -0.720000 0.512000 +0.800000 -0.502100 -0.171200 -0.360000 -0.648000 0.664000 +0.800000 -0.511100 -0.182900 -0.376000 -0.744000 0.544000 +0.800000 -0.511100 -0.182900 -0.376000 -0.744000 0.544000 +0.800000 -0.333100 -0.182900 0.680000 0.680000 0.256000 +0.800000 -0.333100 -0.182900 0.680000 0.680000 0.256000 +0.821300 -0.351500 -0.182900 0.624000 0.648000 0.416000 +0.800000 -0.351500 -0.149400 0.664000 0.512000 0.528000 +0.800000 -0.351500 -0.149400 0.664000 0.512000 0.528000 +0.900000 -0.552300 -0.159100 -0.496000 -0.592000 0.632000 +0.900000 -0.552300 -0.159100 -0.496000 -0.592000 0.632000 +0.900000 -0.573700 -0.182900 -0.608000 -0.704000 0.344000 +0.876500 -0.552300 -0.182900 -0.528000 -0.672000 0.504000 +0.900000 -0.578300 -0.243900 -0.552000 -0.704000 -0.440000 +0.868400 -0.552300 -0.243900 -0.552000 -0.760000 -0.328000 +0.900000 -0.552300 -0.278500 -0.424000 -0.592000 -0.672000 +0.900000 -0.552300 -0.278500 -0.424000 -0.592000 -0.672000 +0.900000 0.127900 -0.121900 0.560000 0.776000 -0.264000 +0.900000 0.127900 -0.121900 0.560000 0.776000 -0.264000 +0.931600 0.100400 -0.121900 0.600000 0.744000 -0.272000 +0.900000 0.111100 -0.182900 0.552000 0.712000 -0.416000 +0.912000 0.100400 -0.182900 0.600000 0.704000 -0.360000 +0.900000 0.100400 -0.203200 0.536000 0.688000 -0.472000 +0.900000 0.100400 -0.203200 0.536000 0.688000 -0.472000 +0.950000 -0.602500 -0.169200 -0.536000 -0.520000 0.656000 +0.950000 -0.602500 -0.169200 -0.536000 -0.520000 0.656000 +0.950000 -0.619400 -0.182900 -0.632000 -0.592000 0.480000 +0.935000 -0.602500 -0.182900 -0.552000 -0.552000 0.608000 +0.950000 -0.619400 -0.243900 -0.600000 -0.584000 -0.536000 +0.933200 -0.602500 -0.243900 -0.584000 -0.624000 -0.512000 +0.950000 -0.602500 -0.260200 -0.544000 -0.504000 -0.664000 +0.950000 -0.602500 -0.260200 -0.544000 -0.504000 -0.664000 +1.000000 -0.251000 -0.154300 -0.728000 -0.648000 0.200000 +1.000000 -0.251000 -0.154300 -0.728000 -0.648000 0.200000 +1.000000 -0.258900 -0.182900 -0.752000 -0.616000 0.208000 +0.993400 -0.251000 -0.182900 -0.736000 -0.640000 0.200000 +1.000000 -0.277900 -0.243900 -0.712000 -0.592000 0.360000 +0.978600 -0.251000 -0.243900 -0.696000 -0.616000 0.352000 +0.978600 -0.251000 -0.243900 -0.696000 -0.616000 0.352000 +0.950000 -0.560000 -0.121900 -0.400000 -0.536000 0.728000 +0.950000 -0.560000 -0.121900 -0.400000 -0.536000 0.728000 +0.992300 -0.602500 -0.121900 -0.520000 -0.480000 0.696000 +0.950000 -0.602500 -0.169200 -0.536000 -0.520000 0.656000 +0.950000 -0.602500 -0.169200 -0.536000 -0.520000 0.656000 +1.000000 -0.652700 -0.168000 -0.488000 -0.568000 0.656000 +1.000000 -0.652700 -0.168000 -0.488000 -0.568000 0.656000 +1.000000 -0.666200 -0.182900 -0.536000 -0.632000 0.544000 +0.983200 -0.652700 -0.182900 -0.528000 -0.608000 0.584000 +1.000000 -0.673300 -0.243900 -0.656000 -0.656000 -0.368000 +0.979500 -0.652700 -0.243900 -0.672000 -0.664000 -0.304000 +1.000000 -0.652700 -0.268800 -0.592000 -0.512000 -0.608000 +1.000000 -0.652700 -0.268800 -0.592000 -0.512000 -0.608000 +-1.000000 0.256900 -0.182900 0.288000 0.752000 -0.584000 +-1.000000 0.256900 -0.182900 0.288000 0.752000 -0.584000 +-1.000000 0.251000 -0.191500 0.280000 0.728000 -0.616000 +-0.985000 0.251000 -0.182900 0.288000 0.752000 -0.576000 +-0.985000 0.251000 -0.182900 0.288000 0.752000 -0.576000 +-0.980800 0.200800 -0.243900 0.232000 0.632000 -0.736000 +-0.980800 0.200800 -0.243900 0.232000 0.632000 -0.736000 +-0.950000 0.189400 -0.243900 0.264000 0.616000 -0.728000 +-0.950000 0.200800 -0.231900 0.272000 0.640000 -0.704000 +-0.950000 0.200800 -0.231900 0.272000 0.640000 -0.704000 +-0.900000 0.214200 -0.182900 0.360000 0.720000 -0.576000 +-0.900000 0.214200 -0.182900 0.360000 0.720000 -0.576000 +-0.900000 0.200800 -0.201400 0.352000 0.680000 -0.640000 +-0.874200 0.200800 -0.182900 0.360000 0.712000 -0.584000 +-0.874200 0.200800 -0.182900 0.360000 0.712000 -0.584000 +-0.878700 0.150600 -0.243900 0.328000 0.616000 -0.704000 +-0.878700 0.150600 -0.243900 0.328000 0.616000 -0.704000 +-0.850000 0.135500 -0.243900 0.320000 0.608000 -0.712000 +-0.850000 0.150600 -0.229000 0.320000 0.608000 -0.720000 +-0.850000 0.150600 -0.229000 0.320000 0.608000 -0.720000 +-0.900000 -0.542100 -0.182900 -0.808000 -0.560000 0.136000 +-0.900000 -0.542100 -0.182900 -0.808000 -0.560000 0.136000 +-0.900000 -0.551700 -0.243900 -0.808000 -0.568000 -0.120000 +-0.892400 -0.552300 -0.182900 -0.760000 -0.624000 0.176000 +-0.899500 -0.552300 -0.243900 -0.800000 -0.592000 -0.072000 +-0.850000 -0.592600 -0.182900 -0.520000 -0.800000 0.264000 +-0.851300 -0.602500 -0.243900 -0.680000 -0.720000 -0.008000 +-0.850000 -0.602500 -0.238600 -0.616000 -0.752000 0.216000 +-0.850000 -0.603800 -0.243900 -0.656000 -0.744000 0.064000 +-0.832500 -0.602500 -0.182900 -0.576000 -0.768000 0.272000 +-0.800000 -0.632800 -0.243900 -0.432000 -0.896000 0.072000 +-0.800000 -0.620600 -0.182900 -0.312000 -0.880000 0.336000 +-0.750000 -0.646000 -0.243900 -0.088000 -0.984000 0.144000 +-0.750000 -0.630100 -0.182900 -0.144000 -0.912000 0.360000 +-0.750000 -0.630100 -0.182900 -0.144000 -0.912000 0.360000 +-0.820300 -0.502100 -0.182900 0.496000 0.792000 0.344000 +-0.820300 -0.502100 -0.182900 0.496000 0.792000 0.344000 +-0.800000 -0.502100 -0.227500 0.432000 0.824000 0.352000 +-0.800000 -0.513200 -0.182900 -0.080000 0.880000 0.456000 +-0.750000 -0.502100 -0.184800 -0.496000 0.696000 0.496000 +-0.750000 -0.503000 -0.182900 -0.200000 0.848000 0.472000 +-0.749300 -0.502100 -0.182900 -0.920000 -0.232000 0.288000 +-0.750000 -0.502100 -0.184800 -0.496000 0.696000 0.496000 +-0.750000 -0.499500 -0.182900 -0.936000 -0.200000 0.264000 +-0.750000 -0.499500 -0.182900 -0.936000 -0.200000 0.264000 +-0.850000 -0.592600 -0.182900 -0.520000 -0.800000 0.264000 +-0.850000 -0.592600 -0.182900 -0.520000 -0.800000 0.264000 +-0.832500 -0.602500 -0.182900 -0.576000 -0.768000 0.272000 +-0.850000 -0.602500 -0.238600 -0.616000 -0.752000 0.216000 +-0.850000 -0.602500 -0.238600 -0.616000 -0.752000 0.216000 +-0.650000 0.045800 -0.182900 0.672000 0.432000 -0.592000 +-0.650000 0.045800 -0.182900 0.672000 0.432000 -0.592000 +-0.650000 0.000000 -0.224600 0.632000 0.368000 -0.672000 +-0.621400 0.000000 -0.182900 0.848000 0.280000 -0.440000 +-0.621400 0.000000 -0.182900 0.848000 0.280000 -0.440000 +-0.600000 -0.629300 -0.182900 0.072000 -0.968000 0.224000 +-0.600000 -0.629300 -0.182900 0.072000 -0.968000 0.224000 +-0.600000 -0.640700 -0.243900 0.080000 -0.976000 0.192000 +-0.550000 -0.618800 -0.182900 0.168000 -0.944000 0.272000 +-0.550000 -0.629900 -0.243900 0.160000 -0.960000 0.200000 +-0.500000 -0.610400 -0.182900 -0.136000 -0.936000 0.304000 +-0.500000 -0.625200 -0.243900 -0.096000 -0.960000 0.240000 +-0.550000 -0.629900 -0.243900 0.160000 -0.960000 0.200000 +-0.500000 -0.637800 -0.304800 -0.208000 -0.976000 -0.032000 +-0.550000 -0.639800 -0.304800 0.152000 -0.984000 0.000000 +-0.500000 -0.633000 -0.365800 -0.088000 -0.968000 -0.200000 +-0.550000 -0.637200 -0.365800 0.152000 -0.968000 -0.168000 +-0.550000 -0.639800 -0.304800 0.152000 -0.984000 0.000000 +-0.600000 -0.645500 -0.365800 0.016000 -0.968000 -0.216000 +-0.600000 -0.650800 -0.304800 0.064000 -0.992000 0.000000 +-0.550000 -0.639800 -0.304800 0.152000 -0.984000 0.000000 +-0.600000 -0.640700 -0.243900 0.080000 -0.976000 0.192000 +-0.550000 -0.629900 -0.243900 0.160000 -0.960000 0.200000 +-0.550000 -0.629900 -0.243900 0.160000 -0.960000 0.200000 +-0.403600 -0.100400 -0.182900 -0.616000 0.592000 -0.512000 +-0.403600 -0.100400 -0.182900 -0.616000 0.592000 -0.512000 +-0.400000 -0.100400 -0.188300 -0.616000 0.576000 -0.520000 +-0.400000 -0.096400 -0.182900 -0.664000 0.552000 -0.496000 +-0.354400 -0.100400 -0.243900 -0.584000 0.448000 -0.664000 +-0.365500 -0.050200 -0.182900 -0.728000 0.384000 -0.560000 +-0.350000 -0.093900 -0.243900 -0.600000 0.408000 -0.680000 +-0.350000 -0.050200 -0.209400 -0.696000 0.392000 -0.584000 +-0.321700 -0.050200 -0.243900 -0.656000 0.344000 -0.656000 +-0.350000 -0.016600 -0.182900 -0.688000 0.360000 -0.616000 +-0.301700 0.000000 -0.243900 -0.744000 0.392000 -0.536000 +-0.340600 0.000000 -0.182900 -0.696000 0.480000 -0.520000 +-0.340600 0.000000 -0.182900 -0.696000 0.480000 -0.520000 +-0.444500 -0.150600 -0.243900 -0.312000 0.784000 -0.528000 +-0.444500 -0.150600 -0.243900 -0.312000 0.784000 -0.528000 +-0.450000 -0.150600 -0.239400 -0.408000 0.792000 -0.448000 +-0.450000 -0.152500 -0.243900 -0.384000 0.800000 -0.448000 +-0.450000 -0.152500 -0.243900 -0.384000 0.800000 -0.448000 +-0.400000 -0.651500 -0.182900 -0.552000 -0.472000 0.672000 +-0.400000 -0.651500 -0.182900 -0.552000 -0.472000 0.672000 +-0.400000 -0.652700 -0.184800 -0.640000 -0.536000 0.536000 +-0.450000 -0.629600 -0.182900 -0.344000 -0.872000 0.320000 +-0.428400 -0.652700 -0.243900 -0.584000 -0.736000 0.336000 +-0.450000 -0.644000 -0.243900 -0.352000 -0.912000 0.200000 +-0.450000 -0.652700 -0.293400 -0.288000 -0.936000 0.160000 +-0.428400 -0.652700 -0.243900 -0.584000 -0.736000 0.336000 +-0.450000 -0.654300 -0.304800 -0.272000 -0.952000 0.040000 +-0.400000 -0.663600 -0.243900 -0.504000 -0.840000 0.160000 +-0.400000 -0.672200 -0.304800 -0.400000 -0.904000 -0.128000 +-0.363900 -0.703000 -0.243900 -0.784000 -0.584000 0.176000 +-0.371300 -0.703000 -0.304800 -0.816000 -0.552000 -0.144000 +-0.350000 -0.730400 -0.243900 -0.544000 -0.776000 0.296000 +-0.350000 -0.747900 -0.304800 -0.512000 -0.832000 -0.184000 +-0.300000 -0.736500 -0.243900 0.320000 -0.832000 0.440000 +-0.330700 -0.753200 -0.304800 -0.192000 -0.968000 -0.112000 +-0.300000 -0.753200 -0.286100 0.088000 -0.928000 0.352000 +-0.300000 -0.758500 -0.304800 0.104000 -0.976000 -0.144000 +-0.281500 -0.753200 -0.304800 0.312000 -0.920000 -0.216000 +-0.300000 -0.753200 -0.317300 0.136000 -0.840000 -0.512000 +-0.300000 -0.758500 -0.304800 0.104000 -0.976000 -0.144000 +-0.330700 -0.753200 -0.304800 -0.192000 -0.968000 -0.112000 +-0.300000 -0.753200 -0.317300 0.136000 -0.840000 -0.512000 +-0.350000 -0.747900 -0.304800 -0.512000 -0.832000 -0.184000 +-0.300000 -0.703000 -0.365100 0.056000 -0.232000 -0.968000 +-0.350000 -0.703000 -0.357000 -0.336000 -0.496000 -0.792000 +-0.300000 -0.687100 -0.365800 0.104000 -0.048000 -0.992000 +-0.350000 -0.679200 -0.365800 -0.072000 -0.176000 -0.976000 +-0.350000 -0.703000 -0.357000 -0.336000 -0.496000 -0.792000 +-0.400000 -0.653700 -0.365800 -0.176000 -0.888000 -0.416000 +-0.371300 -0.703000 -0.304800 -0.816000 -0.552000 -0.144000 +-0.400000 -0.672200 -0.304800 -0.400000 -0.904000 -0.128000 +-0.400000 -0.672200 -0.304800 -0.400000 -0.904000 -0.128000 +-0.428400 -0.652700 -0.243900 -0.584000 -0.736000 0.336000 +-0.428400 -0.652700 -0.243900 -0.584000 -0.736000 0.336000 +-0.400000 -0.652700 -0.184800 -0.640000 -0.536000 0.536000 +-0.400000 -0.663600 -0.243900 -0.504000 -0.840000 0.160000 +-0.396000 -0.652700 -0.182900 -0.176000 0.000000 0.984000 +-0.363900 -0.703000 -0.243900 -0.784000 -0.584000 0.176000 +-0.350700 -0.703000 -0.182900 -0.792000 -0.176000 0.576000 +-0.350000 -0.730400 -0.243900 -0.544000 -0.776000 0.296000 +-0.350000 -0.704300 -0.182900 -0.112000 -0.808000 0.576000 +-0.300000 -0.736500 -0.243900 0.320000 -0.832000 0.440000 +-0.300000 -0.708000 -0.182900 0.360000 -0.768000 0.520000 +-0.300000 -0.708000 -0.182900 0.360000 -0.768000 0.520000 +-0.365500 -0.050200 -0.182900 -0.728000 0.384000 -0.560000 +-0.365500 -0.050200 -0.182900 -0.728000 0.384000 -0.560000 +-0.350000 -0.050200 -0.209400 -0.696000 0.392000 -0.584000 +-0.350000 -0.016600 -0.182900 -0.688000 0.360000 -0.616000 +-0.350000 -0.016600 -0.182900 -0.688000 0.360000 -0.616000 +-0.400000 -0.100400 -0.188300 -0.616000 0.576000 -0.520000 +-0.400000 -0.100400 -0.188300 -0.616000 0.576000 -0.520000 +-0.400000 -0.131400 -0.243900 -0.384000 0.744000 -0.536000 +-0.354400 -0.100400 -0.243900 -0.584000 0.448000 -0.664000 +-0.400000 -0.150600 -0.272200 -0.312000 0.624000 -0.704000 +-0.350000 -0.100400 -0.248500 -0.576000 0.440000 -0.680000 +-0.350000 -0.150600 -0.298700 -0.264000 0.464000 -0.840000 +-0.400000 -0.150600 -0.272200 -0.312000 0.624000 -0.704000 +-0.350000 -0.159400 -0.304800 -0.248000 0.528000 -0.808000 +-0.400000 -0.174400 -0.304800 -0.224000 0.736000 -0.632000 +-0.350000 -0.200800 -0.339000 0.200000 0.416000 -0.880000 +-0.400000 -0.200800 -0.333600 -0.064000 0.568000 -0.816000 +-0.350000 -0.248400 -0.365800 0.184000 0.424000 -0.880000 +-0.400000 -0.239300 -0.365800 0.048000 0.512000 -0.848000 +-0.350000 -0.251000 -0.367200 0.240000 0.168000 -0.952000 +-0.400000 -0.251000 -0.373300 0.080000 0.400000 -0.904000 +-0.350000 -0.301200 -0.377400 0.232000 0.208000 -0.944000 +-0.400000 -0.301200 -0.390900 0.144000 0.296000 -0.936000 +-0.350000 -0.351500 -0.416300 -0.176000 0.600000 -0.768000 +-0.400000 -0.351500 -0.411400 0.000000 0.616000 -0.784000 +-0.400000 -0.351500 -0.411400 0.000000 0.616000 -0.784000 +-0.350000 -0.647900 -0.182900 0.008000 0.768000 0.624000 +-0.350000 -0.647900 -0.182900 0.008000 0.768000 0.624000 +-0.386500 -0.602500 -0.182900 0.376000 -0.032000 0.920000 +-0.350000 -0.630200 -0.243900 -0.144000 0.776000 0.600000 +-0.371400 -0.602500 -0.243900 0.928000 0.016000 0.352000 +-0.371400 -0.602500 -0.243900 0.928000 0.016000 0.352000 +-0.200000 0.172600 -0.182900 -0.488000 0.416000 -0.760000 +-0.200000 0.172600 -0.182900 -0.488000 0.416000 -0.760000 +-0.216700 0.150600 -0.182900 -0.560000 0.376000 -0.728000 +-0.200000 0.150600 -0.197300 -0.488000 0.464000 -0.728000 +-0.249100 0.100400 -0.182900 -0.576000 0.496000 -0.640000 +-0.200000 0.100400 -0.242800 -0.520000 0.512000 -0.672000 +-0.200000 0.100400 -0.242800 -0.520000 0.512000 -0.672000 +-0.200000 0.172600 -0.182900 -0.488000 0.416000 -0.760000 +-0.200000 0.172600 -0.182900 -0.488000 0.416000 -0.760000 +-0.200000 0.150600 -0.197300 -0.488000 0.464000 -0.728000 +-0.173800 0.200800 -0.182900 -0.480000 0.344000 -0.800000 +-0.150000 0.150600 -0.235500 -0.296000 0.536000 -0.784000 +-0.150000 0.200800 -0.199200 -0.328000 0.272000 -0.896000 +-0.150000 0.200800 -0.199200 -0.328000 0.272000 -0.896000 +0.100000 0.004900 -0.182900 -0.288000 0.864000 0.400000 +0.100000 0.004900 -0.182900 -0.288000 0.864000 0.400000 +0.050000 0.005700 -0.182900 0.312000 0.584000 0.744000 +0.100000 0.000000 -0.203800 -0.256000 0.936000 -0.224000 +0.050000 0.042300 -0.243900 0.688000 0.376000 -0.616000 +0.078000 0.000000 -0.243900 0.336000 0.616000 -0.696000 +0.050000 0.000000 -0.258500 0.448000 0.256000 -0.848000 +0.100000 -0.005500 -0.243900 -0.184000 0.760000 -0.616000 +0.050000 -0.050200 -0.279200 0.280000 0.320000 -0.896000 +0.100000 -0.050200 -0.272200 -0.136000 0.384000 -0.904000 +0.050000 -0.100400 -0.298100 0.360000 0.248000 -0.896000 +0.100000 -0.100400 -0.298900 0.040000 0.136000 -0.984000 +0.100000 -0.100400 -0.298900 0.040000 0.136000 -0.984000 +0.078000 0.000000 -0.243900 0.336000 0.616000 -0.696000 +0.078000 0.000000 -0.243900 0.336000 0.616000 -0.696000 +0.100000 -0.005500 -0.243900 -0.184000 0.760000 -0.616000 +0.100000 0.000000 -0.203800 -0.256000 0.936000 -0.224000 +0.100000 0.000000 -0.203800 -0.256000 0.936000 -0.224000 +0.200000 -0.301200 -0.206400 -0.600000 -0.688000 0.384000 +0.200000 -0.301200 -0.206400 -0.600000 -0.688000 0.384000 +0.200000 -0.319700 -0.243900 -0.624000 -0.696000 0.328000 +0.176900 -0.301200 -0.243900 -0.504000 -0.800000 0.304000 +0.200000 -0.340400 -0.304800 -0.480000 -0.448000 -0.744000 +0.170700 -0.301200 -0.304800 -0.520000 -0.608000 -0.592000 +0.200000 -0.301200 -0.321600 -0.488000 -0.368000 -0.784000 +0.200000 -0.301200 -0.321600 -0.488000 -0.368000 -0.784000 +0.300000 -0.330300 -0.182900 -0.312000 -0.696000 0.632000 +0.300000 -0.330300 -0.182900 -0.312000 -0.696000 0.632000 +0.300000 -0.351500 -0.225700 -0.416000 -0.800000 0.416000 +0.250000 -0.319600 -0.182900 -0.280000 -0.832000 0.472000 +0.277600 -0.351500 -0.243900 -0.264000 -0.888000 0.352000 +0.250000 -0.343100 -0.243900 -0.320000 -0.920000 0.208000 +0.271900 -0.351500 -0.304800 -0.112000 -0.784000 -0.608000 +0.250000 -0.348300 -0.304800 -0.128000 -0.736000 -0.656000 +0.300000 -0.351500 -0.310200 -0.192000 -0.728000 -0.648000 +0.250000 -0.313600 -0.365800 -0.336000 -0.640000 -0.680000 +0.300000 -0.308000 -0.365800 0.080000 -0.656000 -0.744000 +0.250000 -0.301200 -0.379400 -0.536000 -0.264000 -0.792000 +0.300000 -0.301200 -0.372900 0.128000 -0.472000 -0.864000 +0.300000 -0.308000 -0.365800 0.080000 -0.656000 -0.744000 +0.333500 -0.301200 -0.365800 0.208000 -0.080000 -0.968000 +0.300000 -0.351500 -0.310200 -0.192000 -0.728000 -0.648000 +0.350000 -0.301200 -0.360500 0.376000 0.184000 -0.904000 +0.348000 -0.351500 -0.365800 -0.720000 -0.032000 -0.680000 +0.350000 -0.334300 -0.365800 -0.304000 0.096000 -0.944000 +0.350000 -0.351500 -0.368100 -0.440000 0.096000 -0.888000 +0.355700 -0.351500 -0.365800 0.360000 -0.072000 -0.928000 +0.350000 -0.354600 -0.365800 -0.264000 -0.632000 -0.720000 +0.400000 -0.351500 -0.338800 0.360000 -0.568000 -0.728000 +0.350000 -0.401700 -0.317400 -0.608000 -0.560000 -0.544000 +0.400000 -0.388800 -0.304800 0.392000 -0.800000 -0.448000 +0.376800 -0.401700 -0.304800 0.336000 -0.848000 -0.392000 +0.400000 -0.401700 -0.257800 0.112000 -0.952000 -0.280000 +0.350000 -0.410700 -0.304800 -0.592000 -0.664000 -0.440000 +0.400000 -0.404800 -0.243900 0.016000 -0.968000 0.240000 +0.350000 -0.409600 -0.243900 -0.632000 -0.696000 0.320000 +0.400000 -0.401700 -0.239700 -0.184000 -0.720000 0.656000 +0.350000 -0.401700 -0.229000 -0.616000 -0.656000 0.416000 +0.400000 -0.370500 -0.182900 -0.008000 -0.616000 0.776000 +0.350000 -0.366900 -0.182900 -0.368000 -0.552000 0.736000 +0.350000 -0.401700 -0.229000 -0.616000 -0.656000 0.416000 +0.331500 -0.351500 -0.182900 -0.432000 -0.576000 0.688000 +0.343800 -0.401700 -0.243900 -0.728000 -0.584000 0.344000 +0.300000 -0.351500 -0.225700 -0.416000 -0.800000 0.416000 +0.300000 -0.357600 -0.243900 -0.288000 -0.920000 0.248000 +0.277600 -0.351500 -0.243900 -0.264000 -0.888000 0.352000 +0.300000 -0.355300 -0.304800 -0.272000 -0.752000 -0.592000 +0.271900 -0.351500 -0.304800 -0.112000 -0.784000 -0.608000 +0.300000 -0.351500 -0.310200 -0.192000 -0.728000 -0.648000 +0.300000 -0.355300 -0.304800 -0.272000 -0.752000 -0.592000 +0.348000 -0.351500 -0.365800 -0.720000 -0.032000 -0.680000 +0.344100 -0.401700 -0.304800 -0.784000 -0.512000 -0.336000 +0.350000 -0.354600 -0.365800 -0.264000 -0.632000 -0.720000 +0.350000 -0.401700 -0.317400 -0.608000 -0.560000 -0.544000 +0.344100 -0.401700 -0.304800 -0.784000 -0.512000 -0.336000 +0.350000 -0.410700 -0.304800 -0.592000 -0.664000 -0.440000 +0.343800 -0.401700 -0.243900 -0.728000 -0.584000 0.344000 +0.350000 -0.409600 -0.243900 -0.632000 -0.696000 0.320000 +0.350000 -0.401700 -0.229000 -0.616000 -0.656000 0.416000 +0.350000 -0.401700 -0.229000 -0.616000 -0.656000 0.416000 +0.300000 -0.330300 -0.182900 -0.312000 -0.696000 0.632000 +0.300000 -0.330300 -0.182900 -0.312000 -0.696000 0.632000 +0.331500 -0.351500 -0.182900 -0.432000 -0.576000 0.688000 +0.300000 -0.351500 -0.225700 -0.416000 -0.800000 0.416000 +0.300000 -0.351500 -0.225700 -0.416000 -0.800000 0.416000 +0.427100 -0.301200 -0.182900 0.776000 0.464000 0.416000 +0.427100 -0.301200 -0.182900 0.776000 0.464000 0.416000 +0.450000 -0.338000 -0.182900 0.248000 0.592000 0.752000 +0.429200 -0.301200 -0.243900 0.816000 0.544000 -0.176000 +0.450000 -0.327300 -0.243900 -0.064000 0.864000 -0.488000 +0.401200 -0.301200 -0.304800 0.744000 0.488000 -0.440000 +0.450000 -0.351500 -0.290700 -0.176000 0.632000 -0.744000 +0.437100 -0.351500 -0.304800 0.688000 0.472000 -0.536000 +0.437100 -0.351500 -0.304800 0.688000 0.472000 -0.536000 +0.450000 -0.370700 -0.182900 -0.080000 -0.520000 0.848000 +0.450000 -0.370700 -0.182900 -0.080000 -0.520000 0.848000 +0.400000 -0.370500 -0.182900 -0.008000 -0.616000 0.776000 +0.450000 -0.401700 -0.212100 0.240000 -0.816000 0.520000 +0.400000 -0.401700 -0.239700 -0.184000 -0.720000 0.656000 +0.450000 -0.418500 -0.243900 -0.152000 -0.896000 0.400000 +0.400000 -0.404800 -0.243900 0.016000 -0.968000 0.240000 +0.450000 -0.411100 -0.304800 -0.144000 -0.808000 -0.560000 +0.400000 -0.401700 -0.257800 0.112000 -0.952000 -0.280000 +0.428900 -0.401700 -0.304800 -0.392000 -0.464000 -0.784000 +0.428900 -0.401700 -0.304800 -0.392000 -0.464000 -0.784000 +0.500000 0.355500 -0.182900 0.400000 0.616000 -0.664000 +0.500000 0.355500 -0.182900 0.400000 0.616000 -0.664000 +0.500000 0.351500 -0.187300 0.416000 0.568000 -0.696000 +0.506000 0.351500 -0.182900 0.424000 0.584000 -0.680000 +0.506000 0.351500 -0.182900 0.424000 0.584000 -0.680000 +0.550000 -0.401700 -0.218900 -0.128000 -0.904000 0.392000 +0.550000 -0.401700 -0.218900 -0.128000 -0.904000 0.392000 +0.550000 -0.409700 -0.243900 -0.144000 -0.944000 0.272000 +0.503900 -0.401700 -0.243900 -0.232000 -0.936000 0.256000 +0.550000 -0.415900 -0.304800 -0.192000 -0.848000 -0.480000 +0.502600 -0.401700 -0.304800 -0.320000 -0.840000 -0.416000 +0.550000 -0.401700 -0.333700 -0.144000 -0.688000 -0.704000 +0.550000 -0.401700 -0.333700 -0.144000 -0.688000 -0.704000 +0.600000 0.200800 -0.209200 0.248000 0.288000 -0.920000 +0.600000 0.200800 -0.209200 0.248000 0.288000 -0.920000 +0.650000 0.200800 -0.204000 0.272000 0.408000 -0.864000 +0.600000 0.150600 -0.225200 0.008000 0.128000 -0.984000 +0.650000 0.150600 -0.219600 0.200000 0.280000 -0.928000 +0.600000 0.100400 -0.237100 -0.096000 0.168000 -0.976000 +0.650000 0.100400 -0.241400 0.232000 0.064000 -0.968000 +0.600000 0.076600 -0.243900 -0.096000 0.360000 -0.920000 +0.650000 0.067400 -0.243900 0.208000 0.056000 -0.968000 +0.600000 0.050200 -0.251100 0.248000 0.344000 -0.896000 +0.650000 0.050200 -0.244900 0.216000 0.040000 -0.968000 +0.600000 0.000000 -0.284600 0.512000 0.112000 -0.840000 +0.650000 0.000000 -0.248500 0.680000 -0.160000 -0.712000 +0.650000 0.000000 -0.248500 0.680000 -0.160000 -0.712000 +0.600000 -0.392700 -0.182900 -0.184000 -0.752000 0.624000 +0.600000 -0.392700 -0.182900 -0.184000 -0.752000 0.624000 +0.628900 -0.401700 -0.182900 -0.216000 -0.760000 0.608000 +0.600000 -0.401700 -0.203000 -0.208000 -0.872000 0.432000 +0.600000 -0.401700 -0.203000 -0.208000 -0.872000 0.432000 +0.700000 -0.451900 -0.215800 -0.528000 -0.696000 0.472000 +0.700000 -0.451900 -0.215800 -0.528000 -0.696000 0.472000 +0.700000 -0.472400 -0.243900 -0.560000 -0.816000 -0.016000 +0.673600 -0.451900 -0.243900 -0.480000 -0.752000 0.448000 +0.700000 -0.481300 -0.304800 -0.240000 -0.712000 -0.656000 +0.653100 -0.451900 -0.304800 -0.336000 -0.480000 -0.800000 +0.700000 -0.451900 -0.321600 -0.136000 -0.312000 -0.936000 +0.700000 -0.451900 -0.321600 -0.136000 -0.312000 -0.936000 +0.700000 -0.435200 -0.182900 -0.448000 -0.712000 0.536000 +0.700000 -0.435200 -0.182900 -0.448000 -0.712000 0.536000 +0.719600 -0.451900 -0.182900 -0.568000 -0.640000 0.512000 +0.700000 -0.451900 -0.215800 -0.528000 -0.696000 0.472000 +0.700000 -0.451900 -0.215800 -0.528000 -0.696000 0.472000 +0.750000 -0.502100 -0.236900 -0.448000 -0.776000 0.432000 +0.750000 -0.502100 -0.236900 -0.448000 -0.776000 0.432000 +0.750000 -0.505200 -0.243900 -0.480000 -0.856000 0.152000 +0.744200 -0.502100 -0.243900 -0.480000 -0.864000 0.128000 +0.750000 -0.502100 -0.254300 -0.448000 -0.832000 -0.312000 +0.750000 -0.502100 -0.254300 -0.448000 -0.832000 -0.312000 +0.750000 0.157000 -0.182900 0.280000 0.720000 -0.624000 +0.750000 0.157000 -0.182900 0.280000 0.720000 -0.624000 +0.750000 0.150600 -0.191500 0.256000 0.656000 -0.704000 +0.769100 0.150600 -0.182900 0.248000 0.704000 -0.648000 +0.769100 0.150600 -0.182900 0.248000 0.704000 -0.648000 +0.929600 0.050200 -0.243900 0.432000 0.672000 -0.584000 +0.929600 0.050200 -0.243900 0.432000 0.672000 -0.584000 +0.950000 0.037500 -0.243900 0.432000 0.688000 -0.576000 +0.950000 0.050200 -0.224500 0.472000 0.712000 -0.504000 +0.950000 0.050200 -0.224500 0.472000 0.712000 -0.504000 +0.950000 0.069900 -0.182900 0.544000 0.736000 -0.392000 +0.950000 0.069900 -0.182900 0.544000 0.736000 -0.392000 +0.950000 0.050200 -0.224500 0.472000 0.712000 -0.504000 +0.978000 0.050200 -0.182900 0.512000 0.768000 -0.376000 +0.978000 0.050200 -0.182900 0.512000 0.768000 -0.376000 +0.950000 -0.451900 -0.206400 0.504000 0.736000 0.440000 +0.950000 -0.451900 -0.206400 0.504000 0.736000 0.440000 +0.950000 -0.433400 -0.243900 0.528000 0.832000 0.152000 +0.980700 -0.451900 -0.243900 0.752000 0.648000 0.032000 +0.950000 -0.451900 -0.300000 0.488000 0.464000 -0.728000 +0.950000 -0.433400 -0.243900 0.528000 0.832000 0.152000 +0.900000 -0.451900 -0.272400 0.368000 0.408000 -0.824000 +0.900000 -0.412700 -0.243900 0.520000 0.640000 -0.552000 +0.850000 -0.451900 -0.293100 0.448000 0.248000 -0.848000 +0.890600 -0.401700 -0.243900 0.576000 0.616000 -0.528000 +0.850000 -0.401700 -0.268600 0.504000 0.432000 -0.744000 +0.850000 -0.375700 -0.243900 0.544000 0.616000 -0.552000 +0.800000 -0.401700 -0.291400 0.440000 0.456000 -0.760000 +0.829500 -0.351500 -0.243900 0.648000 0.640000 -0.400000 +0.800000 -0.351500 -0.277300 0.568000 0.408000 -0.704000 +0.800000 -0.328800 -0.243900 0.640000 0.656000 -0.384000 +0.800000 -0.328800 -0.243900 0.640000 0.656000 -0.384000 +1.000000 -0.503200 -0.182900 0.400000 0.704000 0.576000 +1.000000 -0.503200 -0.182900 0.400000 0.704000 0.576000 +0.998000 -0.502100 -0.182900 0.528000 0.664000 0.520000 +1.000000 -0.502100 -0.189300 0.760000 0.568000 0.296000 +1.000000 -0.502100 -0.189300 0.760000 0.568000 0.296000 +-0.891000 -0.451900 -0.304800 0.528000 0.824000 -0.192000 +-0.891000 -0.451900 -0.304800 0.528000 0.824000 -0.192000 +-0.896800 -0.451900 -0.243900 0.600000 0.776000 0.136000 +-0.850000 -0.473200 -0.304800 0.272000 0.896000 -0.336000 +-0.850000 -0.480800 -0.243900 0.376000 0.912000 0.152000 +-0.800000 -0.473000 -0.304800 -0.736000 0.648000 -0.168000 +-0.800000 -0.496000 -0.243900 0.424000 0.840000 0.320000 +-0.787800 -0.451900 -0.304800 -0.984000 0.136000 -0.040000 +-0.769800 -0.451900 -0.243900 -0.952000 -0.080000 0.272000 +-0.769800 -0.451900 -0.243900 -0.952000 -0.080000 0.272000 +-0.900000 -0.551700 -0.243900 -0.808000 -0.568000 -0.120000 +-0.900000 -0.551700 -0.243900 -0.808000 -0.568000 -0.120000 +-0.900000 -0.539600 -0.304800 -0.720000 -0.488000 -0.480000 +-0.899500 -0.552300 -0.243900 -0.800000 -0.592000 -0.072000 +-0.891900 -0.552300 -0.304800 -0.800000 -0.568000 -0.136000 +-0.851300 -0.602500 -0.243900 -0.680000 -0.720000 -0.008000 +-0.850000 -0.602000 -0.304800 -0.640000 -0.736000 -0.184000 +-0.850000 -0.602500 -0.285600 -0.672000 -0.728000 -0.024000 +-0.849200 -0.602500 -0.304800 -0.536000 -0.720000 -0.432000 +-0.850000 -0.603800 -0.243900 -0.656000 -0.744000 0.064000 +-0.800000 -0.636000 -0.304800 -0.536000 -0.792000 -0.272000 +-0.800000 -0.632800 -0.243900 -0.432000 -0.896000 0.072000 +-0.750000 -0.652200 -0.304800 -0.040000 -0.952000 -0.288000 +-0.750000 -0.646000 -0.243900 -0.088000 -0.984000 0.144000 +-0.750000 -0.646000 -0.243900 -0.088000 -0.984000 0.144000 +-0.850000 -0.603800 -0.243900 -0.656000 -0.744000 0.064000 +-0.850000 -0.603800 -0.243900 -0.656000 -0.744000 0.064000 +-0.850000 -0.602500 -0.285600 -0.672000 -0.728000 -0.024000 +-0.851300 -0.602500 -0.243900 -0.680000 -0.720000 -0.008000 +-0.851300 -0.602500 -0.243900 -0.680000 -0.720000 -0.008000 +-0.800000 0.108800 -0.243900 0.352000 0.608000 -0.704000 +-0.800000 0.108800 -0.243900 0.352000 0.608000 -0.704000 +-0.800000 0.100400 -0.252800 0.360000 0.584000 -0.720000 +-0.785800 0.100400 -0.243900 0.360000 0.584000 -0.720000 +-0.785800 0.100400 -0.243900 0.360000 0.584000 -0.720000 +-0.750000 0.077000 -0.243900 0.368000 0.552000 -0.744000 +-0.750000 0.077000 -0.243900 0.368000 0.552000 -0.744000 +-0.750000 0.050200 -0.267100 0.368000 0.432000 -0.816000 +-0.711800 0.050200 -0.243900 0.416000 0.432000 -0.792000 +-0.711800 0.050200 -0.243900 0.416000 0.432000 -0.792000 +-0.731900 -0.150600 -0.304800 0.424000 0.400000 -0.808000 +-0.731900 -0.150600 -0.304800 0.424000 0.400000 -0.808000 +-0.700000 -0.175200 -0.304800 0.352000 0.528000 -0.768000 +-0.700000 -0.150600 -0.284500 0.376000 0.392000 -0.832000 +-0.700000 -0.150600 -0.284500 0.376000 0.392000 -0.832000 +-0.650000 -0.200800 -0.303800 0.136000 0.680000 -0.712000 +-0.650000 -0.200800 -0.303800 0.136000 0.680000 -0.712000 +-0.651700 -0.200800 -0.304800 0.320000 0.544000 -0.768000 +-0.650000 -0.201600 -0.304800 0.104000 0.688000 -0.704000 +-0.700000 -0.200800 -0.326900 0.208000 0.528000 -0.816000 +-0.650000 -0.251000 -0.354800 0.152000 0.632000 -0.752000 +-0.700000 -0.251000 -0.364900 0.104000 0.560000 -0.816000 +-0.650000 -0.261300 -0.365800 0.088000 0.568000 -0.808000 +-0.700000 -0.252100 -0.365800 0.096000 0.552000 -0.824000 +-0.700000 -0.251000 -0.364900 0.104000 0.560000 -0.816000 +-0.707800 -0.251000 -0.365800 0.064000 0.432000 -0.896000 +-0.700000 -0.200800 -0.326900 0.208000 0.528000 -0.816000 +-0.750000 -0.240500 -0.365800 0.056000 0.272000 -0.952000 +-0.750000 -0.200800 -0.348300 0.272000 0.384000 -0.872000 +-0.800000 -0.234100 -0.365800 -0.112000 0.264000 -0.952000 +-0.800000 -0.200800 -0.355700 0.080000 0.256000 -0.960000 +-0.800000 -0.200800 -0.355700 0.080000 0.256000 -0.960000 +-0.650000 -0.035200 -0.243900 0.544000 0.264000 -0.792000 +-0.650000 -0.035200 -0.243900 0.544000 0.264000 -0.792000 +-0.650000 -0.050200 -0.249300 0.496000 0.208000 -0.840000 +-0.642900 -0.050200 -0.243900 0.560000 0.208000 -0.792000 +-0.642900 -0.050200 -0.243900 0.560000 0.208000 -0.792000 +-0.544700 -0.200800 -0.304800 -0.080000 0.824000 -0.552000 +-0.544700 -0.200800 -0.304800 -0.080000 0.824000 -0.552000 +-0.550000 -0.200800 -0.303600 -0.040000 0.880000 -0.464000 +-0.550000 -0.201300 -0.304800 -0.032000 0.864000 -0.488000 +-0.550000 -0.201300 -0.304800 -0.032000 0.864000 -0.488000 +-0.354400 -0.100400 -0.243900 -0.584000 0.448000 -0.664000 +-0.354400 -0.100400 -0.243900 -0.584000 0.448000 -0.664000 +-0.350000 -0.100400 -0.248500 -0.576000 0.440000 -0.680000 +-0.350000 -0.093900 -0.243900 -0.600000 0.408000 -0.680000 +-0.350000 -0.093900 -0.243900 -0.600000 0.408000 -0.680000 +-0.363900 -0.552300 -0.243900 0.816000 -0.480000 0.304000 +-0.363900 -0.552300 -0.243900 0.816000 -0.480000 0.304000 +-0.350000 -0.535600 -0.243900 0.360000 -0.840000 0.384000 +-0.350000 -0.552300 -0.283400 -0.096000 -0.680000 0.720000 +-0.317500 -0.552300 -0.243900 -0.600000 -0.648000 0.448000 +-0.317500 -0.552300 -0.243900 -0.600000 -0.648000 0.448000 +-0.300000 -0.050200 -0.270300 -0.824000 0.232000 -0.512000 +-0.300000 -0.050200 -0.270300 -0.824000 0.232000 -0.512000 +-0.266700 -0.050200 -0.304800 -0.504000 0.288000 -0.808000 +-0.300000 -0.100400 -0.298100 -0.480000 0.288000 -0.824000 +-0.288100 -0.100400 -0.304800 -0.408000 0.240000 -0.872000 +-0.300000 -0.118900 -0.304800 -0.376000 0.264000 -0.880000 +-0.300000 -0.118900 -0.304800 -0.376000 0.264000 -0.880000 +-0.256000 -0.703000 -0.243900 0.696000 -0.392000 0.584000 +-0.256000 -0.703000 -0.243900 0.696000 -0.392000 0.584000 +-0.250000 -0.679700 -0.243900 0.728000 -0.208000 0.640000 +-0.250000 -0.703000 -0.252700 0.704000 -0.368000 0.600000 +-0.250000 -0.703000 -0.252700 0.704000 -0.368000 0.600000 +-0.213400 0.000000 -0.304800 -0.304000 0.448000 -0.832000 +-0.213400 0.000000 -0.304800 -0.304000 0.448000 -0.832000 +-0.250000 0.000000 -0.286200 -0.320000 0.712000 -0.616000 +-0.250000 -0.028200 -0.304800 -0.400000 0.416000 -0.808000 +-0.250000 -0.028200 -0.304800 -0.400000 0.416000 -0.808000 +-0.196100 -0.200800 -0.304800 0.360000 -0.200000 -0.904000 +-0.196100 -0.200800 -0.304800 0.360000 -0.200000 -0.904000 +-0.150000 -0.200800 -0.284500 0.024000 -0.216000 -0.968000 +-0.150000 -0.159100 -0.304800 0.152000 -0.400000 -0.896000 +-0.108400 -0.200800 -0.304800 -0.496000 -0.048000 -0.856000 +-0.108400 -0.200800 -0.304800 -0.496000 -0.048000 -0.856000 +-0.172800 -0.552300 -0.243900 0.592000 -0.568000 0.560000 +-0.172800 -0.552300 -0.243900 0.592000 -0.568000 0.560000 +-0.150000 -0.530700 -0.243900 0.632000 -0.664000 0.392000 +-0.150000 -0.552300 -0.270100 0.544000 -0.504000 0.656000 +-0.150000 -0.552300 -0.270100 0.544000 -0.504000 0.656000 +-0.126800 0.150600 -0.243900 -0.208000 0.496000 -0.832000 +-0.126800 0.150600 -0.243900 -0.208000 0.496000 -0.832000 +-0.100000 0.150600 -0.251000 -0.024000 0.408000 -0.904000 +-0.100000 0.164100 -0.243900 -0.032000 0.432000 -0.896000 +-0.077600 0.150600 -0.243900 0.320000 0.328000 -0.880000 +-0.077600 0.150600 -0.243900 0.320000 0.328000 -0.880000 +-0.150000 0.100400 -0.267100 -0.312000 0.440000 -0.832000 +-0.150000 0.100400 -0.267100 -0.312000 0.440000 -0.832000 +-0.100000 0.100400 -0.276400 0.032000 0.376000 -0.920000 +-0.150000 0.050200 -0.299600 -0.080000 0.408000 -0.904000 +-0.100000 0.050200 -0.292200 0.304000 0.312000 -0.896000 +-0.150000 0.040500 -0.304800 -0.136000 0.416000 -0.896000 +-0.100000 0.022400 -0.304800 0.184000 0.304000 -0.928000 +-0.150000 0.000000 -0.322200 0.064000 0.240000 -0.968000 +-0.100000 0.000000 -0.309600 0.168000 0.152000 -0.968000 +-0.150000 -0.050200 -0.328000 0.128000 0.064000 -0.984000 +-0.100000 -0.050200 -0.318600 0.080000 0.144000 -0.984000 +-0.150000 -0.100400 -0.338700 0.056000 -0.088000 -0.992000 +-0.100000 -0.100400 -0.323700 -0.040000 -0.152000 -0.984000 +-0.150000 -0.150600 -0.309500 -0.032000 -0.400000 -0.912000 +-0.100000 -0.150600 -0.315000 -0.456000 -0.064000 -0.880000 +-0.100000 -0.150600 -0.315000 -0.456000 -0.064000 -0.880000 +-0.077600 0.000000 -0.304800 0.248000 0.344000 -0.896000 +-0.077600 0.000000 -0.304800 0.248000 0.344000 -0.896000 +-0.050000 -0.015100 -0.304800 0.280000 0.536000 -0.784000 +-0.050000 0.000000 -0.288000 0.256000 0.560000 -0.776000 +-0.050000 0.000000 -0.288000 0.256000 0.560000 -0.776000 +-0.013800 -0.351500 -0.243900 0.552000 -0.808000 -0.168000 +-0.013800 -0.351500 -0.243900 0.552000 -0.808000 -0.168000 +-0.050000 -0.380500 -0.243900 0.664000 -0.736000 -0.104000 +-0.026900 -0.351500 -0.304800 0.608000 -0.688000 -0.384000 +-0.050000 -0.374600 -0.304800 0.584000 -0.672000 -0.448000 +-0.050000 -0.351500 -0.336900 0.024000 -0.576000 -0.808000 +-0.050000 -0.351500 -0.336900 0.024000 -0.576000 -0.808000 +0.050000 -0.050200 -0.279200 0.280000 0.320000 -0.896000 +0.050000 -0.050200 -0.279200 0.280000 0.320000 -0.896000 +0.004800 -0.050200 -0.304800 0.368000 0.176000 -0.904000 +0.050000 -0.100400 -0.298100 0.360000 0.248000 -0.896000 +0.039400 -0.100400 -0.304800 0.408000 0.224000 -0.880000 +0.039400 -0.100400 -0.304800 0.408000 0.224000 -0.880000 +0.113100 0.000000 -0.243900 -0.392000 0.768000 -0.496000 +0.113100 0.000000 -0.243900 -0.392000 0.768000 -0.496000 +0.150000 0.000000 -0.257100 -0.208000 0.552000 -0.800000 +0.150000 0.015400 -0.243900 -0.208000 0.728000 -0.640000 +0.150000 0.015400 -0.243900 -0.208000 0.728000 -0.640000 +0.200000 -0.100400 -0.298900 0.088000 0.040000 -0.992000 +0.200000 -0.100400 -0.298900 0.088000 0.040000 -0.992000 +0.185500 -0.100400 -0.304800 0.296000 0.104000 -0.944000 +0.200000 -0.139100 -0.304800 0.208000 0.104000 -0.968000 +0.150000 -0.100400 -0.322200 0.000000 0.224000 -0.968000 +0.200000 -0.150600 -0.306400 0.192000 0.112000 -0.968000 +0.150000 -0.150600 -0.323600 -0.232000 0.464000 -0.848000 +0.200000 -0.200800 -0.335700 -0.120000 0.200000 -0.968000 +0.150000 -0.200800 -0.325200 0.160000 0.176000 -0.968000 +0.200000 -0.251000 -0.346500 -0.184000 0.088000 -0.976000 +0.150000 -0.251000 -0.336000 0.080000 -0.336000 -0.928000 +0.150000 -0.251000 -0.336000 0.080000 -0.336000 -0.928000 +0.211400 -0.050200 -0.304800 0.152000 0.184000 -0.968000 +0.211400 -0.050200 -0.304800 0.152000 0.184000 -0.968000 +0.200000 -0.061600 -0.304800 0.000000 -0.144000 -0.984000 +0.250000 -0.050200 -0.297000 0.000000 0.040000 -0.992000 +0.200000 -0.100400 -0.298900 0.088000 0.040000 -0.992000 +0.250000 -0.100400 -0.298400 -0.088000 0.216000 -0.968000 +0.200000 -0.139100 -0.304800 0.208000 0.104000 -0.968000 +0.250000 -0.114900 -0.304800 -0.104000 0.280000 -0.952000 +0.200000 -0.150600 -0.306400 0.192000 0.112000 -0.968000 +0.250000 -0.150600 -0.317700 0.024000 0.336000 -0.936000 +0.200000 -0.200800 -0.335700 -0.120000 0.200000 -0.968000 +0.250000 -0.200800 -0.343100 0.104000 0.232000 -0.960000 +0.200000 -0.251000 -0.346500 -0.184000 0.088000 -0.976000 +0.250000 -0.251000 -0.353900 0.064000 0.384000 -0.920000 +0.250000 -0.251000 -0.353900 0.064000 0.384000 -0.920000 +0.250000 -0.050200 -0.297000 0.000000 0.040000 -0.992000 +0.250000 -0.050200 -0.297000 0.000000 0.040000 -0.992000 +0.266500 -0.050200 -0.304800 -0.280000 0.064000 -0.952000 +0.250000 -0.100400 -0.298400 -0.088000 0.216000 -0.968000 +0.278900 -0.100400 -0.304800 -0.176000 0.256000 -0.944000 +0.250000 -0.114900 -0.304800 -0.104000 0.280000 -0.952000 +0.250000 -0.114900 -0.304800 -0.104000 0.280000 -0.952000 +0.350000 -0.127600 -0.304800 0.032000 -0.600000 -0.792000 +0.350000 -0.127600 -0.304800 0.032000 -0.600000 -0.792000 +0.313400 -0.150600 -0.304800 0.400000 -0.360000 -0.840000 +0.350000 -0.150600 -0.283600 -0.064000 -0.424000 -0.896000 +0.320800 -0.200800 -0.304800 0.496000 0.328000 -0.800000 +0.350000 -0.200800 -0.271400 0.216000 0.224000 -0.944000 +0.350000 -0.228300 -0.304800 0.616000 0.528000 -0.576000 +0.350000 -0.228300 -0.304800 0.616000 0.528000 -0.576000 +0.300000 -0.357600 -0.243900 -0.288000 -0.920000 0.248000 +0.300000 -0.357600 -0.243900 -0.288000 -0.920000 0.248000 +0.343800 -0.401700 -0.243900 -0.728000 -0.584000 0.344000 +0.300000 -0.355300 -0.304800 -0.272000 -0.752000 -0.592000 +0.344100 -0.401700 -0.304800 -0.784000 -0.512000 -0.336000 +0.344100 -0.401700 -0.304800 -0.784000 -0.512000 -0.336000 +0.350000 -0.127600 -0.304800 0.032000 -0.600000 -0.792000 +0.350000 -0.127600 -0.304800 0.032000 -0.600000 -0.792000 +0.350000 -0.150600 -0.283600 -0.064000 -0.424000 -0.896000 +0.380400 -0.150600 -0.304800 -0.424000 -0.456000 -0.776000 +0.380400 -0.150600 -0.304800 -0.424000 -0.456000 -0.776000 +0.419200 0.050200 -0.304800 -0.224000 0.736000 -0.632000 +0.419200 0.050200 -0.304800 -0.224000 0.736000 -0.632000 +0.400000 0.050200 -0.294000 -0.352000 0.672000 -0.640000 +0.400000 0.041200 -0.304800 -0.352000 0.672000 -0.648000 +0.400000 0.041200 -0.304800 -0.352000 0.672000 -0.648000 +0.400000 -0.168700 -0.304800 -0.504000 -0.464000 -0.720000 +0.400000 -0.168700 -0.304800 -0.504000 -0.464000 -0.720000 +0.400000 -0.200800 -0.276700 0.448000 -0.472000 -0.752000 +0.424400 -0.200800 -0.304800 -0.552000 -0.520000 -0.648000 +0.400000 -0.249400 -0.243900 0.760000 -0.472000 -0.424000 +0.450000 -0.217600 -0.304800 -0.352000 -0.736000 -0.560000 +0.450000 -0.248400 -0.243900 -0.224000 -0.888000 -0.384000 +0.450000 -0.248400 -0.243900 -0.224000 -0.888000 -0.384000 +0.550000 -0.150600 -0.287800 0.352000 0.528000 -0.768000 +0.550000 -0.150600 -0.287800 0.352000 0.528000 -0.768000 +0.523400 -0.150600 -0.304800 0.376000 0.592000 -0.704000 +0.550000 -0.162200 -0.304800 0.376000 0.720000 -0.576000 +0.500000 -0.150600 -0.319100 0.336000 0.504000 -0.792000 +0.550000 -0.194000 -0.365800 0.224000 0.896000 -0.368000 +0.500000 -0.200800 -0.334200 -0.376000 -0.448000 -0.800000 +0.535800 -0.200800 -0.365800 -0.736000 0.208000 -0.632000 +0.500000 -0.222600 -0.304800 -0.320000 -0.704000 -0.624000 +0.550000 -0.216200 -0.365800 -0.080000 -0.576000 -0.808000 +0.535300 -0.251000 -0.304800 -0.648000 -0.480000 -0.576000 +0.550000 -0.251000 -0.326800 -0.648000 -0.504000 -0.560000 +0.550000 -0.216200 -0.365800 -0.080000 -0.576000 -0.808000 +0.573000 -0.251000 -0.365800 -0.696000 0.544000 -0.464000 +0.559600 -0.200800 -0.365800 0.680000 0.504000 -0.520000 +0.600000 -0.231600 -0.365800 0.072000 0.640000 -0.760000 +0.594200 -0.200800 -0.304800 0.544000 0.576000 -0.600000 +0.600000 -0.206100 -0.304800 0.488000 0.616000 -0.608000 +0.600000 -0.200800 -0.298700 0.448000 0.592000 -0.656000 +0.650000 -0.208600 -0.304800 0.024000 0.680000 -0.728000 +0.650000 -0.200800 -0.297000 0.088000 0.616000 -0.776000 +0.600000 -0.200800 -0.298700 0.448000 0.592000 -0.656000 +0.650000 -0.150600 -0.274900 0.544000 0.464000 -0.688000 +0.600000 -0.150600 -0.265200 0.248000 0.032000 -0.960000 +0.600000 -0.200800 -0.298700 0.448000 0.592000 -0.656000 +0.550000 -0.150600 -0.287800 0.352000 0.528000 -0.768000 +0.594200 -0.200800 -0.304800 0.544000 0.576000 -0.600000 +0.550000 -0.162200 -0.304800 0.376000 0.720000 -0.576000 +0.559600 -0.200800 -0.365800 0.680000 0.504000 -0.520000 +0.550000 -0.194000 -0.365800 0.224000 0.896000 -0.368000 +0.550000 -0.200800 -0.388300 0.280000 0.584000 -0.752000 +0.535800 -0.200800 -0.365800 -0.736000 0.208000 -0.632000 +0.550000 -0.216200 -0.365800 -0.080000 -0.576000 -0.808000 +0.550000 -0.200800 -0.388300 0.280000 0.584000 -0.752000 +0.559600 -0.200800 -0.365800 0.680000 0.504000 -0.520000 +0.559600 -0.200800 -0.365800 0.680000 0.504000 -0.520000 +0.500000 -0.222600 -0.304800 -0.320000 -0.704000 -0.624000 +0.500000 -0.222600 -0.304800 -0.320000 -0.704000 -0.624000 +0.500000 -0.251000 -0.264200 -0.272000 -0.744000 -0.600000 +0.535300 -0.251000 -0.304800 -0.648000 -0.480000 -0.576000 +0.535300 -0.251000 -0.304800 -0.648000 -0.480000 -0.576000 +0.800000 -0.401700 -0.291400 0.440000 0.456000 -0.760000 +0.800000 -0.401700 -0.291400 0.440000 0.456000 -0.760000 +0.800000 -0.418300 -0.304800 0.408000 0.496000 -0.760000 +0.850000 -0.401700 -0.268600 0.504000 0.432000 -0.744000 +0.837100 -0.451900 -0.304800 0.528000 0.264000 -0.800000 +0.850000 -0.451900 -0.293100 0.448000 0.248000 -0.848000 +0.800000 -0.493800 -0.304800 0.032000 -0.688000 -0.720000 +0.850000 -0.490600 -0.304800 0.216000 0.112000 -0.968000 +0.800000 -0.502100 -0.293400 -0.120000 -0.840000 -0.520000 +0.832800 -0.502100 -0.304800 -0.104000 -0.544000 -0.824000 +0.832800 -0.502100 -0.304800 -0.104000 -0.544000 -0.824000 +0.858900 0.050200 -0.243900 -0.424000 0.568000 -0.696000 +0.858900 0.050200 -0.243900 -0.424000 0.568000 -0.696000 +0.900000 0.050200 -0.268900 0.208000 0.672000 -0.696000 +0.900000 0.070800 -0.243900 -0.096000 0.744000 -0.656000 +0.900000 0.070800 -0.243900 -0.096000 0.744000 -0.656000 +0.981700 -0.050200 -0.304800 0.528000 0.432000 -0.720000 +0.981700 -0.050200 -0.304800 0.528000 0.432000 -0.720000 +1.000000 -0.073100 -0.304800 0.536000 0.424000 -0.720000 +1.000000 -0.050200 -0.288900 0.520000 0.432000 -0.728000 +1.000000 -0.050200 -0.288900 0.520000 0.432000 -0.728000 +-0.900000 0.104600 -0.304800 0.304000 0.568000 -0.760000 +-0.900000 0.104600 -0.304800 0.304000 0.568000 -0.760000 +-0.900000 0.100400 -0.308600 0.312000 0.536000 -0.776000 +-0.892300 0.100400 -0.304800 0.320000 0.536000 -0.776000 +-0.892300 0.100400 -0.304800 0.320000 0.536000 -0.776000 +-0.850000 -0.301200 -0.321900 -0.728000 -0.616000 -0.280000 +-0.850000 -0.301200 -0.321900 -0.728000 -0.616000 -0.280000 +-0.850000 -0.251000 -0.359600 -0.320000 0.248000 -0.912000 +-0.826000 -0.301200 -0.365800 -0.648000 -0.448000 -0.600000 +-0.828000 -0.251000 -0.365800 -0.248000 0.216000 -0.936000 +-0.800000 -0.301200 -0.380800 -0.264000 0.104000 -0.952000 +-0.800000 -0.251000 -0.370300 -0.064000 0.200000 -0.976000 +-0.750000 -0.301200 -0.392900 -0.104000 0.352000 -0.928000 +-0.750000 -0.251000 -0.369800 0.056000 0.280000 -0.952000 +-0.750000 -0.251000 -0.369800 0.056000 0.280000 -0.952000 +-0.800000 -0.066700 -0.304800 0.296000 0.144000 -0.936000 +-0.800000 -0.066700 -0.304800 0.296000 0.144000 -0.936000 +-0.800000 -0.100400 -0.313000 0.368000 0.216000 -0.896000 +-0.785000 -0.100400 -0.304800 0.328000 0.224000 -0.912000 +-0.785000 -0.100400 -0.304800 0.328000 0.224000 -0.912000 +-0.750000 -0.129200 -0.304800 0.392000 0.376000 -0.832000 +-0.750000 -0.129200 -0.304800 0.392000 0.376000 -0.832000 +-0.750000 -0.150600 -0.317800 0.416000 0.384000 -0.816000 +-0.731900 -0.150600 -0.304800 0.424000 0.400000 -0.808000 +-0.731900 -0.150600 -0.304800 0.424000 0.400000 -0.808000 +-0.576800 -0.251000 -0.365800 -0.136000 0.624000 -0.760000 +-0.576800 -0.251000 -0.365800 -0.136000 0.624000 -0.760000 +-0.600000 -0.251000 -0.360600 -0.120000 0.624000 -0.760000 +-0.600000 -0.256300 -0.365800 -0.112000 0.608000 -0.776000 +-0.600000 -0.256300 -0.365800 -0.112000 0.608000 -0.776000 +-0.500000 -0.637800 -0.304800 -0.208000 -0.976000 -0.032000 +-0.500000 -0.637800 -0.304800 -0.208000 -0.976000 -0.032000 +-0.455200 -0.652700 -0.304800 -0.280000 -0.952000 0.040000 +-0.500000 -0.633000 -0.365800 -0.088000 -0.968000 -0.200000 +-0.450000 -0.652700 -0.319500 -0.256000 -0.952000 -0.136000 +-0.450000 -0.645700 -0.365800 -0.144000 -0.904000 -0.392000 +-0.405700 -0.652700 -0.365800 -0.144000 -0.920000 -0.344000 +-0.405700 -0.652700 -0.365800 -0.144000 -0.920000 -0.344000 +-0.350000 -0.585900 -0.365800 0.168000 -0.792000 -0.576000 +-0.350000 -0.585900 -0.365800 0.168000 -0.792000 -0.576000 +-0.350000 -0.594300 -0.304800 0.520000 -0.800000 0.280000 +-0.357100 -0.602500 -0.365800 0.904000 0.256000 -0.312000 +-0.351600 -0.602500 -0.304800 0.944000 0.304000 0.024000 +-0.350000 -0.629600 -0.365800 0.056000 0.640000 -0.760000 +-0.350000 -0.605300 -0.304800 0.248000 0.960000 -0.032000 +-0.328400 -0.602500 -0.365800 -0.832000 -0.248000 -0.488000 +-0.344900 -0.602500 -0.304800 -0.744000 0.664000 -0.032000 +-0.350000 -0.585900 -0.365800 0.168000 -0.792000 -0.576000 +-0.350000 -0.594300 -0.304800 0.520000 -0.800000 0.280000 +-0.350000 -0.594300 -0.304800 0.520000 -0.800000 0.280000 +-0.350000 -0.747900 -0.304800 -0.512000 -0.832000 -0.184000 +-0.350000 -0.747900 -0.304800 -0.512000 -0.832000 -0.184000 +-0.350000 -0.703000 -0.357000 -0.336000 -0.496000 -0.792000 +-0.371300 -0.703000 -0.304800 -0.816000 -0.552000 -0.144000 +-0.371300 -0.703000 -0.304800 -0.816000 -0.552000 -0.144000 +-0.331500 -0.150600 -0.304800 -0.256000 0.464000 -0.840000 +-0.331500 -0.150600 -0.304800 -0.256000 0.464000 -0.840000 +-0.300000 -0.150600 -0.319300 -0.256000 0.480000 -0.832000 +-0.300000 -0.118900 -0.304800 -0.376000 0.264000 -0.880000 +-0.300000 -0.118900 -0.304800 -0.376000 0.264000 -0.880000 +-0.250000 -0.639500 -0.365800 0.216000 -0.224000 -0.944000 +-0.250000 -0.639500 -0.365800 0.216000 -0.224000 -0.944000 +-0.282800 -0.652700 -0.365800 0.080000 -0.160000 -0.976000 +-0.250000 -0.652700 -0.361600 0.240000 -0.216000 -0.944000 +-0.250000 -0.652700 -0.361600 0.240000 -0.216000 -0.944000 +-0.250000 -0.150600 -0.327500 -0.120000 0.152000 -0.976000 +-0.250000 -0.150600 -0.327500 -0.120000 0.152000 -0.976000 +-0.200000 -0.150600 -0.333300 0.216000 -0.272000 -0.936000 +-0.250000 -0.200800 -0.333200 0.168000 0.080000 -0.976000 +-0.200000 -0.200800 -0.306700 0.368000 -0.184000 -0.904000 +-0.250000 -0.251000 -0.337900 0.384000 0.112000 -0.912000 +-0.200000 -0.251000 -0.307600 0.408000 0.096000 -0.904000 +-0.250000 -0.301200 -0.349000 0.296000 0.272000 -0.912000 +-0.200000 -0.301200 -0.313400 0.328000 0.152000 -0.928000 +-0.200000 -0.301200 -0.313400 0.328000 0.152000 -0.928000 +-0.200000 -0.602500 -0.345500 0.488000 -0.272000 -0.824000 +-0.200000 -0.602500 -0.345500 0.488000 -0.272000 -0.824000 +-0.200000 -0.558000 -0.365800 0.448000 -0.240000 -0.856000 +-0.229500 -0.602500 -0.365800 0.408000 -0.240000 -0.872000 +-0.200000 -0.552300 -0.367100 0.360000 -0.232000 -0.896000 +-0.250000 -0.602500 -0.376000 0.360000 -0.328000 -0.872000 +-0.250000 -0.552300 -0.402600 0.504000 -0.312000 -0.792000 +-0.250000 -0.552300 -0.402600 0.504000 -0.312000 -0.792000 +-0.150000 -0.602500 -0.307600 0.456000 -0.280000 -0.840000 +-0.150000 -0.602500 -0.307600 0.456000 -0.280000 -0.840000 +-0.150000 -0.552300 -0.337600 0.424000 -0.304000 -0.840000 +-0.200000 -0.602500 -0.345500 0.488000 -0.272000 -0.824000 +-0.196100 -0.552300 -0.365800 0.320000 -0.272000 -0.904000 +-0.200000 -0.558000 -0.365800 0.448000 -0.240000 -0.856000 +-0.200000 -0.552300 -0.367100 0.360000 -0.232000 -0.896000 +-0.200000 -0.552300 -0.367100 0.360000 -0.232000 -0.896000 +-0.147100 -0.502100 -0.365800 0.472000 -0.192000 -0.848000 +-0.147100 -0.502100 -0.365800 0.472000 -0.192000 -0.848000 +-0.145700 -0.451900 -0.365800 0.464000 0.040000 -0.880000 +-0.100000 -0.502100 -0.325200 0.520000 -0.368000 -0.760000 +-0.100000 -0.451900 -0.336100 0.496000 -0.048000 -0.856000 +-0.074100 -0.502100 -0.304800 0.864000 -0.480000 0.112000 +-0.061500 -0.451900 -0.304800 0.928000 -0.352000 0.088000 +-0.061500 -0.451900 -0.304800 0.928000 -0.352000 0.088000 +-0.100000 -0.200800 -0.311700 -0.496000 0.128000 -0.856000 +-0.100000 -0.200800 -0.311700 -0.496000 0.128000 -0.856000 +-0.050000 -0.200800 -0.320900 -0.056000 0.280000 -0.952000 +-0.100000 -0.251000 -0.333700 -0.512000 0.248000 -0.816000 +-0.050000 -0.251000 -0.364300 -0.216000 0.352000 -0.904000 +-0.100000 -0.301200 -0.349000 -0.368000 0.264000 -0.888000 +-0.050000 -0.266900 -0.365800 -0.288000 0.088000 -0.944000 +-0.058500 -0.301200 -0.365800 -0.384000 -0.288000 -0.872000 +-0.050000 -0.301200 -0.370400 -0.392000 -0.264000 -0.872000 +-0.050000 -0.309800 -0.365800 -0.336000 -0.416000 -0.840000 +-0.058500 -0.301200 -0.365800 -0.384000 -0.288000 -0.872000 +-0.050000 -0.351500 -0.336900 0.024000 -0.576000 -0.808000 +-0.100000 -0.301200 -0.349000 -0.368000 0.264000 -0.888000 +-0.100000 -0.351500 -0.338800 0.024000 -0.312000 -0.944000 +-0.100000 -0.351500 -0.338800 0.024000 -0.312000 -0.944000 +0.050000 -0.119800 -0.304800 0.416000 0.264000 -0.864000 +0.050000 -0.119800 -0.304800 0.416000 0.264000 -0.864000 +0.050000 -0.150600 -0.318000 0.352000 0.312000 -0.872000 +0.096000 -0.150600 -0.304800 0.176000 0.336000 -0.920000 +0.096000 -0.150600 -0.304800 0.176000 0.336000 -0.920000 +0.301400 0.000000 -0.304800 -0.584000 0.656000 -0.464000 +0.301400 0.000000 -0.304800 -0.584000 0.656000 -0.464000 +0.350000 0.000000 -0.339100 -0.264000 0.552000 -0.784000 +0.350000 0.024300 -0.304800 -0.456000 0.784000 -0.408000 +0.400000 0.000000 -0.343200 -0.216000 0.592000 -0.768000 +0.400000 0.041200 -0.304800 -0.352000 0.672000 -0.648000 +0.400000 0.041200 -0.304800 -0.352000 0.672000 -0.648000 +0.383500 -0.050200 -0.365800 0.200000 -0.288000 -0.928000 +0.383500 -0.050200 -0.365800 0.200000 -0.288000 -0.928000 +0.400000 -0.050200 -0.360800 0.184000 -0.432000 -0.872000 +0.350000 -0.037900 -0.365800 -0.440000 0.432000 -0.776000 +0.400000 0.000000 -0.343200 -0.216000 0.592000 -0.768000 +0.350000 0.000000 -0.339100 -0.264000 0.552000 -0.784000 +0.350000 0.000000 -0.339100 -0.264000 0.552000 -0.784000 +0.355700 -0.351500 -0.365800 0.360000 -0.072000 -0.928000 +0.355700 -0.351500 -0.365800 0.360000 -0.072000 -0.928000 +0.400000 -0.351500 -0.338800 0.360000 -0.568000 -0.728000 +0.350000 -0.334300 -0.365800 -0.304000 0.096000 -0.944000 +0.400000 -0.301200 -0.307300 0.704000 0.496000 -0.496000 +0.350000 -0.301200 -0.360500 0.376000 0.184000 -0.904000 +0.350000 -0.301200 -0.360500 0.376000 0.184000 -0.904000 +0.376800 -0.401700 -0.304800 0.336000 -0.848000 -0.392000 +0.376800 -0.401700 -0.304800 0.336000 -0.848000 -0.392000 +0.350000 -0.401700 -0.317400 -0.608000 -0.560000 -0.544000 +0.350000 -0.410700 -0.304800 -0.592000 -0.664000 -0.440000 +0.350000 -0.410700 -0.304800 -0.592000 -0.664000 -0.440000 +0.400000 -0.050200 -0.360800 0.184000 -0.432000 -0.872000 +0.400000 -0.050200 -0.360800 0.184000 -0.432000 -0.872000 +0.450000 -0.050200 -0.325200 -0.120000 -0.568000 -0.808000 +0.400000 -0.100400 -0.340000 -0.040000 -0.360000 -0.928000 +0.450000 -0.100400 -0.322200 0.392000 -0.360000 -0.840000 +0.400000 -0.150600 -0.318400 -0.432000 -0.416000 -0.792000 +0.450000 -0.150600 -0.321300 -0.008000 0.120000 -0.992000 +0.400000 -0.168700 -0.304800 -0.504000 -0.464000 -0.720000 +0.450000 -0.200800 -0.331300 -0.472000 -0.400000 -0.776000 +0.424400 -0.200800 -0.304800 -0.552000 -0.520000 -0.648000 +0.450000 -0.217600 -0.304800 -0.352000 -0.736000 -0.560000 +0.450000 -0.217600 -0.304800 -0.352000 -0.736000 -0.560000 +0.450000 0.055500 -0.304800 0.064000 0.864000 -0.496000 +0.450000 0.055500 -0.304800 0.064000 0.864000 -0.496000 +0.450000 0.050200 -0.314200 0.064000 0.744000 -0.656000 +0.496000 0.050200 -0.304800 0.104000 0.800000 -0.576000 +0.496000 0.050200 -0.304800 0.104000 0.800000 -0.576000 +0.500000 -0.333600 -0.304800 -0.408000 0.824000 -0.376000 +0.500000 -0.333600 -0.304800 -0.408000 0.824000 -0.376000 +0.458900 -0.351500 -0.304800 -0.472000 0.360000 -0.792000 +0.500000 -0.351500 -0.354900 -0.384000 -0.472000 -0.784000 +0.500000 -0.400200 -0.304800 -0.176000 -0.672000 -0.712000 +0.500000 -0.400200 -0.304800 -0.176000 -0.672000 -0.712000 +0.450000 -0.380500 -0.304800 -0.144000 0.256000 -0.952000 +0.450000 -0.380500 -0.304800 -0.144000 0.256000 -0.952000 +0.450000 -0.401700 -0.316200 -0.184000 -0.360000 -0.904000 +0.492100 -0.401700 -0.304800 0.152000 -0.576000 -0.792000 +0.492100 -0.401700 -0.304800 0.152000 -0.576000 -0.792000 +0.500000 -0.127100 -0.304800 0.480000 0.456000 -0.744000 +0.500000 -0.127100 -0.304800 0.480000 0.456000 -0.744000 +0.500000 -0.150600 -0.319100 0.336000 0.504000 -0.792000 +0.523400 -0.150600 -0.304800 0.376000 0.592000 -0.704000 +0.523400 -0.150600 -0.304800 0.376000 0.592000 -0.704000 +0.600000 -0.086300 -0.304800 0.440000 0.312000 -0.832000 +0.600000 -0.086300 -0.304800 0.440000 0.312000 -0.832000 +0.589400 -0.100400 -0.304800 -0.440000 -0.424000 -0.784000 +0.600000 -0.100400 -0.312700 0.376000 -0.472000 -0.792000 +0.600000 -0.105700 -0.304800 0.312000 -0.728000 -0.600000 +0.604900 -0.100400 -0.304800 0.744000 -0.360000 -0.552000 +0.600000 -0.100400 -0.312700 0.376000 -0.472000 -0.792000 +0.600000 -0.086300 -0.304800 0.440000 0.312000 -0.832000 +0.600000 -0.086300 -0.304800 0.440000 0.312000 -0.832000 +0.600000 -0.206100 -0.304800 0.488000 0.616000 -0.608000 +0.600000 -0.206100 -0.304800 0.488000 0.616000 -0.608000 +0.650000 -0.208600 -0.304800 0.024000 0.680000 -0.728000 +0.600000 -0.231600 -0.365800 0.072000 0.640000 -0.760000 +0.650000 -0.245700 -0.365800 0.168000 0.856000 -0.480000 +0.600000 -0.249700 -0.426800 -0.344000 0.872000 -0.328000 +0.650000 -0.251000 -0.378600 0.328000 0.752000 -0.560000 +0.604800 -0.251000 -0.426800 0.544000 0.248000 -0.792000 +0.650000 -0.267900 -0.365800 0.280000 -0.440000 -0.848000 +0.600000 -0.252700 -0.426800 -0.416000 -0.736000 -0.520000 +0.600000 -0.288400 -0.365800 -0.376000 -0.712000 -0.584000 +0.598300 -0.251000 -0.426800 -0.848000 0.144000 -0.496000 +0.573000 -0.251000 -0.365800 -0.696000 0.544000 -0.464000 +0.600000 -0.249700 -0.426800 -0.344000 0.872000 -0.328000 +0.600000 -0.231600 -0.365800 0.072000 0.640000 -0.760000 +0.600000 -0.231600 -0.365800 0.072000 0.640000 -0.760000 +0.700000 -0.211400 -0.304800 0.288000 0.624000 -0.720000 +0.700000 -0.211400 -0.304800 0.288000 0.624000 -0.720000 +0.700000 -0.251000 -0.357800 0.296000 0.496000 -0.808000 +0.728900 -0.251000 -0.304800 0.720000 0.440000 -0.528000 +0.700000 -0.301200 -0.354900 0.160000 -0.240000 -0.952000 +0.744500 -0.301200 -0.304800 0.640000 0.104000 -0.760000 +0.744500 -0.301200 -0.304800 0.640000 0.104000 -0.760000 +0.750000 -0.334300 -0.304800 0.512000 0.112000 -0.840000 +0.750000 -0.334300 -0.304800 0.512000 0.112000 -0.840000 +0.750000 -0.351500 -0.307800 0.512000 0.128000 -0.840000 +0.754800 -0.351500 -0.304800 0.424000 0.136000 -0.888000 +0.750000 -0.401700 -0.321600 0.336000 0.000000 -0.936000 +0.779200 -0.401700 -0.304800 0.400000 0.336000 -0.848000 +0.779200 -0.401700 -0.304800 0.400000 0.336000 -0.848000 +0.800000 -0.418300 -0.304800 0.408000 0.496000 -0.760000 +0.800000 -0.418300 -0.304800 0.408000 0.496000 -0.760000 +0.800000 -0.451900 -0.330300 0.328000 0.200000 -0.920000 +0.837100 -0.451900 -0.304800 0.528000 0.264000 -0.800000 +0.800000 -0.493800 -0.304800 0.032000 -0.688000 -0.720000 +0.800000 -0.493800 -0.304800 0.032000 -0.688000 -0.720000 +0.856800 -0.502100 -0.304800 0.288000 0.144000 -0.944000 +0.856800 -0.502100 -0.304800 0.288000 0.144000 -0.944000 +0.850000 -0.502100 -0.307100 0.032000 -0.240000 -0.968000 +0.850000 -0.504700 -0.304800 -0.096000 -0.664000 -0.736000 +0.850000 -0.504700 -0.304800 -0.096000 -0.664000 -0.736000 +0.900000 0.016700 -0.304800 -0.152000 0.720000 -0.664000 +0.900000 0.016700 -0.304800 -0.152000 0.720000 -0.664000 +0.900000 0.000000 -0.329500 -0.080000 0.648000 -0.744000 +0.927400 0.000000 -0.304800 0.400000 0.560000 -0.720000 +0.927400 0.000000 -0.304800 0.400000 0.560000 -0.720000 +-0.850000 -0.496800 -0.365800 -0.176000 0.616000 -0.760000 +-0.850000 -0.496800 -0.365800 -0.176000 0.616000 -0.760000 +-0.864000 -0.502100 -0.365800 -0.304000 0.480000 -0.816000 +-0.850000 -0.502100 -0.370900 -0.184000 0.560000 -0.800000 +-0.860100 -0.552300 -0.365800 -0.680000 -0.432000 -0.584000 +-0.850000 -0.552300 -0.378600 -0.568000 -0.344000 -0.736000 +-0.850000 -0.564700 -0.365800 -0.608000 -0.528000 -0.584000 +-0.800000 -0.552300 -0.401000 -0.552000 -0.288000 -0.776000 +-0.806700 -0.602500 -0.365800 -0.520000 -0.656000 -0.536000 +-0.800000 -0.602500 -0.372400 -0.488000 -0.592000 -0.624000 +-0.800000 -0.607700 -0.365800 -0.488000 -0.640000 -0.584000 +-0.750000 -0.602500 -0.401000 -0.336000 -0.696000 -0.624000 +-0.750000 -0.628000 -0.365800 -0.232000 -0.808000 -0.528000 +-0.714100 -0.602500 -0.426800 -0.368000 -0.680000 -0.624000 +-0.700000 -0.639000 -0.365800 -0.040000 -0.920000 -0.376000 +-0.700000 -0.609100 -0.426800 -0.336000 -0.744000 -0.568000 +-0.650000 -0.641900 -0.365800 -0.024000 -0.952000 -0.280000 +-0.650000 -0.621300 -0.426800 -0.080000 -0.904000 -0.400000 +-0.650000 -0.621300 -0.426800 -0.080000 -0.904000 -0.400000 +-0.850000 -0.496800 -0.365800 -0.176000 0.616000 -0.760000 +-0.850000 -0.496800 -0.365800 -0.176000 0.616000 -0.760000 +-0.800000 -0.496400 -0.365800 -0.664000 0.416000 -0.608000 +-0.850000 -0.502100 -0.370900 -0.184000 0.560000 -0.800000 +-0.800000 -0.502100 -0.369300 -0.768000 0.256000 -0.576000 +-0.850000 -0.552300 -0.378600 -0.568000 -0.344000 -0.736000 +-0.800000 -0.552300 -0.401000 -0.552000 -0.288000 -0.776000 +-0.800000 -0.502100 -0.369300 -0.768000 0.256000 -0.576000 +-0.750000 -0.552300 -0.422100 -0.552000 -0.096000 -0.824000 +-0.750000 -0.502100 -0.424900 -0.848000 -0.112000 -0.512000 +-0.744500 -0.552300 -0.426800 -0.560000 -0.080000 -0.816000 +-0.748800 -0.502100 -0.426800 -0.584000 -0.048000 -0.800000 +-0.750000 -0.502100 -0.424900 -0.848000 -0.112000 -0.512000 +-0.750000 -0.498100 -0.426800 -0.864000 -0.184000 -0.448000 +-0.800000 -0.502100 -0.369300 -0.768000 0.256000 -0.576000 +-0.764100 -0.451900 -0.426800 -0.880000 -0.256000 -0.384000 +-0.800000 -0.496400 -0.365800 -0.664000 0.416000 -0.608000 +-0.786000 -0.451900 -0.365800 -0.872000 0.080000 -0.472000 +-0.764100 -0.451900 -0.426800 -0.880000 -0.256000 -0.384000 +-0.796500 -0.401700 -0.365800 -0.952000 -0.168000 -0.232000 +-0.777800 -0.401700 -0.426800 -0.928000 0.040000 -0.360000 +-0.777800 -0.401700 -0.426800 -0.928000 0.040000 -0.360000 +-0.800000 -0.602500 -0.372400 -0.488000 -0.592000 -0.624000 +-0.800000 -0.602500 -0.372400 -0.488000 -0.592000 -0.624000 +-0.800000 -0.552300 -0.401000 -0.552000 -0.288000 -0.776000 +-0.750000 -0.602500 -0.401000 -0.336000 -0.696000 -0.624000 +-0.750000 -0.552300 -0.422100 -0.552000 -0.096000 -0.824000 +-0.714100 -0.602500 -0.426800 -0.368000 -0.680000 -0.624000 +-0.744500 -0.552300 -0.426800 -0.560000 -0.080000 -0.816000 +-0.744500 -0.552300 -0.426800 -0.560000 -0.080000 -0.816000 +-0.350000 -0.248400 -0.365800 0.184000 0.424000 -0.880000 +-0.350000 -0.248400 -0.365800 0.184000 0.424000 -0.880000 +-0.350000 -0.251000 -0.367200 0.240000 0.168000 -0.952000 +-0.345700 -0.251000 -0.365800 0.320000 0.336000 -0.880000 +-0.345700 -0.251000 -0.365800 0.320000 0.336000 -0.880000 +-0.250000 -0.342900 -0.365800 0.504000 0.512000 -0.680000 +-0.250000 -0.342900 -0.365800 0.504000 0.512000 -0.680000 +-0.250000 -0.351500 -0.379700 0.552000 0.712000 -0.416000 +-0.241400 -0.351500 -0.365800 0.488000 0.640000 -0.576000 +-0.241400 -0.351500 -0.365800 0.488000 0.640000 -0.576000 +-0.200000 -0.365300 -0.365800 0.504000 0.768000 -0.376000 +-0.200000 -0.365300 -0.365800 0.504000 0.768000 -0.376000 +-0.200000 -0.393200 -0.426800 0.696000 0.632000 -0.328000 +-0.151700 -0.401700 -0.365800 0.568000 0.104000 -0.808000 +-0.194300 -0.401700 -0.426800 0.792000 0.416000 -0.432000 +-0.194300 -0.401700 -0.426800 0.792000 0.416000 -0.432000 +-0.044700 -0.251000 -0.365800 -0.216000 0.376000 -0.896000 +-0.044700 -0.251000 -0.365800 -0.216000 0.376000 -0.896000 +0.000000 -0.251000 -0.386300 -0.352000 0.496000 -0.792000 +0.000000 -0.238800 -0.365800 -0.192000 0.648000 -0.728000 +0.000000 -0.238800 -0.365800 -0.192000 0.648000 -0.728000 +0.100000 -0.224900 -0.365800 0.352000 0.456000 -0.808000 +0.100000 -0.224900 -0.365800 0.352000 0.456000 -0.808000 +0.100000 -0.251000 -0.380100 0.472000 -0.384000 -0.784000 +0.118000 -0.251000 -0.365800 0.536000 -0.224000 -0.808000 +0.100000 -0.263400 -0.365800 0.480000 -0.672000 -0.544000 +0.100000 -0.263400 -0.365800 0.480000 -0.672000 -0.544000 +0.350000 -0.354600 -0.365800 -0.264000 -0.632000 -0.720000 +0.350000 -0.354600 -0.365800 -0.264000 -0.632000 -0.720000 +0.350000 -0.351500 -0.368100 -0.440000 0.096000 -0.888000 +0.348000 -0.351500 -0.365800 -0.720000 -0.032000 -0.680000 +0.348000 -0.351500 -0.365800 -0.720000 -0.032000 -0.680000 +0.450000 0.007700 -0.365800 -0.264000 0.744000 -0.600000 +0.450000 0.007700 -0.365800 -0.264000 0.744000 -0.600000 +0.431500 0.000000 -0.365800 -0.424000 0.312000 -0.840000 +0.450000 0.000000 -0.377000 -0.360000 0.400000 -0.840000 +0.450000 -0.014200 -0.365800 -0.336000 -0.568000 -0.744000 +0.450000 -0.014200 -0.365800 -0.336000 -0.568000 -0.744000 +0.650000 -0.245700 -0.365800 0.168000 0.856000 -0.480000 +0.650000 -0.245700 -0.365800 0.168000 0.856000 -0.480000 +0.650000 -0.251000 -0.378600 0.328000 0.752000 -0.560000 +0.678000 -0.251000 -0.365800 0.264000 0.520000 -0.808000 +0.650000 -0.267900 -0.365800 0.280000 -0.440000 -0.848000 diff --git a/progs/demos/lodbias.c b/progs/demos/lodbias.c new file mode 100644 index 00000000000..a4db22e26e4 --- /dev/null +++ b/progs/demos/lodbias.c @@ -0,0 +1,282 @@ +/* + * 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 +#include +#include +#include +#include +#include + +#include "readtex.h" + +#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 = -400, BiasMax = 400; + + + +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 ) +{ + GLfloat maxBias; + + if (!glutExtensionSupported("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 (glutExtensionSupported("GL_SGIS_generate_mipmap")) { + /* test auto mipmap generation */ + GLint width, height, i; + GLenum format; + GLubyte *image = LoadRGBImage(TEXTURE_FILE, &width, &height, &format); + if (!image) { + printf("Error: could not load texture image %s\n", TEXTURE_FILE); + exit(1); + } + /* resize to 256 x 256 */ + if (width != 256 || height != 256) { + GLubyte *newImage = malloc(256 * 256 * 4); + gluScaleImage(format, width, height, GL_UNSIGNED_BYTE, image, + 256, 256, GL_UNSIGNED_BYTE, newImage); + free(image); + image = newImage; + } + printf("Using GL_SGIS_generate_mipmap\n"); + glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS, GL_TRUE); + glTexImage2D(GL_TEXTURE_2D, 0, format, 256, 256, 0, + format, GL_UNSIGNED_BYTE, image); + free(image); + + /* make sure mipmap was really generated correctly */ + width = height = 256; + for (i = 0; i < 9; i++) { + GLint w, h; + glGetTexLevelParameteriv(GL_TEXTURE_2D, i, GL_TEXTURE_WIDTH, &w); + glGetTexLevelParameteriv(GL_TEXTURE_2D, i, GL_TEXTURE_HEIGHT, &h); + printf("Level %d size: %d x %d\n", i, w, h); + assert(w == width); + assert(h == height); + width /= 2; + height /= 2; + } + + } + else 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); + + glGetFloatv(GL_MAX_TEXTURE_LOD_BIAS_EXT, &maxBias); + printf("LOD bias range: [%g, %g]\n", -maxBias, maxBias); + BiasMin = -100 * maxBias; + BiasMax = 100 * maxBias; + + /* Since we have (about) 8 mipmap levels, no need to bias beyond + * the range [-1, +8]. + */ + if (BiasMin < -100) + BiasMin = -100; + if (BiasMax > 800) + BiasMax = 800; +} + + +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; +} diff --git a/progs/demos/morph3d.c b/progs/demos/morph3d.c new file mode 100644 index 00000000000..162a6ff847e --- /dev/null +++ b/progs/demos/morph3d.c @@ -0,0 +1,896 @@ + +/*- + * morph3d.c - Shows 3D morphing objects + * + * Converted to GLUT by brianp on 1/1/98 + * + * This program was inspired on a WindowsNT(R)'s screen saver. It was written + * from scratch and it was not based on any other source code. + * + * Porting it to xlock (the final objective of this code since the moment I + * decided to create it) was possible by comparing the original Mesa's gear + * demo with it's ported version, so thanks for Danny Sung for his indirect + * help (look at gear.c in xlock source tree). NOTE: At the moment this code + * was sent to Brian Paul for package inclusion, the XLock Version was not + * available. In fact, I'll wait it to appear on the next Mesa release (If you + * are reading this, it means THIS release) to send it for xlock package + * inclusion). It will probably there be a GLUT version too. + * + * Thanks goes also to Brian Paul for making it possible and inexpensive + * to use OpenGL at home. + * + * Since I'm not a native english speaker, my apologies for any gramatical + * mistake. + * + * My e-mail addresses are + * + * vianna@cat.cbpf.br + * and + * marcelo@venus.rdc.puc-rio.br + * + * Marcelo F. Vianna (Feb-13-1997) + */ + +/* +This document is VERY incomplete, but tries to describe the mathematics used +in the program. At this moment it just describes how the polyhedra are +generated. On futhurer versions, this document will be probabbly improved. + +Since I'm not a native english speaker, my apologies for any gramatical +mistake. + +Marcelo Fernandes Vianna +- Undergraduate in Computer Engeneering at Catholic Pontifical University +- of Rio de Janeiro (PUC-Rio) Brasil. +- e-mail: vianna@cat.cbpf.br or marcelo@venus.rdc.puc-rio.br +- Feb-13-1997 + +POLYHEDRA GENERATION + +For the purpose of this program it's not sufficient to know the polyhedra +vertexes coordinates. Since the morphing algorithm applies a nonlinear +transformation over the surfaces (faces) of the polyhedron, each face has +to be divided into smaller ones. The morphing algorithm needs to transform +each vertex of these smaller faces individually. It's a very time consoming +task. + +In order to reduce calculation overload, and since all the macro faces of +the polyhedron are transformed by the same way, the generation is made by +creating only one face of the polyhedron, morphing it and then rotating it +around the polyhedron center. + +What we need to know is the face radius of the polyhedron (the radius of +the inscribed sphere) and the angle between the center of two adjacent +faces using the center of the sphere as the angle's vertex. + +The face radius of the regular polyhedra are known values which I decided +to not waste my time calculating. Following is a table of face radius for +the regular polyhedra with edge length = 1: + + TETRAHEDRON : 1/(2*sqrt(2))/sqrt(3) + CUBE : 1/2 + OCTAHEDRON : 1/sqrt(6) + DODECAHEDRON : T^2 * sqrt((T+2)/5) / 2 -> where T=(sqrt(5)+1)/2 + ICOSAHEDRON : (3*sqrt(3)+sqrt(15))/12 + +I've not found any reference about the mentioned angles, so I needed to +calculate them, not a trivial task until I figured out how :) +Curiously these angles are the same for the tetrahedron and octahedron. +A way to obtain this value is inscribing the tetrahedron inside the cube +by matching their vertexes. So you'll notice that the remaining unmatched +vertexes are in the same straight line starting in the cube/tetrahedron +center and crossing the center of each tetrahedron's face. At this point +it's easy to obtain the bigger angle of the isosceles triangle formed by +the center of the cube and two opposite vertexes on the same cube face. +The edges of this triangle have the following lenghts: sqrt(2) for the base +and sqrt(3)/2 for the other two other edges. So the angle we want is: + +-----------------------------------------------------------+ + | 2*ARCSIN(sqrt(2)/sqrt(3)) = 109.47122063449069174 degrees | + +-----------------------------------------------------------+ +For the cube this angle is obvious, but just for formality it can be +easily obtained because we also know it's isosceles edge lenghts: +sqrt(2)/2 for the base and 1/2 for the other two edges. So the angle we +want is: + +-----------------------------------------------------------+ + | 2*ARCSIN((sqrt(2)/2)/1) = 90.000000000000000000 degrees | + +-----------------------------------------------------------+ +For the octahedron we use the same idea used for the tetrahedron, but now +we inscribe the cube inside the octahedron so that all cubes's vertexes +matches excatly the center of each octahedron's face. It's now clear that +this angle is the same of the thetrahedron one: + +-----------------------------------------------------------+ + | 2*ARCSIN(sqrt(2)/sqrt(3)) = 109.47122063449069174 degrees | + +-----------------------------------------------------------+ +For the dodecahedron it's a little bit harder because it's only relationship +with the cube is useless to us. So we need to solve the problem by another +way. The concept of Face radius also exists on 2D polygons with the name +Edge radius: + Edge Radius For Pentagon (ERp) + ERp = (1/2)/TAN(36 degrees) * VRp = 0.6881909602355867905 + (VRp is the pentagon's vertex radio). + Face Radius For Dodecahedron + FRd = T^2 * sqrt((T+2)/5) / 2 = 1.1135163644116068404 +Why we need ERp? Well, ERp and FRd segments forms a 90 degrees angle, +completing this triangle, the lesser angle is a half of the angle we are +looking for, so this angle is: + +-----------------------------------------------------------+ + | 2*ARCTAN(ERp/FRd) = 63.434948822922009981 degrees | + +-----------------------------------------------------------+ +For the icosahedron we can use the same method used for dodecahedron (well +the method used for dodecahedron may be used for all regular polyhedra) + Edge Radius For Triangle (this one is well known: 1/3 of the triangle height) + ERt = sin(60)/3 = sqrt(3)/6 = 0.2886751345948128655 + Face Radius For Icosahedron + FRi= (3*sqrt(3)+sqrt(15))/12 = 0.7557613140761707538 +So the angle is: + +-----------------------------------------------------------+ + | 2*ARCTAN(ERt/FRi) = 41.810314895778596167 degrees | + +-----------------------------------------------------------+ + +*/ + + +#include +#include +#ifndef _WIN32 +#include +#endif +#include +#include +#include + +#define Scale 0.3 + +#define VectMul(X1,Y1,Z1,X2,Y2,Z2) (Y1)*(Z2)-(Z1)*(Y2),(Z1)*(X2)-(X1)*(Z2),(X1)*(Y2)-(Y1)*(X2) +#define sqr(A) ((A)*(A)) + +/* Increasing this values produces better image quality, the price is speed. */ +/* Very low values produces erroneous/incorrect plotting */ +#define tetradivisions 23 +#define cubedivisions 20 +#define octadivisions 21 +#define dodecadivisions 10 +#define icodivisions 15 + +#define tetraangle 109.47122063449069174 +#define cubeangle 90.000000000000000000 +#define octaangle 109.47122063449069174 +#define dodecaangle 63.434948822922009981 +#define icoangle 41.810314895778596167 + +#ifndef Pi +#define Pi 3.1415926535897932385 +#endif +#define SQRT2 1.4142135623730951455 +#define SQRT3 1.7320508075688771932 +#define SQRT5 2.2360679774997898051 +#define SQRT6 2.4494897427831778813 +#define SQRT15 3.8729833462074170214 +#define cossec36_2 0.8506508083520399322 +#define cos72 0.3090169943749474241 +#define sin72 0.9510565162951535721 +#define cos36 0.8090169943749474241 +#define sin36 0.5877852522924731292 + +/*************************************************************************/ + +static int mono=0; +static int smooth=1; +static int anim=1; +static GLint WindH, WindW; +static GLfloat step=0; +static GLfloat seno; +static int object; +static int edgedivisions; +static void (*draw_object)( void ); +static float Magnitude; +static float *MaterialColor[20]; + +static float front_shininess[] = {60.0}; +static float front_specular[] = { 0.7, 0.7, 0.7, 1.0 }; +static float ambient[] = { 0.0, 0.0, 0.0, 1.0 }; +static float diffuse[] = { 1.0, 1.0, 1.0, 1.0 }; +static float position0[] = { 1.0, 1.0, 1.0, 0.0 }; +static float position1[] = {-1.0,-1.0, 1.0, 0.0 }; +static float lmodel_ambient[] = { 0.5, 0.5, 0.5, 1.0 }; +static float lmodel_twoside[] = {GL_TRUE}; + +static float MaterialRed[] = { 0.7, 0.0, 0.0, 1.0 }; +static float MaterialGreen[] = { 0.1, 0.5, 0.2, 1.0 }; +static float MaterialBlue[] = { 0.0, 0.0, 0.7, 1.0 }; +static float MaterialCyan[] = { 0.2, 0.5, 0.7, 1.0 }; +static float MaterialYellow[] = { 0.7, 0.7, 0.0, 1.0 }; +static float MaterialMagenta[] = { 0.6, 0.2, 0.5, 1.0 }; +static float MaterialWhite[] = { 0.7, 0.7, 0.7, 1.0 }; +static float MaterialGray[] = { 0.2, 0.2, 0.2, 1.0 }; + +#define TRIANGLE(Edge, Amp, Divisions, Z) \ +{ \ + GLfloat Xf,Yf,Xa,Yb,Xf2,Yf2; \ + GLfloat Factor,Factor1,Factor2; \ + GLfloat VertX,VertY,VertZ,NeiAX,NeiAY,NeiAZ,NeiBX,NeiBY,NeiBZ; \ + GLfloat Ax,Ay,Bx; \ + int Ri,Ti; \ + GLfloat Vr=(Edge)*SQRT3/3; \ + GLfloat AmpVr2=(Amp)/sqr(Vr); \ + GLfloat Zf=(Edge)*(Z); \ + \ + Ax=(Edge)*(+0.5/(Divisions)), Ay=(Edge)*(-SQRT3/(2*Divisions)); \ + Bx=(Edge)*(-0.5/(Divisions)); \ + \ + for (Ri=1; Ri<=(Divisions); Ri++) { \ + glBegin(GL_TRIANGLE_STRIP); \ + for (Ti=0; Ti 2 texture units. + */ + + +#include +#include +#include +#include +#include + +#include "readtex.h" + +#define TEXTURE_1_FILE "../images/girl.rgb" +#define TEXTURE_2_FILE "../images/reflect.rgb" + +#define TEX0 1 +#define TEX7 8 +#define ANIMATE 10 +#define QUIT 100 + +static GLboolean Animate = GL_TRUE; +static GLint NumUnits = 1; +static GLboolean TexEnabled[8]; + +static GLfloat Drift = 0.0; +static GLfloat drift_increment = 0.005; +static GLfloat Xrot = 20.0, Yrot = 30.0, Zrot = 0.0; + + +static void Idle( void ) +{ + if (Animate) { + GLint i; + + Drift += drift_increment; + if (Drift >= 1.0) + Drift = 0.0; + + for (i = 0; i < NumUnits; i++) { + glActiveTextureARB(GL_TEXTURE0_ARB + i); + glMatrixMode(GL_TEXTURE); + glLoadIdentity(); + if (i == 0) { + glTranslatef(Drift, 0.0, 0.0); + glScalef(2, 2, 1); + } + else if (i == 1) { + glTranslatef(0.0, Drift, 0.0); + } + else { + glTranslatef(0.5, 0.5, 0.0); + glRotatef(180.0 * Drift, 0, 0, 1); + glScalef(1.0/i, 1.0/i, 1.0/i); + glTranslatef(-0.5, -0.5, 0.0); + } + } + glMatrixMode(GL_MODELVIEW); + + glutPostRedisplay(); + } +} + + +static void DrawObject(void) +{ + GLint i; + GLint j; + static const GLfloat tex_coords[] = { 0.0, 0.0, 1.0, 1.0, 0.0 }; + static const GLfloat vtx_coords[] = { -1.0, -1.0, 1.0, 1.0, -1.0 }; + + if (!TexEnabled[0] && !TexEnabled[1]) + glColor3f(0.1, 0.1, 0.1); /* add onto this */ + else + glColor3f(1, 1, 1); /* modulate this */ + + glBegin(GL_QUADS); + + /* Toggle between the vector and scalar entry points. This is done purely + * to hit multiple paths in the driver. + */ + if ( Drift > 0.49 ) { + for (j = 0; j < 4; j++ ) { + for (i = 0; i < NumUnits; i++) + glMultiTexCoord2fARB(GL_TEXTURE0_ARB + i, + tex_coords[j], tex_coords[j+1]); + glVertex2f( vtx_coords[j], vtx_coords[j+1] ); + } + } + else { + for (j = 0; j < 4; j++ ) { + for (i = 0; i < NumUnits; i++) + glMultiTexCoord2fvARB(GL_TEXTURE0_ARB + i, & tex_coords[j]); + glVertex2fv( & vtx_coords[j] ); + } + } + + glEnd(); +} + + + +static void Display( void ) +{ + static GLint T0 = 0; + static GLint Frames = 0; + GLint t; + + glClear( GL_COLOR_BUFFER_BIT ); + + glPushMatrix(); + glRotatef(Xrot, 1.0, 0.0, 0.0); + glRotatef(Yrot, 0.0, 1.0, 0.0); + glRotatef(Zrot, 0.0, 0.0, 1.0); + glScalef(5.0, 5.0, 5.0); + DrawObject(); + glPopMatrix(); + + glutSwapBuffers(); + + Frames++; + + t = glutGet(GLUT_ELAPSED_TIME); + if (t - T0 >= 250) { + GLfloat seconds = (t - T0) / 1000.0; + drift_increment = 2.2 * seconds / Frames; + T0 = t; + Frames = 0; + } +} + + +static void Reshape( int width, int height ) +{ + glViewport( 0, 0, width, height ); + glMatrixMode( GL_PROJECTION ); + glLoadIdentity(); + glFrustum( -1.0, 1.0, -1.0, 1.0, 10.0, 100.0 ); + /*glOrtho( -6.0, 6.0, -6.0, 6.0, 10.0, 100.0 );*/ + glMatrixMode( GL_MODELVIEW ); + glLoadIdentity(); + glTranslatef( 0.0, 0.0, -70.0 ); +} + + +static void ModeMenu(int entry) +{ + if (entry >= TEX0 && entry <= TEX7) { + /* toggle */ + GLint i = entry - TEX0; + TexEnabled[i] = !TexEnabled[i]; + glActiveTextureARB(GL_TEXTURE0_ARB + i); + if (TexEnabled[i]) + glEnable(GL_TEXTURE_2D); + else + glDisable(GL_TEXTURE_2D); + printf("Enabled: "); + for (i = 0; i < NumUnits; i++) + printf("%d ", (int) TexEnabled[i]); + printf("\n"); + } + else if (entry==ANIMATE) { + Animate = !Animate; + } + else if (entry==QUIT) { + exit(0); + } + + glutPostRedisplay(); +} + + +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 ) +{ + float 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( int argc, char *argv[] ) +{ + GLuint texObj[8]; + GLint size, i; + + const char *exten = (const char *) glGetString(GL_EXTENSIONS); + if (!strstr(exten, "GL_ARB_multitexture")) { + printf("Sorry, GL_ARB_multitexture not supported by this renderer.\n"); + exit(1); + } + + glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &NumUnits); + printf("%d texture units supported\n", NumUnits); + if (NumUnits > 8) + NumUnits = 8; + + glGetIntegerv(GL_MAX_TEXTURE_SIZE, &size); + printf("%d x %d max texture size\n", size, size); + + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + + for (i = 0; i < NumUnits; i++) { + if (i < 2) + TexEnabled[i] = GL_TRUE; + else + TexEnabled[i] = GL_FALSE; + } + + /* allocate two texture objects */ + glGenTextures(NumUnits, texObj); + + /* setup the texture objects */ + for (i = 0; i < NumUnits; i++) { + + glActiveTextureARB(GL_TEXTURE0_ARB + i); + glBindTexture(GL_TEXTURE_2D, texObj[i]); + + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + + if (i == 0) { + if (!LoadRGBMipmaps(TEXTURE_1_FILE, GL_RGB)) { + printf("Error: couldn't load texture image\n"); + exit(1); + } + } + else if (i == 1) { + if (!LoadRGBMipmaps(TEXTURE_2_FILE, GL_RGB)) { + printf("Error: couldn't load texture image\n"); + exit(1); + } + } + else { + /* checker */ + GLubyte image[8][8][3]; + GLint i, j; + for (i = 0; i < 8; i++) { + for (j = 0; j < 8; j++) { + if ((i + j) & 1) { + image[i][j][0] = 50; + image[i][j][1] = 50; + image[i][j][2] = 50; + } + else { + image[i][j][0] = 25; + image[i][j][1] = 25; + image[i][j][2] = 25; + } + } + } + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 8, 8, 0, + GL_RGB, GL_UNSIGNED_BYTE, (GLvoid *) image); + } + + /* Bind texObj[i] to ith texture unit */ + if (i < 2) + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + else + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_ADD); + + if (TexEnabled[i]) + glEnable(GL_TEXTURE_2D); + } + + glShadeModel(GL_FLAT); + glClearColor(0.3, 0.3, 0.4, 1.0); + + 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)); + } +} + + +int main( int argc, char *argv[] ) +{ + GLint i; + + glutInit( &argc, argv ); + glutInitWindowSize( 300, 300 ); + glutInitWindowPosition( 0, 0 ); + glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE ); + glutCreateWindow(argv[0] ); + + Init( argc, argv ); + + glutReshapeFunc( Reshape ); + glutKeyboardFunc( Key ); + glutSpecialFunc( SpecialKey ); + glutDisplayFunc( Display ); + glutIdleFunc( Idle ); + + glutCreateMenu(ModeMenu); + + for (i = 0; i < NumUnits; i++) { + char s[100]; + sprintf(s, "Toggle Texture %d", i); + glutAddMenuEntry(s, TEX0 + i); + } + glutAddMenuEntry("Toggle Animation", ANIMATE); + glutAddMenuEntry("Quit", QUIT); + glutAttachMenu(GLUT_RIGHT_BUTTON); + + glutMainLoop(); + return 0; +} diff --git a/progs/demos/occlude.c b/progs/demos/occlude.c new file mode 100644 index 00000000000..8f7b90984e0 --- /dev/null +++ b/progs/demos/occlude.c @@ -0,0 +1,234 @@ +/* + * 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 +#include +#include +#include +#include +#include + + +static GLfloat Xpos = 0; +static GLboolean Anim = GL_TRUE; + + +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 'a': + Anim = !Anim; + if (Anim) + glutIdleFunc( Idle ); + else + glutIdleFunc( NULL ); + break; + 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; +} diff --git a/progs/demos/paltex.c b/progs/demos/paltex.c new file mode 100644 index 00000000000..aa9c0da36b7 --- /dev/null +++ b/progs/demos/paltex.c @@ -0,0 +1,270 @@ + +/* + * Paletted texture demo. Written by Brian Paul. + * This program is in the public domain. + */ + +#include +#include +#include +#include +#ifdef _WIN32 +#include +#endif +#define GL_GLEXT_PROTOTYPES +#include + + +static float Rot = 0.0; +static GLboolean Anim = 1; + + +static void Idle( void ) +{ + float t = glutGet(GLUT_ELAPSED_TIME) * 0.001; /* in seconds */ + Rot = t * 360 / 4; /* 1 rotation per 4 seconds */ + glutPostRedisplay(); +} + + +static void Display( void ) +{ + /* draw background gradient */ + glDisable(GL_TEXTURE_2D); + glBegin(GL_POLYGON); + glColor3f(1.0, 0.0, 0.2); glVertex2f(-1.5, -1.0); + glColor3f(1.0, 0.0, 0.2); glVertex2f( 1.5, -1.0); + glColor3f(0.0, 0.0, 1.0); glVertex2f( 1.5, 1.0); + glColor3f(0.0, 0.0, 1.0); glVertex2f(-1.5, 1.0); + glEnd(); + + glPushMatrix(); + glRotatef(Rot, 0, 0, 1); + + glEnable(GL_TEXTURE_2D); + glBegin(GL_POLYGON); + glTexCoord2f(0, 1); glVertex2f(-1, -0.5); + glTexCoord2f(1, 1); glVertex2f( 1, -0.5); + glTexCoord2f(1, 0); glVertex2f( 1, 0.5); + glTexCoord2f(0, 0); glVertex2f(-1, 0.5); + glEnd(); + + glPopMatrix(); + + glutSwapBuffers(); +} + + +static void Reshape( int width, int height ) +{ + glViewport( 0, 0, width, height ); + glMatrixMode( GL_PROJECTION ); + glLoadIdentity(); + glOrtho( -1.5, 1.5, -1.0, 1.0, -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 27: + exit(0); + break; + case 's': + Rot += 0.5; + break; + case ' ': + Anim = !Anim; + if (Anim) + glutIdleFunc( Idle ); + else + glutIdleFunc( NULL ); + break; + } + glutPostRedisplay(); +} + + +static void Init( void ) +{ +#define HEIGHT 8 +#define WIDTH 32 + /* 257 = HEIGHT * WIDTH + 1 (for trailing '\0') */ + static char texture[257] = {"\ + \ + MMM EEEE SSS AAA \ + M M M E S S A A \ + M M M EEEE SS A A \ + M M M E SS AAAAA \ + M M E S S A A \ + M M EEEE SSS A A \ + " + }; + GLubyte table[256][4]; + + if (!glutExtensionSupported("GL_EXT_paletted_texture")) { + printf("Sorry, GL_EXT_paletted_texture not supported\n"); + exit(0); + } + + /* load the color table for each texel-index */ + memset(table, 0, 256*4); + table[' '][0] = 255; + table[' '][1] = 255; + table[' '][2] = 255; + table[' '][3] = 64; + table['M'][0] = 255; + table['M'][1] = 0; + table['M'][2] = 0; + table['M'][3] = 255; + table['E'][0] = 0; + table['E'][1] = 255; + table['E'][2] = 0; + table['E'][3] = 255; + table['S'][0] = 0; + table['S'][1] = 0; + table['S'][2] = 255; + table['S'][3] = 255; + table['A'][0] = 255; + table['A'][1] = 255; + table['A'][2] = 0; + table['A'][3] = 255; + +#ifdef GL_EXT_paletted_texture + +#if defined(GL_EXT_shared_texture_palette) && defined(USE_SHARED_PALETTE) + printf("Using shared palette\n"); + glColorTableEXT(GL_SHARED_TEXTURE_PALETTE_EXT, /* target */ + GL_RGBA, /* internal format */ + 256, /* table size */ + GL_RGBA, /* table format */ + GL_UNSIGNED_BYTE, /* table type */ + table); /* the color table */ + glEnable(GL_SHARED_TEXTURE_PALETTE_EXT); +#else + glColorTableEXT(GL_TEXTURE_2D, /* target */ + GL_RGBA, /* internal format */ + 256, /* table size */ + GL_RGBA, /* table format */ + GL_UNSIGNED_BYTE, /* table type */ + table); /* the color table */ +#endif + + glTexImage2D(GL_TEXTURE_2D, /* target */ + 0, /* level */ + GL_COLOR_INDEX8_EXT, /* internal format */ + WIDTH, HEIGHT, /* width, height */ + 0, /* border */ + GL_COLOR_INDEX, /* texture format */ + GL_UNSIGNED_BYTE, /* texture type */ + texture); /* the texture */ +#endif + + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); + glEnable(GL_TEXTURE_2D); + + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); +#undef HEIGHT +#undef WIDTH +} + + + +/* + * Color ramp test + */ +static void Init2( void ) +{ +#define HEIGHT 32 +#define WIDTH 256 + static char texture[HEIGHT][WIDTH]; + GLubyte table[256][4]; + int i, j; + + if (!glutExtensionSupported("GL_EXT_paletted_texture")) { + printf("Sorry, GL_EXT_paletted_texture not supported\n"); + exit(0); + } + + for (j = 0; j < HEIGHT; j++) { + for (i = 0; i < WIDTH; i++) { + texture[j][i] = i; + } + } + + for (i = 0; i < 255; i++) { + table[i][0] = i; + table[i][1] = 0; + table[i][2] = 0; + table[i][3] = 255; + } + +#ifdef GL_EXT_paletted_texture + +#if defined(GL_EXT_shared_texture_palette) && defined(USE_SHARED_PALETTE) + printf("Using shared palette\n"); + glColorTableEXT(GL_SHARED_TEXTURE_PALETTE_EXT, /* target */ + GL_RGBA, /* internal format */ + 256, /* table size */ + GL_RGBA, /* table format */ + GL_UNSIGNED_BYTE, /* table type */ + table); /* the color table */ + glEnable(GL_SHARED_TEXTURE_PALETTE_EXT); +#else + glColorTableEXT(GL_TEXTURE_2D, /* target */ + GL_RGBA, /* internal format */ + 256, /* table size */ + GL_RGBA, /* table format */ + GL_UNSIGNED_BYTE, /* table type */ + table); /* the color table */ +#endif + + glTexImage2D(GL_TEXTURE_2D, /* target */ + 0, /* level */ + GL_COLOR_INDEX8_EXT, /* internal format */ + WIDTH, HEIGHT, /* width, height */ + 0, /* border */ + GL_COLOR_INDEX, /* texture format */ + GL_UNSIGNED_BYTE, /* texture type */ + texture); /* teh texture */ +#endif + + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); + glEnable(GL_TEXTURE_2D); + + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); +} + + +int main( int argc, char *argv[] ) +{ + glutInit( &argc, argv ); + glutInitWindowPosition( 0, 0 ); + glutInitWindowSize( 400, 300 ); + + glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE ); + + glutCreateWindow(argv[0]); + + Init(); + (void) Init2; /* silence warning */ + + glutReshapeFunc( Reshape ); + glutKeyboardFunc( Key ); + glutDisplayFunc( Display ); + if (Anim) + glutIdleFunc( Idle ); + + glutMainLoop(); + return 0; +} diff --git a/progs/demos/particles.cxx b/progs/demos/particles.cxx new file mode 100644 index 00000000000..b88c318e0bc --- /dev/null +++ b/progs/demos/particles.cxx @@ -0,0 +1,219 @@ +/* + * This program is under the GNU GPL. + * Use at your own risk. + * + * written by David Bucciarelli (humanware@plus.it) + * Humanware s.r.l. + */ + +#include + +#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;idraw(); + part[0]->endDraw(); +} + +void particleSystem::addTime(float dt) +{ + if(!part) + return; + + for(unsigned int i=0;ielapsedTime(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]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]; +} diff --git a/progs/demos/particles.h b/progs/demos/particles.h new file mode 100644 index 00000000000..a49dd691e4a --- /dev/null +++ b/progs/demos/particles.h @@ -0,0 +1,81 @@ +/* + * 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 + +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 diff --git a/progs/demos/pointblast.c b/progs/demos/pointblast.c new file mode 100644 index 00000000000..715813f1763 --- /dev/null +++ b/progs/demos/pointblast.c @@ -0,0 +1,498 @@ + +/* Copyright (c) Mark J. Kilgard, 1997. */ + +/* This program is freely distributable without licensing fees + and is provided without guarantee or warrantee expressed or + implied. This program is -not- in the public domain. */ + +/* This example demonstrates how to render particle effects + with OpenGL. A cloud of pinkish/orange particles explodes with the + particles bouncing off the ground. When the EXT_point_parameters + is present , the particle size is attenuated based on eye distance. */ + + +#include +#include +#include +#include /* for cos(), sin(), and sqrt() */ +#ifdef _WIN32 +#include +#endif +#define GL_GLEXT_PROTOTYPES +#include + +/* Some files do not define M_PI... */ +#ifndef M_PI +#define M_PI 3.14159265 +#endif + +#if 0 /* For debugging. */ +#undef GL_EXT_point_parameters +#endif + +static GLfloat angle = -150; /* in degrees */ +static int spin = 0; +static int moving, begin; +static int newModel = 1; +static float theTime; +static int repeat = 1; +static int blend = 1; +int useMipmaps = 1; +int linearFiltering = 1; + +static GLfloat constant[3] = { 1/5.0, 0.0, 0.0 }; +static GLfloat linear[3] = { 0.0, 1/5.0, 0.0 }; +static GLfloat theQuad[3] = { 0.25, 0.0, 1/60.0 }; + +#define MAX_POINTS 2000 + +static int numPoints = 200; + +static GLfloat pointList[MAX_POINTS][3]; +static GLfloat pointTime[MAX_POINTS]; +static GLfloat pointVelocity[MAX_POINTS][2]; +static GLfloat pointDirection[MAX_POINTS][2]; +static int colorList[MAX_POINTS]; +static int animate = 1, motion = 0; + +static GLfloat colorSet[][4] = { + /* Shades of red. */ + { 0.7, 0.2, 0.4, 0.5 }, + { 0.8, 0.0, 0.7, 0.5 }, + { 1.0, 0.0, 0.0, 0.5 }, + { 0.9, 0.3, 0.6, 0.5 }, + { 1.0, 0.4, 0.0, 0.5 }, + { 1.0, 0.0, 0.5, 0.5 }, +}; + +#define NUM_COLORS (sizeof(colorSet)/sizeof(colorSet[0])) + +#define DEAD (NUM_COLORS+1) + + +#if 0 /* drand48 might be better on Unix machines */ +#define RANDOM_RANGE(lo, hi) ((lo) + (hi - lo) * drand48()) +#else +static float float_rand(void) { return rand() / (float) RAND_MAX; } +#define RANDOM_RANGE(lo, hi) ((lo) + (hi - lo) * float_rand()) +#endif + +#define MEAN_VELOCITY 3.0 +#define GRAVITY 2.0 + +/* Modeling units of ground extent in each X and Z direction. */ +#define EDGE 12 + +static void +makePointList(void) +{ + float angle, velocity, direction; + int i; + + motion = 1; + for (i=0; i EDGE) { + /* Particle has hit ground past the distance duration of + the particles. Mark particle as dead. */ + colorList[i] = NUM_COLORS; /* Not moving. */ + continue; + } + + pointVelocity[i][1] *= 0.8; /* 80% of previous up velocity. */ + pointTime[i] = 0.0; /* Reset the particles sense of up time. */ + } + motion = 1; + pointTime[i] += dt; + } + theTime += dt; + if (!motion && !spin) { + if (repeat) { + makePointList(); + } else { + glutIdleFunc(NULL); + } + } +} + +static void +idle(void) +{ + updatePointList(); + if (spin) { + angle += 0.3; + newModel = 1; + } + glutPostRedisplay(); +} + +static void +visible(int vis) +{ + if (vis == GLUT_VISIBLE) { + if (animate && (motion || spin)) { + glutIdleFunc(idle); + } + } else { + glutIdleFunc(NULL); + } +} + +static void +recalcModelView(void) +{ + glPopMatrix(); + glPushMatrix(); + glRotatef(angle, 0.0, 1.0, 0.0); + newModel = 0; +} + +static void +redraw(void) +{ + int i; + + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + if (newModel) + recalcModelView(); + + glDepthMask(GL_FALSE); + + /* Draw the floor. */ +/* glEnable(GL_TEXTURE_2D);*/ + glColor3f(0.5, 1.0, 0.5); + glBegin(GL_QUADS); + glTexCoord2f(0.0, 0.0); + glVertex3f(-EDGE, -0.05, -EDGE); + glTexCoord2f(20.0, 0.0); + glVertex3f(EDGE, -0.05, -EDGE); + glTexCoord2f(20.0, 20.0); + glVertex3f(EDGE, -0.05, EDGE); + glTexCoord2f(0.0, 20.0); + glVertex3f(-EDGE, -0.05, EDGE); + glEnd(); + + /* Allow particles to blend with each other. */ + glDepthMask(GL_TRUE); + + if (blend) + glEnable(GL_BLEND); + + glDisable(GL_TEXTURE_2D); + glBegin(GL_POINTS); + for (i=0; i +#include +#include +#include +#include +#ifndef M_PI +#define M_PI 3.14159265 +#endif + +#include "particles.h" +extern "C" { +#include "readtex.h" +} + +#ifdef _WIN32 +#include +#include +#include "particles.cxx" +#include "readtex.c" +#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;idraw(); + 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) +{ + GLubyte *img; + GLint width,height; + GLenum format; + GLenum gluerr; + + glGenTextures(1,&groundid); + glBindTexture(GL_TEXTURE_2D,groundid); + + if(!(img=LoadRGBImage("../images/s128.rgb",&width,&height,&format))){ + fprintf(stderr,"Error reading a texture.\n"); + exit(-1); + } + glPixelStorei(GL_UNPACK_ALIGNMENT,4); + if((gluerr=(GLenum)gluBuild2DMipmaps(GL_TEXTURE_2D, 3, width, height,GL_RGB, + GL_UNSIGNED_BYTE, (GLvoid *)(img)))) { + 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;irandomHeight(); + + 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); +} diff --git a/progs/demos/ray.c b/progs/demos/ray.c new file mode 100644 index 00000000000..c2d8e4f545e --- /dev/null +++ b/progs/demos/ray.c @@ -0,0 +1,904 @@ +/* + * 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 +#include +#include +#include + +#ifdef WIN32 +#include +#endif + +#include + +#ifdef XMESA +#include "GL/xmesa.h" +static int fullscreen = 1; +#endif + +static int WIDTH = 640; +static int HEIGHT = 480; + +static GLint T0 = 0; +static GLint Frames = 0; + +#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)) ) + +#ifndef fabs +#define fabs(x) ((x)<0.0f?-(x):(x)) +#endif + +#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 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); + + if (dir[0] < 1.0e-5 && dir[0] > -1.0e-5) + dir[0] = 0; + if (dir[1] < 1.0e-5 && dir[1] > -1.0e-5) + dir[1] = 0; + if (dir[2] < 1.0e-5 && dir[2] > -1.0e-5) + dir[2] = 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 - Toggle Help"); + glRasterPos2i(60, 370); + printstring(GLUT_BITMAP_HELVETICA_12, "f - Toggle Fog"); + glRasterPos2i(60, 350); + printstring(GLUT_BITMAP_HELVETICA_12, "b - Toggle Back face culling"); + glRasterPos2i(60, 330); + printstring(GLUT_BITMAP_HELVETICA_12, "p - Toggle 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 - Toggle 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 - Toggle the plane texture map window"); + + glRasterPos2i(60, 170); + printstring(GLUT_BITMAP_HELVETICA_12, + "2 - Toggle 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 = pow(kfact, 6.0) * 7.0 * 255.0; + + 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 = pow(kfact, 4.0); + if (kfact < 1.0e-10) + kfact = 0.0; + } + + 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 char frbuf[80] = ""; + + 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(); + + 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(); + + Frames++; + { + GLint t = glutGet(GLUT_ELAPSED_TIME); + if (t - T0 >= 2000) { + GLfloat seconds = (t - T0) / 1000.0; + GLfloat fps = Frames / seconds; + sprintf(frbuf, "Frame rate: %f", fps); + T0 = t; + Frames = 0; + } + } +} + +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; +} diff --git a/progs/demos/readpix.c b/progs/demos/readpix.c new file mode 100644 index 00000000000..75ba45c1e5f --- /dev/null +++ b/progs/demos/readpix.c @@ -0,0 +1,344 @@ + +/* + * glReadPixels and glCopyPixels test + * + * Brian Paul March 1, 2000 This file is in the public domain. + */ + +#include +#include +#include +#include +#include +#include + +#include "readtex.h" + +#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 0 +#define ReadFormat ImgFormat +#define ReadType GL_UNSIGNED_BYTE +#endif +#if 1 +static GLenum ReadFormat = GL_RGBA; +static GLenum ReadType = GL_UNSIGNED_BYTE; +#endif +#if 0 +static GLenum ReadFormat = GL_RGB; +static GLenum ReadType = GL_UNSIGNED_BYTE; +#endif +#if 0 +static GLenum ReadFormat = GL_RGB; +static GLenum ReadType = GL_UNSIGNED_SHORT_5_6_5; +#endif +#if 0 +static GLenum ReadFormat = GL_RGBA; +static GLenum ReadType = GL_UNSIGNED_SHORT_1_5_5_5_REV; +#endif +#if 0 +static GLenum ReadFormat = GL_BGRA; +static GLenum ReadType = GL_UNSIGNED_SHORT_5_5_5_1; +#endif +#if 0 +static GLenum ReadFormat = GL_BGRA; +static GLenum ReadType = GL_UNSIGNED_SHORT_4_4_4_4_REV; +#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); + } +} + + +/** + * Exercise Pixel Pack parameters by reading the image in four pieces. + */ +static void +ComplexReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, + GLenum format, GLenum type, GLvoid *pixels) +{ + const GLsizei width0 = width / 2; + const GLsizei width1 = width - width0; + const GLsizei height0 = height / 2; + const GLsizei height1 = height - height0; + + glPixelStorei(GL_PACK_ROW_LENGTH, width); + + /* lower-left quadrant */ + glReadPixels(x, y, width0, height0, format, type, pixels); + + /* lower-right quadrant */ + glPixelStorei(GL_PACK_SKIP_PIXELS, width0); + glReadPixels(x + width0, y, width1, height0, format, type, pixels); + + /* upper-left quadrant */ + glPixelStorei(GL_PACK_SKIP_PIXELS, 0); + glPixelStorei(GL_PACK_SKIP_ROWS, height0); + glReadPixels(x, y + height0, width0, height1, format, type, pixels); + + /* upper-right quadrant */ + glPixelStorei(GL_PACK_SKIP_PIXELS, width0); + glPixelStorei(GL_PACK_SKIP_ROWS, height0); + glReadPixels(x + width0, y + height0, width1, height1, format, type, pixels); + + /* restore defaults */ + glPixelStorei(GL_PACK_SKIP_PIXELS, 0); + glPixelStorei(GL_PACK_SKIP_ROWS, 0); + glPixelStorei(GL_PACK_ROW_LENGTH, ImgWidth); +} + + + +static void +Display( void ) +{ + glClearColor(.3, .3, .3, 1); + 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); + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + glDrawPixels(ImgWidth, ImgHeight, ImgFormat, GL_UNSIGNED_BYTE, Image); + + /* might try alignment=4 here for testing */ + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + glPixelStorei(GL_PACK_ALIGNMENT, 1); + + /* 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 { + /* clear the temporary image to white (helpful for debugging */ + memset(TempImage, 255, ImgWidth * ImgHeight * 4); +#if 1 + glReadPixels(APosX, APosY, ImgWidth, ImgHeight, + ReadFormat, ReadType, TempImage); + (void) ComplexReadPixels; +#else + /* you might use this when debugging */ + ComplexReadPixels(APosX, APosY, ImgWidth, ImgHeight, + ReadFormat, ReadType, TempImage); +#endif + } + 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(); + else + glFinish(); +} + + +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 ) +{ + GLboolean have_read_format = GL_FALSE; + + 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 = (GLubyte *) malloc( ImgWidth * ImgHeight ); + GLint i; + for (i=0; i 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; +} diff --git a/progs/demos/reflect.c b/progs/demos/reflect.c new file mode 100644 index 00000000000..0bec0663bc2 --- /dev/null +++ b/progs/demos/reflect.c @@ -0,0 +1,590 @@ +/* + * Demo of a reflective, texture-mapped surface with OpenGL. + * Brian Paul August 14, 1995 This file is in the public domain. + * + * Hardware texture mapping is highly recommended! + * + * The basic steps are: + * 1. Render the reflective object (a polygon) from the normal viewpoint, + * setting the stencil planes = 1. + * 2. Render the scene from a special viewpoint: the viewpoint which + * is on the opposite side of the reflective plane. Only draw where + * stencil = 1. This draws the objects in the reflective surface. + * 3. Render the scene from the original viewpoint. This draws the + * objects in the normal fashion. Use blending when drawing + * the reflective, textured surface. + * + * This is a very crude demo. It could be much better. + */ + +/* + * 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) + * Brian Paul (August 2005 - added multi window feature) + */ + + +#include +#include +#include +#include +#include "GL/glut.h" +#include "showbuffer.h" +#include "readtex.h" + + +#define DEG2RAD (3.14159/180.0) +#define TABLE_TEXTURE "../images/tile.rgb" +#define MAX_OBJECTS 2 +#define INIT_WIDTH 400 +#define INIT_HEIGHT 300 + +#ifdef _WIN32 +#undef CreateWindowA +#endif + +struct window { + int id; /* returned by glutCreateWindow() */ + int width, height; + GLboolean anim; + GLfloat xrot, yrot; + GLfloat spin; + GLenum showBuffer; + GLenum drawBuffer; + GLuint table_list; + GLuint objects_list[MAX_OBJECTS]; + double t0; + struct window *next; +}; + + +static struct window *FirstWindow = NULL; + + +static void +CreateWindow(void); + + +static struct window * +CurrentWindow(void) +{ + int id = glutGetWindow(); + struct window *w; + for (w = FirstWindow; w; w = w->next) { + if (w->id == id) + return w; + } + return NULL; +} + + +static GLboolean +AnyAnimating(void) +{ + struct window *w; + for (w = FirstWindow; w; w = w->next) { + if (w->anim) + return 1; + } + return 0; +} + + +static void +KillWindow(struct window *w) +{ + struct window *win, *prev = NULL; + for (win = FirstWindow; win; win = win->next) { + if (win == w) { + if (prev) { + prev->next = win->next; + } + else { + FirstWindow = win->next; + } + glutDestroyWindow(win->id); + win->next = NULL; + free(win); + return; + } + prev = win; + } +} + + +static void +KillAllWindows(void) +{ + while (FirstWindow) + KillWindow(FirstWindow); +} + + +static GLuint +MakeTable(void) +{ + static GLfloat table_mat[] = { 1.0, 1.0, 1.0, 0.6 }; + static GLfloat gray[] = { 0.4, 0.4, 0.4, 1.0 }; + GLuint table_list; + + table_list = glGenLists(1); + glNewList( table_list, GL_COMPILE ); + + /* load table's texture */ + glMaterialfv( GL_FRONT, GL_AMBIENT_AND_DIFFUSE, table_mat ); + /*glMaterialfv( GL_FRONT, GL_EMISSION, gray );*/ + glMaterialfv( GL_FRONT, GL_DIFFUSE, table_mat ); + glMaterialfv( GL_FRONT, GL_AMBIENT, gray ); + + /* draw textured square for the table */ + glPushMatrix(); + glScalef( 4.0, 4.0, 4.0 ); + glBegin( GL_POLYGON ); + glNormal3f( 0.0, 1.0, 0.0 ); + glTexCoord2f( 0.0, 0.0 ); glVertex3f( -1.0, 0.0, 1.0 ); + glTexCoord2f( 1.0, 0.0 ); glVertex3f( 1.0, 0.0, 1.0 ); + glTexCoord2f( 1.0, 1.0 ); glVertex3f( 1.0, 0.0, -1.0 ); + glTexCoord2f( 0.0, 1.0 ); glVertex3f( -1.0, 0.0, -1.0 ); + glEnd(); + glPopMatrix(); + + glDisable( GL_TEXTURE_2D ); + + glEndList(); + return table_list; +} + + +static void +MakeObjects(GLuint *objects_list) +{ + GLUquadricObj *q; + + static GLfloat cyan[] = { 0.0, 1.0, 1.0, 1.0 }; + static GLfloat green[] = { 0.2, 1.0, 0.2, 1.0 }; + static GLfloat black[] = { 0.0, 0.0, 0.0, 0.0 }; + + q = gluNewQuadric(); + gluQuadricDrawStyle( q, GLU_FILL ); + gluQuadricNormals( q, GLU_SMOOTH ); + + objects_list[0] = glGenLists(1); + glNewList( objects_list[0], GL_COMPILE ); + glMaterialfv( GL_FRONT, GL_AMBIENT_AND_DIFFUSE, cyan ); + glMaterialfv( GL_FRONT, GL_EMISSION, black ); + gluCylinder( q, 0.5, 0.5, 1.0, 15, 1 ); + glEndList(); + + objects_list[1] = glGenLists(1); + glNewList( objects_list[1], GL_COMPILE ); + glMaterialfv( GL_FRONT, GL_AMBIENT_AND_DIFFUSE, green ); + glMaterialfv( GL_FRONT, GL_EMISSION, black ); + gluCylinder( q, 1.5, 0.0, 2.5, 15, 1 ); + glEndList(); + + gluDeleteQuadric(q); +} + + +static void +InitWindow(struct window *w) +{ + GLint imgWidth, imgHeight; + GLenum imgFormat; + GLubyte *image = NULL; + + w->table_list = MakeTable(); + MakeObjects(w->objects_list); + + image = LoadRGBImage( TABLE_TEXTURE, &imgWidth, &imgHeight, &imgFormat ); + if (!image) { + printf("Couldn't read %s\n", TABLE_TEXTURE); + exit(0); + } + + gluBuild2DMipmaps(GL_TEXTURE_2D, 3, imgWidth, imgHeight, + imgFormat, GL_UNSIGNED_BYTE, image); + free(image); + + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST ); + + glShadeModel( GL_FLAT ); + + glEnable( GL_LIGHT0 ); + glEnable( GL_LIGHTING ); + + glClearColor( 0.5, 0.5, 0.9, 0.0 ); + + glEnable( GL_NORMALIZE ); +} + + +static void +Reshape(int width, int height) +{ + struct window *w = CurrentWindow(); + GLfloat yAspect = 2.5; + GLfloat xAspect = yAspect * (float) width / (float) height; + w->width = width; + w->height = height; + glViewport(0, 0, width, height); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glFrustum( -xAspect, xAspect, -yAspect, yAspect, 10.0, 30.0 ); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); +} + + +static void +DrawObjects(struct window *w, GLfloat eyex, GLfloat eyey, GLfloat eyez) +{ + (void) eyex; + (void) eyey; + (void) eyez; +#ifndef USE_ZBUFFER + if (eyex<0.5) { +#endif + glPushMatrix(); + glTranslatef( 1.0, 1.5, 0.0 ); + glRotatef( w->spin, 1.0, 0.5, 0.0 ); + glRotatef( 0.5*w->spin, 0.0, 0.5, 1.0 ); + glCallList( w->objects_list[0] ); + glPopMatrix(); + + glPushMatrix(); + glTranslatef( -1.0, 0.85+3.0*fabs( cos(0.01*w->spin) ), 0.0 ); + glRotatef( 0.5*w->spin, 0.0, 0.5, 1.0 ); + glRotatef( w->spin, 1.0, 0.5, 0.0 ); + glScalef( 0.5, 0.5, 0.5 ); + glCallList( w->objects_list[1] ); + glPopMatrix(); +#ifndef USE_ZBUFFER + } + else { + glPushMatrix(); + glTranslatef( -1.0, 0.85+3.0*fabs( cos(0.01*w->spin) ), 0.0 ); + glRotatef( 0.5*w->spin, 0.0, 0.5, 1.0 ); + glRotatef( w->spin, 1.0, 0.5, 0.0 ); + glScalef( 0.5, 0.5, 0.5 ); + glCallList( w->objects_list[1] ); + glPopMatrix(); + + glPushMatrix(); + glTranslatef( 1.0, 1.5, 0.0 ); + glRotatef( w->spin, 1.0, 0.5, 0.0 ); + glRotatef( 0.5*w->spin, 0.0, 0.5, 1.0 ); + glCallList( w->objects_list[0] ); + glPopMatrix(); + } +#endif +} + + +static void +DrawTable(struct window *w) +{ + glCallList(w->table_list); +} + + +static void +DrawWindow(void) +{ + struct window *w = CurrentWindow(); + static GLfloat light_pos[] = { 0.0, 20.0, 0.0, 1.0 }; + GLfloat dist = 20.0; + GLfloat eyex, eyey, eyez; + + if (w->drawBuffer == GL_NONE) { + glDrawBuffer(GL_BACK); + glReadBuffer(GL_BACK); + } + else { + glDrawBuffer(w->drawBuffer); + glReadBuffer(w->drawBuffer); + } + + glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); + + if (w->drawBuffer == GL_NONE) { + glDrawBuffer(GL_NONE); + } + + eyex = dist * cos(w->yrot * DEG2RAD) * cos(w->xrot * DEG2RAD); + eyez = dist * sin(w->yrot * DEG2RAD) * cos(w->xrot * DEG2RAD); + eyey = dist * sin(w->xrot * DEG2RAD); + + /* view from top */ + glPushMatrix(); + gluLookAt( eyex, eyey, eyez, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0 ); + + glLightfv( GL_LIGHT0, GL_POSITION, light_pos ); + + /* draw table into stencil planes */ + glDisable( GL_DEPTH_TEST ); + glEnable( GL_STENCIL_TEST ); + glStencilFunc( GL_ALWAYS, 1, 0xffffffff ); + glStencilOp( GL_REPLACE, GL_REPLACE, GL_REPLACE ); + glColorMask( GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE ); + DrawTable(w); + glColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE ); + + glEnable( GL_DEPTH_TEST ); + + /* render view from below (reflected viewport) */ + /* only draw where stencil==1 */ + if (eyey>0.0) { + glPushMatrix(); + + glStencilFunc( GL_EQUAL, 1, 0xffffffff ); /* draw if ==1 */ + glStencilOp( GL_KEEP, GL_KEEP, GL_KEEP ); + glScalef( 1.0, -1.0, 1.0 ); + + /* Reposition light in reflected space. */ + glLightfv(GL_LIGHT0, GL_POSITION, light_pos); + + DrawObjects(w, eyex, eyey, eyez); + glPopMatrix(); + + /* Restore light's original unreflected position. */ + glLightfv(GL_LIGHT0, GL_POSITION, light_pos); + } + + glDisable( GL_STENCIL_TEST ); + + glEnable( GL_BLEND ); + glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); + + glEnable( GL_TEXTURE_2D ); + DrawTable(w); + glDisable( GL_TEXTURE_2D ); + glDisable( GL_BLEND ); + + /* view from top */ + glPushMatrix(); + + DrawObjects(w, eyex, eyey, eyez); + + glPopMatrix(); + + glPopMatrix(); + + if (w->showBuffer == GL_DEPTH) { + ShowDepthBuffer(w->width, w->height, 1.0, 0.0); + } + else if (w->showBuffer == GL_STENCIL) { + ShowStencilBuffer(w->width, w->height, 255.0, 0.0); + } + else if (w->showBuffer == GL_ALPHA) { + ShowAlphaBuffer(w->width, w->height); + } + + if (w->drawBuffer == GL_FRONT) + glFinish(); + else + glutSwapBuffers(); + + /* calc/show frame rate */ + { + static GLint t0 = 0; + static GLint frames = 0; + GLint t = glutGet(GLUT_ELAPSED_TIME); + frames++; + if (t - t0 >= 5000) { + GLfloat seconds = (t - t0) / 1000.0; + GLfloat fps = frames / seconds; + printf("%d frames in %g seconds = %g FPS\n", frames, seconds, fps); + t0 = t; + frames = 0; + } + } +} + + +static void +Idle(void) +{ + double t = glutGet(GLUT_ELAPSED_TIME) / 1000.0; + struct window *w; + for (w = FirstWindow; w; w = w->next) { + if (w->anim) { + double dt; + if (w->t0 < 0.0) + w->t0 = t; + dt = t - w->t0; + w->t0 = t; + w->spin += 60.0 * dt; + w->yrot += 90.0 * dt; + assert(w->id); + glutSetWindow(w->id); + glutPostRedisplay(); + } + } +} + + +static void +UpdateIdleFunc(void) +{ + if (AnyAnimating()) + glutIdleFunc(Idle); + else + glutIdleFunc(NULL); +} + +static void +Key(unsigned char key, int x, int y) +{ + struct window *w = CurrentWindow(); + (void) x; + (void) y; + + switch (key) { + case 'd': + w->showBuffer = GL_DEPTH; + glutPostRedisplay(); + break; + case 's': + w->showBuffer = GL_STENCIL; + glutPostRedisplay(); + break; + case 'a': + w->showBuffer = GL_ALPHA; + glutPostRedisplay(); + break; + case 'c': + w->showBuffer = GL_NONE; + glutPostRedisplay(); + break; + case 'f': + if (w->drawBuffer == GL_FRONT) + w->drawBuffer = GL_BACK; + else + w->drawBuffer = GL_FRONT; + glutPostRedisplay(); + break; + case '0': + w->drawBuffer = GL_NONE; + glutPostRedisplay(); + break; + case ' ': + w->anim = !w->anim; + w->t0 = -1; + UpdateIdleFunc(); + glutPostRedisplay(); + break; + case 'n': + CreateWindow(); + UpdateIdleFunc(); + break; + case 'k': + KillWindow(w); + if (FirstWindow == NULL) + exit(0); + break; + case 27: + KillAllWindows(); + exit(0); + break; + default: + ; + } +} + + +static void +SpecialKey(int key, int x, int y) +{ + struct window *w = CurrentWindow(); + (void) x; + (void) y; + switch (key) { + case GLUT_KEY_UP: + w->xrot += 3.0; + if (w->xrot > 85) + w->xrot = 85; + break; + case GLUT_KEY_DOWN: + w->xrot -= 3.0; + if (w->xrot < 5) + w->xrot = 5; + break; + case GLUT_KEY_LEFT: + w->yrot += 3.0; + break; + case GLUT_KEY_RIGHT: + w->yrot -= 3.0; + break; + } + glutPostRedisplay(); +} + + +static void +CreateWindow(void) +{ + char title[1000]; + struct window *w = (struct window *) calloc(1, sizeof(struct window)); + + glutInitWindowSize(INIT_WIDTH, INIT_HEIGHT); + w->id = glutCreateWindow("foo"); + sprintf(title, "reflect window %d", w->id); + glutSetWindowTitle(title); + assert(w->id); + w->width = INIT_WIDTH; + w->height = INIT_HEIGHT; + w->anim = GL_TRUE; + w->xrot = 30.0; + w->yrot = 50.0; + w->spin = 0.0; + w->showBuffer = GL_NONE; + w->drawBuffer = GL_BACK; + + InitWindow(w); + + glutReshapeFunc(Reshape); + glutDisplayFunc(DrawWindow); + glutKeyboardFunc(Key); + glutSpecialFunc(SpecialKey); + + /* insert at head of list */ + w->next = FirstWindow; + FirstWindow = w; +} + + +static void +Usage(void) +{ + printf("Keys:\n"); + printf(" a - show alpha buffer\n"); + printf(" d - show depth buffer\n"); + printf(" s - show stencil buffer\n"); + printf(" c - show color buffer\n"); + printf(" f - toggle rendering to front/back color buffer\n"); + printf(" n - create new window\n"); + printf(" k - kill window\n"); + printf(" SPACE - toggle animation\n"); + printf(" ARROWS - rotate scene\n"); +} + + +int +main(int argc, char *argv[]) +{ + glutInit(&argc, argv); + glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH | + GLUT_STENCIL | GLUT_ALPHA); + CreateWindow(); + glutIdleFunc(Idle); + Usage(); + glutMainLoop(); + return 0; +} diff --git a/progs/demos/renormal.c b/progs/demos/renormal.c new file mode 100644 index 00000000000..9e5da95484c --- /dev/null +++ b/progs/demos/renormal.c @@ -0,0 +1,139 @@ + +/* + * Test GL_EXT_rescale_normal extension + * Brian Paul January 1998 This program is in the public domain. + */ + +#include +#include +#include +#include + + +static GLfloat Phi = 0.0; + + +static void Idle( void ) +{ + static double t0 = -1.; + double dt, t = glutGet(GLUT_ELAPSED_TIME) / 1000.0; + if (t0 < 0.0) + t0 = t; + dt = t - t0; + t0 = t; + Phi += 3.0 * dt; + glutPostRedisplay(); +} + + +static void Display( void ) +{ + GLfloat scale = 0.6 + 0.5 * sin(Phi); + glClear( GL_COLOR_BUFFER_BIT ); + glPushMatrix(); + glScalef(scale, scale, scale); + glutSolidSphere(2.0, 20, 20); + glPopMatrix(); + glutSwapBuffers(); +} + + +static void Reshape( int width, int height ) +{ + glViewport( 0, 0, width, height ); + glMatrixMode( GL_PROJECTION ); + glLoadIdentity(); + glFrustum( -1.0, 1.0, -1.0, 1.0, 5.0, 25.0 ); + glMatrixMode( GL_MODELVIEW ); + glLoadIdentity(); + glTranslatef( 0.0, 0.0, -15.0 ); +} + + + +static void Init( void ) +{ + static GLfloat mat[4] = { 0.8, 0.8, 0.0, 1.0 }; + static GLfloat pos[4] = { -1.0, 1.0, 1.0, 0.0 }; + + /* setup lighting, etc */ + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, mat); + glLightfv(GL_LIGHT0, GL_POSITION, pos); + + glEnable(GL_CULL_FACE); + + glDisable(GL_RESCALE_NORMAL_EXT); + glDisable(GL_NORMALIZE); +} + + +#define UNSCALED 1 +#define NORMALIZE 2 +#define RESCALE 3 +#define QUIT 4 + + +static void ModeMenu(int entry) +{ + if (entry==UNSCALED) { + glDisable(GL_RESCALE_NORMAL_EXT); + glDisable(GL_NORMALIZE); + } + else if (entry==NORMALIZE) { + glEnable(GL_NORMALIZE); + glDisable(GL_RESCALE_NORMAL_EXT); + } + else if (entry==RESCALE) { + glDisable(GL_NORMALIZE); + glEnable(GL_RESCALE_NORMAL_EXT); + } + else if (entry==QUIT) { + exit(0); + } + glutPostRedisplay(); +} + +static void +key(unsigned char k, int x, int y) +{ + (void) x; + (void) y; + switch (k) { + case 27: /* Escape */ + exit(0); + break; + default: + return; + } + glutPostRedisplay(); +} + +int main( int argc, char *argv[] ) +{ + glutInit( &argc, argv ); + glutInitWindowPosition(0, 0); + glutInitWindowSize( 400, 400 ); + + glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE ); + + glutCreateWindow(argv[0]); + + Init(); + + glutIdleFunc( Idle ); + glutReshapeFunc( Reshape ); + glutDisplayFunc( Display ); + glutKeyboardFunc(key); + + glutCreateMenu(ModeMenu); + glutAddMenuEntry("Unscaled", UNSCALED); + glutAddMenuEntry("Normalize", NORMALIZE); + glutAddMenuEntry("Rescale EXT", RESCALE); + glutAddMenuEntry("Quit", QUIT); + glutAttachMenu(GLUT_RIGHT_BUTTON); + + glutMainLoop(); + return 0; +} diff --git a/progs/demos/shadowtex.c b/progs/demos/shadowtex.c new file mode 100644 index 00000000000..b32fb45b4fa --- /dev/null +++ b/progs/demos/shadowtex.c @@ -0,0 +1,766 @@ +/* + * Shadow demo using the GL_ARB_depth_texture, GL_ARB_shadow and + * GL_ARB_shadow_ambient extensions. + * + * Brian Paul + * 19 Feb 2001 + * + * Added GL_EXT_shadow_funcs support on 23 March 2002 + * Added GL_EXT_packed_depth_stencil support on 15 March 2006. + * Added GL_EXT_framebuffer_object support on 27 March 2006. + * Removed old SGIX extension support on 5 April 2006. + * + * Copyright (C) 1999-2006 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. + */ + +#define GL_GLEXT_PROTOTYPES +#include +#include +#include +#include +#include +#include "showbuffer.h" + +#define DEG_TO_RAD (3.14159 / 180.0) + +static GLint WindowWidth = 450, WindowHeight = 300; +static GLfloat Xrot = 15, Yrot = 0, Zrot = 0; + +static GLfloat Red[4] = {1, 0, 0, 1}; +static GLfloat Green[4] = {0, 1, 0, 1}; +static GLfloat Blue[4] = {0, 0, 1, 1}; +static GLfloat Yellow[4] = {1, 1, 0, 1}; + +static GLfloat LightDist = 10; +static GLfloat LightLatitude = 45.0; +static GLfloat LightLongitude = 45.0; +static GLfloat LightPos[4]; +static GLfloat SpotDir[3]; +static GLfloat SpotAngle = 40.0 * DEG_TO_RAD; +static GLfloat ShadowNear = 4.0, ShadowFar = 24.0; +static GLint ShadowTexWidth = 256, ShadowTexHeight = 256; + +static GLboolean LinearFilter = GL_FALSE; + +static GLfloat Bias = -0.06; + +static GLboolean Anim = GL_TRUE; + +static GLboolean NeedNewShadowMap = GL_FALSE; +static GLuint ShadowTexture, GrayTexture; +static GLuint ShadowFBO; + +static GLboolean HaveFBO = GL_FALSE; +static GLboolean UseFBO = GL_FALSE; +static GLboolean HavePackedDepthStencil = GL_FALSE; +static GLboolean UsePackedDepthStencil = GL_FALSE; +static GLboolean HaveEXTshadowFuncs = GL_FALSE; +static GLboolean HaveShadowAmbient = GL_FALSE; + +static GLint Operator = 0; +static const GLenum OperatorFunc[8] = { + GL_LEQUAL, GL_LESS, GL_GEQUAL, GL_GREATER, + GL_EQUAL, GL_NOTEQUAL, GL_ALWAYS, GL_NEVER }; +static const char *OperatorName[8] = { + "GL_LEQUAL", "GL_LESS", "GL_GEQUAL", "GL_GREATER", + "GL_EQUAL", "GL_NOTEQUAL", "GL_ALWAYS", "GL_NEVER" }; + + +static GLuint DisplayMode; +#define SHOW_SHADOWS 0 +#define SHOW_DEPTH_IMAGE 1 +#define SHOW_DEPTH_MAPPING 2 +#define SHOW_DISTANCE 3 + + + +static void +DrawScene(void) +{ + GLfloat k = 6; + + /* sphere */ + glPushMatrix(); + glTranslatef(1.6, 2.2, 2.7); + glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, Green); + glColor4fv(Green); + glutSolidSphere(1.5, 15, 15); + glPopMatrix(); + /* dodecahedron */ + glPushMatrix(); + glTranslatef(-2.0, 1.2, 2.1); + glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, Red); + glColor4fv(Red); + glutSolidDodecahedron(); + glPopMatrix(); + /* icosahedron */ + glPushMatrix(); + glTranslatef(-0.6, 1.3, -0.5); + glScalef(1.5, 1.5, 1.5); + glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, Yellow); + glColor4fv(Red); + glutSolidIcosahedron(); + glPopMatrix(); + /* a plane */ + glPushMatrix(); + glTranslatef(0, -1.1, 0); + glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, Blue); + glColor4fv(Blue); + glNormal3f(0, 1, 0); + glBegin(GL_POLYGON); + glVertex3f(-k, 0, -k); + glVertex3f( k, 0, -k); + glVertex3f( k, 0, k); + glVertex3f(-k, 0, k); + glEnd(); + glPopMatrix(); +} + + +/* + * Load the GL_TEXTURE matrix with the projection from the light + * source's point of view. + */ +static void +MakeShadowMatrix(const GLfloat lightPos[4], const GLfloat spotDir[3], + GLfloat spotAngle, GLfloat shadowNear, GLfloat shadowFar) +{ + GLfloat d; + + glMatrixMode(GL_TEXTURE); + glLoadIdentity(); + glTranslatef(0.5, 0.5, 0.5 + Bias); + glScalef(0.5, 0.5, 0.5); + d = shadowNear * tan(spotAngle); + glFrustum(-d, d, -d, d, shadowNear, shadowFar); + gluLookAt(lightPos[0], lightPos[1], lightPos[2], + lightPos[0] + spotDir[0], + lightPos[1] + spotDir[1], + lightPos[2] + spotDir[2], + 0, 1, 0); + glMatrixMode(GL_MODELVIEW); +} + + +static void +EnableIdentityTexgen(void) +{ + /* texgen so that texcoord = vertex coord */ + static GLfloat sPlane[4] = { 1, 0, 0, 0 }; + static GLfloat tPlane[4] = { 0, 1, 0, 0 }; + static GLfloat rPlane[4] = { 0, 0, 1, 0 }; + static GLfloat qPlane[4] = { 0, 0, 0, 1 }; + + glTexGenfv(GL_S, GL_EYE_PLANE, sPlane); + glTexGenfv(GL_T, GL_EYE_PLANE, tPlane); + glTexGenfv(GL_R, GL_EYE_PLANE, rPlane); + glTexGenfv(GL_Q, GL_EYE_PLANE, qPlane); + glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR); + glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR); + glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR); + glTexGeni(GL_Q, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR); + + glEnable(GL_TEXTURE_GEN_S); + glEnable(GL_TEXTURE_GEN_T); + glEnable(GL_TEXTURE_GEN_R); + glEnable(GL_TEXTURE_GEN_Q); +} + + +/* + * Setup 1-D texgen so that the distance from the light source, between + * the near and far planes maps to s=0 and s=1. When we draw the scene, + * the grayness will indicate the fragment's distance from the light + * source. + */ +static void +EnableDistanceTexgen(const GLfloat lightPos[4], const GLfloat lightDir[3], + GLfloat lightNear, GLfloat lightFar) +{ + GLfloat m, d; + GLfloat sPlane[4]; + GLfloat nearPoint[3]; + + m = sqrt(lightDir[0] * lightDir[0] + + lightDir[1] * lightDir[1] + + lightDir[2] * lightDir[2]); + + d = lightFar - lightNear; + + /* nearPoint = point on light direction vector which intersects the + * near plane of the light frustum. + */ + nearPoint[0] = lightPos[0] + lightDir[0] / m * lightNear; + nearPoint[1] = lightPos[1] + lightDir[1] / m * lightNear; + nearPoint[2] = lightPos[2] + lightDir[2] / m * lightNear; + + sPlane[0] = lightDir[0] / d / m; + sPlane[1] = lightDir[1] / d / m; + sPlane[2] = lightDir[2] / d / m; + sPlane[3] = -(sPlane[0] * nearPoint[0] + + sPlane[1] * nearPoint[1] + + sPlane[2] * nearPoint[2]); + + glTexGenfv(GL_S, GL_EYE_PLANE, sPlane); + glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR); + glEnable(GL_TEXTURE_GEN_S); +} + + +static void +DisableTexgen(void) +{ + glDisable(GL_TEXTURE_GEN_S); + glDisable(GL_TEXTURE_GEN_T); + glDisable(GL_TEXTURE_GEN_R); + glDisable(GL_TEXTURE_GEN_Q); +} + + +static void +ComputeLightPos(GLfloat dist, GLfloat latitude, GLfloat longitude, + GLfloat pos[4], GLfloat dir[3]) +{ + + pos[0] = dist * sin(longitude * DEG_TO_RAD); + pos[1] = dist * sin(latitude * DEG_TO_RAD); + pos[2] = dist * cos(latitude * DEG_TO_RAD) * cos(longitude * DEG_TO_RAD); + pos[3] = 1; + dir[0] = -pos[0]; + dir[1] = -pos[1]; + dir[2] = -pos[2]; +} + + +/** + * Render the shadow map / depth texture. + * The result will be in the texture object named ShadowTexture. + */ +static void +RenderShadowMap(void) +{ + GLenum depthFormat; /* GL_DEPTH_COMPONENT or GL_DEPTH_STENCIL_EXT */ + GLenum depthType; /* GL_UNSIGNED_INT_24_8_EXT or GL_UNSIGNED_INT */ + float d; + + if (WindowWidth >= 1024 && WindowHeight >= 1024) { + ShadowTexWidth = ShadowTexHeight = 1024; + } + else if (WindowWidth >= 512 && WindowHeight >= 512) { + ShadowTexWidth = ShadowTexHeight = 512; + } + else if (WindowWidth >= 256 && WindowHeight >= 256) { + ShadowTexWidth = ShadowTexHeight = 256; + } + else { + ShadowTexWidth = ShadowTexHeight = 128; + } + printf("Rendering %d x %d depth texture\n", ShadowTexWidth, ShadowTexHeight); + + if (UsePackedDepthStencil) { + depthFormat = GL_DEPTH_STENCIL_EXT; + depthType = GL_UNSIGNED_INT_24_8_EXT; + } + else { + depthFormat = GL_DEPTH_COMPONENT; + depthType = GL_UNSIGNED_INT; + } + + /* compute frustum to enclose spot light cone */ + d = ShadowNear * tan(SpotAngle); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glFrustum(-d, d, -d, d, ShadowNear, ShadowFar); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + gluLookAt(LightPos[0], LightPos[1], LightPos[2], /* from */ + 0, 0, 0, /* target */ + 0, 1, 0); /* up */ + + if (UseFBO) { + glTexImage2D(GL_TEXTURE_2D, 0, depthFormat, + ShadowTexWidth, ShadowTexHeight, 0, + depthFormat, depthType, NULL); + glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, ShadowFBO); + glDrawBuffer(GL_NONE); + glReadBuffer(GL_NONE); + assert(glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT) + == GL_FRAMEBUFFER_COMPLETE_EXT); + } + + assert(!glIsEnabled(GL_TEXTURE_1D)); + assert(!glIsEnabled(GL_TEXTURE_2D)); + + glViewport(0, 0, ShadowTexWidth, ShadowTexHeight); + glClear(GL_DEPTH_BUFFER_BIT); + glEnable(GL_DEPTH_TEST); + DrawScene(); + + if (UseFBO) { + /* all done! */ + glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); + } + else { + /* + * copy depth buffer into the texture map + */ + if (DisplayMode == SHOW_DEPTH_MAPPING) { + /* load depth image as gray-scale luminance texture */ + GLuint *depth = (GLuint *) + malloc(ShadowTexWidth * ShadowTexHeight * sizeof(GLuint)); + assert(depth); + glReadPixels(0, 0, ShadowTexWidth, ShadowTexHeight, + depthFormat, depthType, depth); + glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, + ShadowTexWidth, ShadowTexHeight, 0, + GL_LUMINANCE, GL_UNSIGNED_INT, depth); + free(depth); + } + else { + /* The normal shadow case - a real depth texture */ + glCopyTexImage2D(GL_TEXTURE_2D, 0, depthFormat, + 0, 0, ShadowTexWidth, ShadowTexHeight, 0); + if (UsePackedDepthStencil) { + /* debug check */ + GLint intFormat; + glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, + GL_TEXTURE_INTERNAL_FORMAT, &intFormat); + assert(intFormat == GL_DEPTH_STENCIL_EXT); + } + } + } +} + + +/** + * Show the shadow map as a grayscale image. + */ +static void +ShowShadowMap(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glMatrixMode(GL_TEXTURE); + glLoadIdentity(); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(0, WindowWidth, 0, WindowHeight, -1, 1); + + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + + glDisable(GL_DEPTH_TEST); + glDisable(GL_LIGHTING); + + glEnable(GL_TEXTURE_2D); + + DisableTexgen(); + + /* interpret texture's depth values as luminance values */ +#if defined(GL_ARB_shadow) + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, GL_NONE); + glTexParameteri(GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE_ARB, GL_LUMINANCE); +#endif + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); + + glBegin(GL_POLYGON); + glTexCoord2f(0, 0); glVertex2f(0, 0); + glTexCoord2f(1, 0); glVertex2f(ShadowTexWidth, 0); + glTexCoord2f(1, 1); glVertex2f(ShadowTexWidth, ShadowTexHeight); + glTexCoord2f(0, 1); glVertex2f(0, ShadowTexHeight); + glEnd(); + + glDisable(GL_TEXTURE_2D); + glEnable(GL_DEPTH_TEST); + glEnable(GL_LIGHTING); +} + + +/** + * Redraw window image + */ +static void +Display(void) +{ + GLenum error; + + ComputeLightPos(LightDist, LightLatitude, LightLongitude, + LightPos, SpotDir); + + if (NeedNewShadowMap) { + RenderShadowMap(); + NeedNewShadowMap = GL_FALSE; + } + + glViewport(0, 0, WindowWidth, WindowHeight); + if (DisplayMode == SHOW_DEPTH_IMAGE) { + ShowShadowMap(); + } + else { + /* prepare to draw scene from camera's view */ + const GLfloat ar = (GLfloat) WindowWidth / (GLfloat) WindowHeight; + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glFrustum(-ar, ar, -1.0, 1.0, 4.0, 50.0); + + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTranslatef(0.0, 0.0, -22.0); + glRotatef(Xrot, 1, 0, 0); + glRotatef(Yrot, 0, 1, 0); + glRotatef(Zrot, 0, 0, 1); + + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + glLightfv(GL_LIGHT0, GL_POSITION, LightPos); + + if (LinearFilter) { + 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); + } + + if (DisplayMode == SHOW_DEPTH_MAPPING) { +#if defined(GL_ARB_shadow) + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, GL_NONE); +#endif + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); + glEnable(GL_TEXTURE_2D); + MakeShadowMatrix(LightPos, SpotDir, SpotAngle, ShadowNear, ShadowFar); + EnableIdentityTexgen(); + } + else if (DisplayMode == SHOW_DISTANCE) { + glMatrixMode(GL_TEXTURE); + glLoadIdentity(); + glMatrixMode(GL_MODELVIEW); + EnableDistanceTexgen(LightPos, SpotDir, ShadowNear+Bias, ShadowFar); + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); + glEnable(GL_TEXTURE_1D); + assert(!glIsEnabled(GL_TEXTURE_2D)); + } + else { + assert(DisplayMode == SHOW_SHADOWS); +#if defined(GL_ARB_shadow) + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, + GL_COMPARE_R_TO_TEXTURE_ARB); +#endif + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + glEnable(GL_TEXTURE_2D); + MakeShadowMatrix(LightPos, SpotDir, SpotAngle, ShadowNear, ShadowFar); + EnableIdentityTexgen(); + } + + DrawScene(); + + DisableTexgen(); + glDisable(GL_TEXTURE_1D); + glDisable(GL_TEXTURE_2D); + } + + glutSwapBuffers(); + + error = glGetError(); + if (error) { + printf("GL Error: %s\n", (char *) gluErrorString(error)); + } +} + + +static void +Reshape(int width, int height) +{ + WindowWidth = width; + WindowHeight = height; + NeedNewShadowMap = GL_TRUE; +} + + +static void +Idle(void) +{ + static double t0 = -1.; + double dt, t = glutGet(GLUT_ELAPSED_TIME) / 1000.0; + if (t0 < 0.0) + t0 = t; + dt = t - t0; + t0 = t; + Yrot += 75.0 * dt; + /*LightLongitude -= 5.0;*/ + glutPostRedisplay(); +} + + +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 'b': + Bias -= 0.01; + printf("Bias %g\n", Bias); + break; + case 'B': + Bias += 0.01; + printf("Bias %g\n", Bias); + break; + case 'd': + DisplayMode = SHOW_DISTANCE; + break; + case 'f': + LinearFilter = !LinearFilter; + printf("%s filtering\n", LinearFilter ? "Bilinear" : "Nearest"); + break; + case 'i': + DisplayMode = SHOW_DEPTH_IMAGE; + break; + case 'm': + DisplayMode = SHOW_DEPTH_MAPPING; + break; + case 'n': + case 's': + case ' ': + DisplayMode = SHOW_SHADOWS; + break; + case 'o': + if (HaveEXTshadowFuncs) { + Operator++; + if (Operator >= 8) + Operator = 0; + printf("Operator: %s\n", OperatorName[Operator]); +#if defined(GL_ARB_shadow) + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC_ARB, + OperatorFunc[Operator]); +#endif + } + break; + case 'p': + UsePackedDepthStencil = !UsePackedDepthStencil; + if (UsePackedDepthStencil && !HavePackedDepthStencil) { + printf("Sorry, GL_EXT_packed_depth_stencil not supported\n"); + UsePackedDepthStencil = GL_FALSE; + } + else { + printf("Use GL_DEPTH_STENCIL_EXT: %d\n", UsePackedDepthStencil); + /* Don't really need to regenerate shadow map texture, but do so + * to exercise more code more often. + */ + NeedNewShadowMap = GL_TRUE; + } + break; + case 'z': + Zrot -= step; + break; + case 'Z': + Zrot += step; + break; + case 27: + exit(0); + break; + } + glutPostRedisplay(); +} + + +static void +SpecialKey(int key, int x, int y) +{ + const GLfloat step = 3.0; + const int mod = glutGetModifiers(); + (void) x; + (void) y; + switch (key) { + case GLUT_KEY_UP: + if (mod) + LightLatitude += step; + else + Xrot += step; + break; + case GLUT_KEY_DOWN: + if (mod) + LightLatitude -= step; + else + Xrot -= step; + break; + case GLUT_KEY_LEFT: + if (mod) + LightLongitude += step; + else + Yrot += step; + break; + case GLUT_KEY_RIGHT: + if (mod) + LightLongitude -= step; + else + Yrot -= step; + break; + } + if (mod) + NeedNewShadowMap = GL_TRUE; + + glutPostRedisplay(); +} + + +static void +Init(void) +{ + static const GLfloat borderColor[4] = {1.0, 0.0, 0.0, 0.0}; + +#if defined(GL_ARB_depth_texture) && defined(GL_ARB_shadow) + if (!glutExtensionSupported("GL_ARB_depth_texture") || + !glutExtensionSupported("GL_ARB_shadow")) { +#else + if (1) { +#endif + printf("Sorry, this demo requires the GL_ARB_depth_texture and GL_ARB_shadow extensions\n"); + exit(1); + } + printf("Using GL_ARB_depth_texture and GL_ARB_shadow\n"); + +#if defined(GL_ARB_shadow_ambient) + HaveShadowAmbient = glutExtensionSupported("GL_ARB_shadow_ambient"); + if (HaveShadowAmbient) { + printf("and GL_ARB_shadow_ambient\n"); + } +#endif + + HaveEXTshadowFuncs = glutExtensionSupported("GL_EXT_shadow_funcs"); + + HavePackedDepthStencil = glutExtensionSupported("GL_EXT_packed_depth_stencil"); + UsePackedDepthStencil = HavePackedDepthStencil; + +#if defined(GL_EXT_framebuffer_object) + HaveFBO = glutExtensionSupported("GL_EXT_framebuffer_object"); + UseFBO = HaveFBO; + if (UseFBO) { + printf("Using GL_EXT_framebuffer_object\n"); + } +#endif + + /* + * Set up the 2D shadow map texture + */ + glGenTextures(1, &ShadowTexture); + glBindTexture(GL_TEXTURE_2D, ShadowTexture); + glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, borderColor); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); +#if defined(GL_ARB_shadow) + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, + GL_COMPARE_R_TO_TEXTURE_ARB); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC_ARB, GL_LEQUAL); +#endif + if (HaveShadowAmbient) { +#if defined(GL_ARB_shadow_ambient) + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FAIL_VALUE_ARB, 0.3); +#endif + } + +#if defined(GL_EXT_framebuffer_object) + if (UseFBO) { + glGenFramebuffersEXT(1, &ShadowFBO); + glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, ShadowFBO); + glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, + GL_COLOR_ATTACHMENT0_EXT, + GL_RENDERBUFFER_EXT, 0); + glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, + GL_TEXTURE_2D, ShadowTexture, 0); + + glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); + } +#endif + + /* + * Setup 1-D grayscale texture image for SHOW_DISTANCE mode + */ + glGenTextures(1, &GrayTexture); + glBindTexture(GL_TEXTURE_1D, GrayTexture); + glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, GL_CLAMP); + glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_WRAP_T, GL_CLAMP); + glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + { + GLuint i; + GLubyte image[256]; + for (i = 0; i < 256; i++) + image[i] = i; + glTexImage1D(GL_TEXTURE_1D, 0, GL_LUMINANCE, + 256, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, image); + } + + glEnable(GL_DEPTH_TEST); + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); +} + + +static void +PrintHelp(void) +{ + printf("Keys:\n"); + printf(" a = toggle animation\n"); + printf(" i = show depth texture image\n"); + printf(" m = show depth texture mapping\n"); + printf(" d = show fragment distance from light source\n"); + printf(" n = show normal, shadowed image\n"); + printf(" f = toggle nearest/bilinear texture filtering\n"); + printf(" b/B = decrease/increase shadow map Z bias\n"); + printf(" p = toggle use of packed depth/stencil\n"); + printf(" cursor keys = rotate scene\n"); + printf(" + cursor keys = rotate light source\n"); + if (HaveEXTshadowFuncs) + printf(" o = cycle through comparison modes\n"); +} + + +int +main(int argc, char *argv[]) +{ + glutInit(&argc, argv); + glutInitWindowPosition(0, 0); + glutInitWindowSize(WindowWidth, WindowHeight); + glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH | GLUT_STENCIL); + glutCreateWindow(argv[0]); + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutSpecialFunc(SpecialKey); + glutDisplayFunc(Display); + if (Anim) + glutIdleFunc(Idle); + Init(); + PrintHelp(); + glutMainLoop(); + return 0; +} diff --git a/progs/demos/singlebuffer.c b/progs/demos/singlebuffer.c new file mode 100644 index 00000000000..9899c245b2a --- /dev/null +++ b/progs/demos/singlebuffer.c @@ -0,0 +1,269 @@ +/* + * Demo of (nearly) flicker-free drawing with a single color buffer. + * + * Basically, draw the scene into the Z buffer first, then draw the + * scene into the color buffer. Finally, "clear" the background by + * setting the fragments we didn't hit earlier. + * + * This won't work if you need blending. The technique works best + * when the scene is relatively simple and can be rendered quickly + * (i.e. with hardware), and when the objects don't move too much from + * one frame to the next. + * + * Brian Paul + * 25 August 2005 + * + * See Mesa license for terms. + */ + + +#include +#include +#include + + +#define FLICKER 0 +#define NO_FLICKER 1 + +static GLint Mode = NO_FLICKER; +static GLfloat Xrot = 0, Yrot = 0, Zrot = 0; +static GLboolean Anim = GL_TRUE; +static GLfloat ClearColor[4] = {0.2, 0.2, 0.9, 0.0}; +static GLfloat NearClip = 5.0, FarClip = 25.0, ViewDist = 7.0; +static double PrevTime = -1; + +struct box { + float tx, ty, tz; + float rx, ry, rz, ra; + float sx, sy, sz; + float color[4]; +}; + +#define NUM_BOXES 25 + +struct box Boxes[NUM_BOXES]; + + +/* Return random float in [0,1] */ +static float +Random(void) +{ + int i = rand(); + return (float) (i % 1000) / 1000.0; +} + + +static void +MakeBoxes(void) +{ + int i; + for (i = 0; i < NUM_BOXES; i++) { + Boxes[i].tx = -1.0 + 2.0 * Random(); + Boxes[i].ty = -1.0 + 2.0 * Random(); + Boxes[i].tz = -1.0 + 2.0 * Random(); + Boxes[i].sx = 0.1 + Random() * 0.4; + Boxes[i].sy = 0.1 + Random() * 0.4; + Boxes[i].sz = 0.1 + Random() * 0.4; + Boxes[i].rx = Random(); + Boxes[i].ry = Random(); + Boxes[i].rz = Random(); + Boxes[i].ra = Random() * 360.0; + Boxes[i].color[0] = Random(); + Boxes[i].color[1] = Random(); + Boxes[i].color[2] = Random(); + Boxes[i].color[3] = 1.0; + } +} + + +static void +DrawBoxes(void) +{ + int i; + for (i = 0; i < NUM_BOXES; i++) { + glPushMatrix(); + glTranslatef(Boxes[i].tx, Boxes[i].ty, Boxes[i].tz); + glRotatef(Boxes[i].ra, Boxes[i].rx, Boxes[i].ry, Boxes[i].rz); + glScalef(Boxes[i].sx, Boxes[i].sy, Boxes[i].sz); + glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, Boxes[i].color); + glutSolidCube(1.0); + glPopMatrix(); + } +} + + +static void +Idle(void) +{ + double dt, t = glutGet(GLUT_ELAPSED_TIME) * 0.001; + if (PrevTime < 0.0) + PrevTime = t; + dt = t - PrevTime; + PrevTime = t; + Xrot += 16.0 * dt; + Yrot += 12.0 * dt; + Zrot += 8.0 * dt; + glutPostRedisplay(); +} + + +static void +Draw(void) +{ + if (Mode == FLICKER) { + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + } + else { + /* don't clear color buffer */ + glClear(GL_DEPTH_BUFFER_BIT); + /* update Z buffer only */ + glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); + } + + glPushMatrix(); + glRotatef(Xrot, 1, 0, 0); + glRotatef(Yrot, 0, 1, 0); + glRotatef(Zrot, 0, 0, 1); + + DrawBoxes(); + + if (Mode == NO_FLICKER) { + /* update color buffer now */ + glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); + glDepthFunc(GL_EQUAL); + DrawBoxes(); + glDepthFunc(GL_LESS); + } + + glPopMatrix(); + + if (Mode == NO_FLICKER) { + /* "clear" the untouched pixels now. + * Note: if you comment-out this code you'll see something interesting. + */ + GLfloat x = FarClip / NearClip; + GLfloat z = -(FarClip - ViewDist - 1.0); + glDisable(GL_LIGHTING); + glColor4fv(ClearColor); + glBegin(GL_POLYGON); + glVertex3f(-x, -x, z); + glVertex3f( x, -x, z); + glVertex3f( x, x, z); + glVertex3f(-x, x, z); + glEnd(); + glEnable(GL_LIGHTING); + } + + /* This is where you'd normally do SwapBuffers */ + glFinish(); +} + + +static void +Reshape(int width, int height) +{ + glViewport(0, 0, width, height); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glFrustum(-1.0, 1.0, -1.0, 1.0, NearClip, FarClip); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTranslatef(0.0, 0.0, -ViewDist); +} + + +static void +Key(unsigned char key, int x, int y) +{ + (void) x; + (void) y; + switch (key) { + case 'a': + Anim = !Anim; + if (Anim) + glutIdleFunc(Idle); + else + glutIdleFunc(NULL); + PrevTime = -1; + break; + case 'm': + Mode = !Mode; + break; + case 'b': + MakeBoxes(); + 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) +{ + glClearColor(ClearColor[0], ClearColor[1], ClearColor[2], ClearColor[3]); + glEnable(GL_DEPTH_TEST); + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + glEnable(GL_CULL_FACE); + glEnable(GL_NORMALIZE); + MakeBoxes(); +} + + +static void +Usage(void) +{ + printf("Keys:\n"); + printf(" m - toggle drawing mode (flicker vs. no flicker)\n"); + printf(" a - toggle animation\n"); + printf(" b - generate new boxes\n"); + printf(" ARROWS - rotate scene\n"); + printf(" ESC - exit\n"); +} + + +int +main(int argc, char *argv[]) +{ + glutInit(&argc, argv); + glutInitWindowSize(800, 800); + glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE | GLUT_DEPTH); + glutCreateWindow(argv[0]); + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutSpecialFunc(SpecialKey); + glutDisplayFunc(Draw); + if (Anim) + glutIdleFunc(Idle); + Init(); + Usage(); + glutMainLoop(); + return 0; +} diff --git a/progs/demos/spectex.c b/progs/demos/spectex.c new file mode 100644 index 00000000000..6ab1191579c --- /dev/null +++ b/progs/demos/spectex.c @@ -0,0 +1,272 @@ + +/* + * GLUT demonstration of texturing with specular highlights. + * + * When drawing a lit, textured surface one usually wants the specular + * highlight to override the texture colors. However, OpenGL applies + * texturing after lighting so the specular highlight is modulated by + * the texture. + * + * The solution here shown here is a two-pass algorithm: + * 1. Draw the textured surface without specular lighting. + * 2. Enable blending to add the next pass: + * 3. Redraw the surface with a matte white material and only the + * specular components of light sources enabled. + * + * Brian Paul February 1997 + */ + +#include +#include +#include +#include + + +static GLUquadricObj *Quadric; +static GLuint Sphere; +static GLfloat LightPos[4] = {10.0, 10.0, 10.0, 1.0}; +static GLfloat Delta = 20.0; +static GLint Mode = 4; + +/*static GLfloat Blue[4] = {0.0, 0.0, 1.0, 1.0};*/ +/*static GLfloat Gray[4] = {0.5, 0.5, 0.5, 1.0};*/ +static GLfloat Black[4] = {0.0, 0.0, 0.0, 1.0}; +static GLfloat White[4] = {1.0, 1.0, 1.0, 1.0}; + +static GLboolean smooth = 1; + +static void +Idle(void) +{ + static double t0 = -1.; + double dt, t = glutGet(GLUT_ELAPSED_TIME) / 1000.0;; + if (t0 < 0.0) + t0 = t; + dt = t - t0; + t0 = t; + LightPos[0] += Delta * dt; + if (LightPos[0]>15.0 || LightPos[0]<-15.0) + Delta = -Delta; + + glutPostRedisplay(); +} + + +static void Display( void ) +{ + glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); + + glLightfv(GL_LIGHT0, GL_POSITION, LightPos); + + glPushMatrix(); + glRotatef(90.0, 1.0, 0.0, 0.0); + + if (Mode==0) { + /* Typical method: diffuse + specular + texture */ + glEnable(GL_TEXTURE_2D); + glLightfv(GL_LIGHT0, GL_DIFFUSE, White); /* enable diffuse */ + glLightfv(GL_LIGHT0, GL_SPECULAR, White); /* enable specular */ +#ifdef GL_VERSION_1_2 + glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SINGLE_COLOR); +#endif + glCallList(Sphere); + } + else if (Mode==1) { + /* just specular highlight */ + glDisable(GL_TEXTURE_2D); + glLightfv(GL_LIGHT0, GL_DIFFUSE, Black); /* disable diffuse */ + glLightfv(GL_LIGHT0, GL_SPECULAR, White); /* enable specular */ +#ifdef GL_VERSION_1_2 + glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SINGLE_COLOR); +#endif + glCallList(Sphere); + } + else if (Mode==2) { + /* diffuse textured */ + glEnable(GL_TEXTURE_2D); + glLightfv(GL_LIGHT0, GL_DIFFUSE, White); /* enable diffuse */ + glLightfv(GL_LIGHT0, GL_SPECULAR, Black); /* disable specular */ +#ifdef GL_VERSION_1_2 + glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SINGLE_COLOR); +#endif + glCallList(Sphere); + } + else if (Mode==3) { + /* 2-pass: diffuse textured then add specular highlight*/ + glEnable(GL_TEXTURE_2D); + glLightfv(GL_LIGHT0, GL_DIFFUSE, White); /* enable diffuse */ + glLightfv(GL_LIGHT0, GL_SPECULAR, Black); /* disable specular */ +#ifdef GL_VERSION_1_2 + glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SINGLE_COLOR); +#endif + glCallList(Sphere); + /* specular highlight */ + glDepthFunc(GL_EQUAL); /* redraw same pixels */ + glDisable(GL_TEXTURE_2D); + glEnable(GL_BLEND); /* add */ + glLightfv(GL_LIGHT0, GL_DIFFUSE, Black); /* disable diffuse */ + glLightfv(GL_LIGHT0, GL_SPECULAR, White); /* enable specular */ + glCallList(Sphere); + glDepthFunc(GL_LESS); + glDisable(GL_BLEND); + } + else if (Mode==4) { + /* OpenGL 1.2's separate diffuse and specular color */ + glEnable(GL_TEXTURE_2D); + glLightfv(GL_LIGHT0, GL_DIFFUSE, White); /* enable diffuse */ + glLightfv(GL_LIGHT0, GL_SPECULAR, White); /* enable specular */ +#ifdef GL_VERSION_1_2 + glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR); +#endif + glCallList(Sphere); + } + + glPopMatrix(); + + glutSwapBuffers(); +} + + +static void Reshape( int width, int height ) +{ + glViewport( 0, 0, width, height ); + glMatrixMode( GL_PROJECTION ); + glLoadIdentity(); + glFrustum( -1.0, 1.0, -1.0, 1.0, 5.0, 25.0 ); + glMatrixMode( GL_MODELVIEW ); + glLoadIdentity(); + glTranslatef( 0.0, 0.0, -12.0 ); +} + + +static void Key( unsigned char key, int x, int y ) +{ + (void) x; + (void) y; + switch (key) { + case 27: + exit(0); + break; + case 's': + smooth = !smooth; + if (smooth) + glShadeModel(GL_SMOOTH); + else + glShadeModel(GL_FLAT); + break; + } + glutPostRedisplay(); +} + + +static void SpecialKey( int key, int x, int y ) +{ + (void) x; + (void) y; + switch (key) { + case GLUT_KEY_UP: + break; + case GLUT_KEY_DOWN: + break; + } + glutPostRedisplay(); +} + + +static void Init( void ) +{ + int i, j; + GLubyte texImage[64][64][3]; + + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, 0); + glLightModelfv(GL_LIGHT_MODEL_AMBIENT, Black); + + glShadeModel(GL_SMOOTH); + + glMaterialfv(GL_FRONT, GL_DIFFUSE, White); + glMaterialfv(GL_FRONT, GL_SPECULAR, White); + glMaterialf(GL_FRONT, GL_SHININESS, 20.0); + + /* Actually, these are set again later */ + glLightfv(GL_LIGHT0, GL_DIFFUSE, White); + glLightfv(GL_LIGHT0, GL_SPECULAR, White); + + Quadric = gluNewQuadric(); + gluQuadricTexture( Quadric, GL_TRUE ); + + Sphere= glGenLists(1); + glNewList( Sphere, GL_COMPILE ); + gluSphere( Quadric, 1.0, 24, 24 ); + glEndList(); + + glEnable(GL_DEPTH_TEST); + glEnable(GL_CULL_FACE); + + for (i=0;i<64;i++) { + for (j=0;j<64;j++) { + int k = ((i>>3)&1) ^ ((j>>3)&1); + texImage[i][j][0] = 255*k; + texImage[i][j][1] = 255*(1-k); + texImage[i][j][2] = 0; + } + } + + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + glTexImage2D( GL_TEXTURE_2D, + 0, + 3, + 64, 64, + 0, + GL_RGB, GL_UNSIGNED_BYTE, + texImage ); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glEnable(GL_TEXTURE_2D); + + glBlendFunc(GL_ONE, GL_ONE); +} + + +static void ModeMenu(int entry) +{ + if (entry==99) + exit(0); + Mode = entry; +} + + +int main( int argc, char *argv[] ) +{ + + glutInit( &argc, argv ); + glutInitWindowPosition( 0, 0 ); + glutInitWindowSize( 300, 300 ); + + glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ); + + glutCreateWindow( "spectex" ); + + Init(); + + glutReshapeFunc( Reshape ); + glutKeyboardFunc( Key ); + glutSpecialFunc( SpecialKey ); + glutDisplayFunc( Display ); + glutIdleFunc( Idle ); + + glutCreateMenu( ModeMenu ); + glutAddMenuEntry("1-pass lighting + texturing", 0); + glutAddMenuEntry("specular lighting", 1); + glutAddMenuEntry("diffuse lighting + texturing", 2); + glutAddMenuEntry("2-pass lighting + texturing", 3); +#ifdef GL_VERSION_1_2 + glutAddMenuEntry("OpenGL 1.2 separate specular", 4); +#endif + glutAddMenuEntry("Quit", 99); + glutAttachMenu(GLUT_RIGHT_BUTTON); + + glutMainLoop(); + return 0; +} diff --git a/progs/demos/spriteblast.c b/progs/demos/spriteblast.c new file mode 100644 index 00000000000..d6e9a4de2fd --- /dev/null +++ b/progs/demos/spriteblast.c @@ -0,0 +1,554 @@ + +/* Copyright (c) Mark J. Kilgard, 1997. */ + +/* This program is freely distributable without licensing fees + and is provided without guarantee or warrantee expressed or + implied. This program is -not- in the public domain. */ + +/* This example demonstrates how to render particle effects + with OpenGL. A cloud of pinkish/orange particles explodes with the + particles bouncing off the ground. When the EXT_point_parameters + is present , the particle size is attenuated based on eye distance. */ + + +/* Modified by Brian Paul to test GL_ARB_point_sprite */ + + +#include +#include +#include +#include /* for cos(), sin(), and sqrt() */ +#ifdef _WIN32 +#include +#endif +#define GL_GLEXT_PROTOTYPES +#include + +/* Some files do not define M_PI... */ +#ifndef M_PI +#define M_PI 3.14159265 +#endif + +#if 0 /* For debugging. */ +#undef GL_EXT_point_parameters +#endif + +static GLfloat angle = -150; /* in degrees */ +static int spin = 0; +static int moving, begin; +static float theTime; +static int repeat = 1; +static int blend = 1; +int useMipmaps = 1; +int linearFiltering = 1; + +static GLfloat constant[3] = { .2, 0.0, 0.0 }; +static GLfloat linear[3] = { .0, .1, 0.0 }; +static GLfloat theQuad[3] = { .005, 0.1, 1/600.0 }; + +#define MAX_POINTS 2000 + +static int numPoints = 200; + +static GLfloat pointList[MAX_POINTS][3]; +static GLfloat pointTime[MAX_POINTS]; +static GLfloat pointVelocity[MAX_POINTS][2]; +static GLfloat pointDirection[MAX_POINTS][2]; +static int colorList[MAX_POINTS]; +static int animate = 1, motion = 0, org = 0, sprite = 1, smooth = 1; + +static GLfloat colorSet[][4] = { + /* Shades of red. */ + { 0.7, 0.2, 0.4, 0.5 }, + { 0.8, 0.0, 0.7, 0.5 }, + { 1.0, 0.0, 0.0, 0.5 }, + { 0.9, 0.3, 0.6, 0.5 }, + { 1.0, 0.4, 0.0, 0.5 }, + { 1.0, 0.0, 0.5, 0.5 }, +}; + +#define NUM_COLORS (sizeof(colorSet)/sizeof(colorSet[0])) + +#define DEAD (NUM_COLORS+1) + + +/* GL */ +static GLint spritePattern[16][16] = { + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0 }, + { 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0 }, + { 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0 }, + { 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0 }, + { 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0 }, + { 0, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0 }, + { 0, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0 }, + { 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0 }, + { 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0 }, + { 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } +}; + + + + +#if 0 /* drand48 might be better on Unix machines */ +#define RANDOM_RANGE(lo, hi) ((lo) + (hi - lo) * drand48()) +#else +static float float_rand(void) { return rand() / (float) RAND_MAX; } +#define RANDOM_RANGE(lo, hi) ((lo) + (hi - lo) * float_rand()) +#endif + +#define MEAN_VELOCITY 3.0 +#define GRAVITY 2.0 + +/* Modeling units of ground extent in each X and Z direction. */ +#define EDGE 12 + +static void +makePointList(void) +{ + float angle, velocity, direction; + int i; + + motion = 1; + for (i=0; i EDGE) { + /* Particle has hit ground past the distance duration of + the particles. Mark particle as dead. */ + colorList[i] = NUM_COLORS; /* Not moving. */ + continue; + } + + pointVelocity[i][1] *= 0.8; /* 80% of previous up velocity. */ + pointTime[i] = 0.0; /* Reset the particles sense of up time. */ + } + motion = 1; + pointTime[i] += dt; + } + theTime += dt; + if (!motion && !spin) { + if (repeat) { + makePointList(); + } else { + glutIdleFunc(NULL); + } + } +} + +static void +idle(void) +{ + updatePointList(); + if (spin) { + angle += 0.3; + } + glutPostRedisplay(); +} + +static void +visible(int vis) +{ + if (vis == GLUT_VISIBLE) { + if (animate && (motion || spin)) { + glutIdleFunc(idle); + } + } else { + glutIdleFunc(NULL); + } +} + +static void +redraw(void) +{ + int i; + + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + glPushMatrix(); + glRotatef(15.0, 1.0, 0.0, 0.0); + glRotatef(angle, 0.0, 1.0, 0.0); + + glDepthMask(GL_FALSE); + + /* Draw the floor. */ +/* glEnable(GL_TEXTURE_2D);*/ + glColor3f(0.1, 0.5, 1.0); + glBegin(GL_QUADS); + glTexCoord2f(0.0, 0.0); + glVertex3f(-EDGE, -0.05, -EDGE); + glTexCoord2f(20.0, 0.0); + glVertex3f(EDGE, -0.05, -EDGE); + glTexCoord2f(20.0, 20.0); + glVertex3f(EDGE, -0.05, EDGE); + glTexCoord2f(0.0, 20.0); + glVertex3f(-EDGE, -0.05, EDGE); + glEnd(); + + /* Allow particles to blend with each other. */ + glDepthMask(GL_TRUE); + + if (blend) + glEnable(GL_BLEND); + + if (sprite) { + glEnable(GL_TEXTURE_2D); +#ifdef GL_ARB_point_sprite + glEnable(GL_POINT_SPRITE_ARB); +#endif + } + + glColor3f(1,1,1); + glBegin(GL_POINTS); + for (i=0; i +#include +#include +#include +#include +#include + + +#ifndef M_PI +#define M_PI 3.14159265358979323846 +#endif + +#define NOISE_TEXTURE 1 +#define GRADIENT_TEXTURE 2 + +#define TORUS 1 +#define SPHERE 2 + +static int tex_width=64, tex_height=64, tex_depth=64; +static float angx=0, angy=0, angz=0; +static int texgen = 2, animate = 1, smooth = 1, wireframe = 0; +static int CurTexture = NOISE_TEXTURE, CurObject = TORUS; + + +static void +BuildTorus(void) +{ + GLint i, j; + float theta1, phi1, theta2, phi2, rings, sides; + float v0[03], v1[3], v2[3], v3[3]; + float t0[03], t1[3], t2[3], t3[3]; + float n0[3], n1[3], n2[3], n3[3]; + float innerRadius = 0.25; + float outerRadius = 0.5; + float scalFac; + + rings = 16; + sides = 12; + scalFac = 1 / (outerRadius * 2); + + glNewList(TORUS, GL_COMPILE); + for (i = 0; i < rings; i++) { + theta1 = (float) i *2.0 * M_PI / rings; + theta2 = (float) (i + 1) * 2.0 * M_PI / rings; + for (j = 0; j < sides; j++) { + phi1 = (float) j *2.0 * M_PI / sides; + phi2 = (float) (j + 1) * 2.0 * M_PI / sides; + + v0[0] = cos(theta1) * (outerRadius + innerRadius * cos(phi1)); + v0[1] = -sin(theta1) * (outerRadius + innerRadius * cos(phi1)); + v0[2] = innerRadius * sin(phi1); + + v1[0] = cos(theta2) * (outerRadius + innerRadius * cos(phi1)); + v1[1] = -sin(theta2) * (outerRadius + innerRadius * cos(phi1)); + v1[2] = innerRadius * sin(phi1); + v2[0] = cos(theta2) * (outerRadius + innerRadius * cos(phi2)); + v2[1] = -sin(theta2) * (outerRadius + innerRadius * cos(phi2)); + v2[2] = innerRadius * sin(phi2); + + v3[0] = cos(theta1) * (outerRadius + innerRadius * cos(phi2)); + v3[1] = -sin(theta1) * (outerRadius + innerRadius * cos(phi2)); + v3[2] = innerRadius * sin(phi2); + + n0[0] = cos(theta1) * (cos(phi1)); + n0[1] = -sin(theta1) * (cos(phi1)); + n0[2] = sin(phi1); + + n1[0] = cos(theta2) * (cos(phi1)); + n1[1] = -sin(theta2) * (cos(phi1)); + n1[2] = sin(phi1); + + n2[0] = cos(theta2) * (cos(phi2)); + n2[1] = -sin(theta2) * (cos(phi2)); + n2[2] = sin(phi2); + + n3[0] = cos(theta1) * (cos(phi2)); + n3[1] = -sin(theta1) * (cos(phi2)); + n3[2] = sin(phi2); + + t0[0] = v0[0] * scalFac + 0.5; + t0[1] = v0[1] * scalFac + 0.5; + t0[2] = v0[2] * scalFac + 0.5; + + t1[0] = v1[0] * scalFac + 0.5; + t1[1] = v1[1] * scalFac + 0.5; + t1[2] = v1[2] * scalFac + 0.5; + + t2[0] = v2[0] * scalFac + 0.5; + t2[1] = v2[1] * scalFac + 0.5; + t2[2] = v2[2] * scalFac + 0.5; + + t3[0] = v3[0] * scalFac + 0.5; + t3[1] = v3[1] * scalFac + 0.5; + t3[2] = v3[2] * scalFac + 0.5; + + glBegin(GL_POLYGON); + glNormal3fv(n3); + glTexCoord3fv(t3); + glVertex3fv(v3); + glNormal3fv(n2); + glTexCoord3fv(t2); + glVertex3fv(v2); + glNormal3fv(n1); + glTexCoord3fv(t1); + glVertex3fv(v1); + glNormal3fv(n0); + glTexCoord3fv(t0); + glVertex3fv(v0); + glEnd(); + } + } + glEndList(); +} + + +/*-------------------------------------------------------------------- + noise function over R3 - implemented by a pseudorandom tricubic spline + EXCERPTED FROM SIGGRAPH 92, COURSE 23 + PROCEDURAL MODELING + Ken Perlin + New York University +----------------------------------------------------------------------*/ + + +#define DOT(a,b) (a[0] * b[0] + a[1] * b[1] + a[2] * b[2]) +#define B 128 +static int p[B + B + 2]; +static float g[B + B + 2][3]; +#define setup(i,b0,b1,r0,r1) \ + t = vec[i] + 10000.; \ + b0 = ((int)t) & (B-1); \ + b1 = (b0+1) & (B-1); \ + r0 = t - (int)t; \ + r1 = r0 - 1.; + +static float +noise3(float vec[3]) +{ + int bx0, bx1, by0, by1, bz0, bz1, b00, b10, b01, b11; + float rx0, rx1, ry0, ry1, rz0, rz1, *q, sx, sy, sz, a, b, c, d, t, u, v; + register int i, j; + + setup(0, bx0, bx1, rx0, rx1); + setup(1, by0, by1, ry0, ry1); + setup(2, bz0, bz1, rz0, rz1); + + i = p[bx0]; + j = p[bx1]; + + b00 = p[i + by0]; + b10 = p[j + by0]; + b01 = p[i + by1]; + b11 = p[j + by1]; + +#define at(rx,ry,rz) ( rx * q[0] + ry * q[1] + rz * q[2] ) +#define surve(t) ( t * t * (3. - 2. * t) ) +#define lerp(t, a, b) ( a + t * (b - a) ) + + sx = surve(rx0); + sy = surve(ry0); + sz = surve(rz0); + + q = g[b00 + bz0]; + u = at(rx0, ry0, rz0); + q = g[b10 + bz0]; + v = at(rx1, ry0, rz0); + a = lerp(sx, u, v); + + q = g[b01 + bz0]; + u = at(rx0, ry1, rz0); + q = g[b11 + bz0]; + v = at(rx1, ry1, rz0); + b = lerp(sx, u, v); + + c = lerp(sy, a, b); /* interpolate in y at lo x */ + + q = g[b00 + bz1]; + u = at(rx0, ry0, rz1); + q = g[b10 + bz1]; + v = at(rx1, ry0, rz1); + a = lerp(sx, u, v); + + q = g[b01 + bz1]; + u = at(rx0, ry1, rz1); + q = g[b11 + bz1]; + v = at(rx1, ry1, rz1); + b = lerp(sx, u, v); + + d = lerp(sy, a, b); /* interpolate in y at hi x */ + + return 1.5 * lerp(sz, c, d); /* interpolate in z */ +} + +static void +initNoise(void) +{ + /*long random(); */ + int i, j, k; + float v[3], s; + + /* Create an array of random gradient vectors uniformly on the unit sphere */ + /*srandom(1); */ + srand(1); + for (i = 0; i < B; i++) { + do { /* Choose uniformly in a cube */ + for (j = 0; j < 3; j++) + v[j] = (float) ((rand() % (B + B)) - B) / B; + s = DOT(v, v); + } while (s > 1.0); /* If not in sphere try again */ + s = sqrt(s); + for (j = 0; j < 3; j++) /* Else normalize */ + g[i][j] = v[j] / s; + } + + /* Create a pseudorandom permutation of [1..B] */ + for (i = 0; i < B; i++) + p[i] = i; + for (i = B; i > 0; i -= 2) { + k = p[i]; + p[i] = p[j = rand() % B]; + p[j] = k; + } + + /* Extend g and p arrays to allow for faster indexing */ + for (i = 0; i < B + 2; i++) { + p[B + i] = p[i]; + for (j = 0; j < 3; j++) + g[B + i][j] = g[i][j]; + } +} + + +static float +turbulence(float point[3], float lofreq, float hifreq) +{ + float freq, t, p[3]; + + p[0] = point[0] + 123.456; + p[1] = point[1]; + p[2] = point[2]; + + t = 0; + for (freq = lofreq; freq < hifreq; freq *= 2.) { + t += fabs(noise3(p)) / freq; + p[0] *= 2.; + p[1] *= 2.; + p[2] *= 2.; + } + return t - 0.3; /* readjust to make mean value = 0.0 */ +} + + +static void +create3Dtexture(void) +{ + unsigned char *voxels = NULL; + int i, j, k; + unsigned char *vp; + float vec[3]; + int tmp; + + printf("creating 3d textures...\n"); + voxels = + (unsigned char *) + malloc((size_t) (4 * tex_width * tex_height * tex_depth)); + vp = voxels; + for (i = 0; i < tex_width; i++) { + vec[0] = i; + for (j = 0; j < tex_height; j++) { + vec[1] = j; + for (k = 0; k < tex_depth; k++) { + vec[2] = k; + tmp = (sin(k * i * j + turbulence(vec, 0.01, 1)) + 1) * 127.5; + *vp++ = 0; + *vp++ = 0; + *vp++ = tmp; + *vp++ = tmp + 128; + } + } + } + + printf("setting up 3d texture...\n"); + + glBindTexture(GL_TEXTURE_3D, NOISE_TEXTURE); + 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); + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); + + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, + tex_width, tex_height, tex_depth, + 0, GL_RGBA, GL_UNSIGNED_BYTE, voxels); + + free(voxels); + + printf("finished setting up 3d texture image.\n"); +} + + +static void +printHelp(void) +{ + printf("\nUsage: stex3d \n"); + printf(" cmd line options:\n"); + printf(" -wxxx Width of the texture (Default=64)\n"); + printf(" -hxxx Height of the texture (Default=64)\n"); + printf(" -dxxx Depth of the texture (Default=64)\n"); + printf(" Keyboard Options:\n"); + printf(" up/down rotate around X\n"); + printf(" left/right rotate around Y\n"); + printf(" z/Z rotate around Z\n"); + printf(" a toggle animation\n"); + printf(" s toggle smooth shading\n"); + printf(" t toggle texgen mode\n"); + printf(" o toggle object: torus/sphere\n"); + printf(" i toggle texture image: noise/gradient\n"); +} + + +static GLenum +parseCmdLine(int argc, char **argv) +{ + GLint i; + + for (i = 1; i < argc; i++) { + if (strstr(argv[i], "-w") == 0) { + tex_width = atoi((argv[i]) + 2); + } + else if (strstr(argv[i], "-h") == 0) { + tex_height = atoi((argv[i]) + 2); + } + else if (strstr(argv[i], "-d") == 0) { + tex_depth = atoi((argv[i]) + 2); + } + else if (strcmp(argv[i], "-help") == 0) { + printHelp(); + return GL_FALSE; + } + else { + printf("%s (Bad option).\n", argv[i]); + printHelp(); + return GL_FALSE; + } + } + if (tex_width == 0 || tex_height == 0 || tex_depth == 0) { + printf("%s (Bad option).\n", "size parameters can't be 0"); + printHelp(); + return GL_FALSE; + } + return GL_TRUE; +} + + +static void +drawScene(void) +{ + static const GLfloat sPlane[4] = { 0.5, 0, 0, -.5 }; + static const GLfloat tPlane[4] = { 0, 0.5, 0, -.5 }; + static const GLfloat rPlane[4] = { 0, 0, 0.5, -.5 }; + + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glPushMatrix(); + if (texgen == 2) { + glTexGenfv(GL_S, GL_EYE_PLANE, sPlane); + glTexGenfv(GL_T, GL_EYE_PLANE, tPlane); + glTexGenfv(GL_R, GL_EYE_PLANE, rPlane); + } + + glRotatef(angx, 1.0, 0.0, 0.0); + glRotatef(angy, 0.0, 1.0, 0.0); + glRotatef(angz, 0.0, 0.0, 1.0); + + if (texgen == 1) { + glTexGenfv(GL_S, GL_EYE_PLANE, sPlane); + glTexGenfv(GL_T, GL_EYE_PLANE, tPlane); + glTexGenfv(GL_R, GL_EYE_PLANE, rPlane); + } + + if (texgen) { + glEnable(GL_TEXTURE_GEN_S); + glEnable(GL_TEXTURE_GEN_T); + glEnable(GL_TEXTURE_GEN_R); + } + else { + glDisable(GL_TEXTURE_GEN_S); + glDisable(GL_TEXTURE_GEN_T); + glDisable(GL_TEXTURE_GEN_R); + } + + glCallList(CurObject); + glPopMatrix(); + + glutSwapBuffers(); +} + + +static void +resize(int w, int h) +{ + float ar = (float) w / (float) h; + float ax = 0.6 * ar; + float ay = 0.6; + glViewport(0, 0, (GLint) w, (GLint) h); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glFrustum(-ax, ax, -ay, ay, 2, 20); + /*glOrtho(-2, 2, -2, 2, -10, 10);*/ + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTranslatef(0, 0, -4); +} + + +static void +Idle(void) +{ + float t = glutGet(GLUT_ELAPSED_TIME); + angx = 0.01 * t; + angy = 0.03 * t; + angz += 0; + glutPostRedisplay(); +} + + +static void +SpecialKey(int k, int x, int y) +{ + switch (k) { + case GLUT_KEY_UP: + angx += 5.0; + break; + case GLUT_KEY_DOWN: + angx -= 5.0; + break; + case GLUT_KEY_LEFT: + angy += 5.0; + break; + case GLUT_KEY_RIGHT: + angy -= 5.0; + break; + default: + return; + } + glutPostRedisplay(); +} + + +static void +KeyHandler(unsigned char key, int x, int y) +{ + static const char *mode[] = { + "glTexCoord3f (no texgen)", + "texgen fixed to object coords", + "texgen fixed to eye coords" + }; + (void) x; + (void) y; + switch (key) { + case 27: + case 'q': + case 'Q': /* quit game. */ + exit(0); + break; + case 'z': + angz += 10; + break; + case 'Z': + angz -= 10; + break; + case 's': + smooth = !smooth; + if (smooth) + glShadeModel(GL_SMOOTH); + else + glShadeModel(GL_FLAT); + break; + case 't': + texgen++; + if (texgen > 2) + texgen = 0; + printf("Texgen: %s\n", mode[texgen]); + break; + case 'o': + if (CurObject == TORUS) + CurObject = SPHERE; + else + CurObject = TORUS; + break; + case 'i': + if (CurTexture == NOISE_TEXTURE) + CurTexture = GRADIENT_TEXTURE; + else + CurTexture = NOISE_TEXTURE; + glBindTexture(GL_TEXTURE_3D, CurTexture); + break; + case 'a': + animate = !animate; + if (animate) + glutIdleFunc(Idle); + else + glutIdleFunc(NULL); + break; + case 'w': + wireframe = !wireframe; + if (wireframe) + glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); + else + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); + break; + default: + break; + } + glutPostRedisplay(); +} + + +static void +create3Dgradient(void) +{ + unsigned char *v; + int i, j, k; + unsigned char *voxels = NULL; + + voxels = (unsigned char *) malloc(4 * tex_width * tex_height * tex_depth); + v = voxels; + + for (i = 0; i < tex_depth; i++) { + for (j = 0; j < tex_height; j++) { + for (k = 0; k < tex_width; k++) { + GLint r = (255 * i) / (tex_depth - 1); + GLint g = (255 * j) / (tex_height - 1); + GLint b = (255 * k) / (tex_width - 1); + *v++ = r; + *v++ = g; + *v++ = b; + *v++ = 255; + } + } + } + + + glBindTexture(GL_TEXTURE_3D, GRADIENT_TEXTURE); + 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); + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); + + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, + tex_width, tex_height, tex_depth, + 0, GL_RGBA, GL_UNSIGNED_BYTE, voxels); + + free(voxels); +} + + + +static void +init(void) +{ + static const GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 }; + static const GLfloat mat_shininess[] = { 25.0 }; + static const GLfloat gray[] = { 0.6, 0.6, 0.6, 0.0 }; + static const GLfloat white[] = { 1.0, 1.0, 1.0, 0.0 }; + static const GLfloat light_position[] = { 0.0, 1.0, 1.0, 0.0 }; + + int max; + + /* 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); + } + } + printf("GL_RENDERER: %s\n", (char *) glGetString(GL_RENDERER)); + glGetIntegerv(GL_MAX_3D_TEXTURE_SIZE, &max); + printf("GL_MAX_3D_TEXTURE_SIZE: %d\n", max); + printf("Current 3D texture size: %d x %d x %d\n", + tex_width, tex_height, tex_depth); + + /* init light */ + glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); + glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess); + glLightfv(GL_LIGHT1, GL_POSITION, light_position); + glLightfv(GL_LIGHT1, GL_AMBIENT, gray); + glLightfv(GL_LIGHT1, GL_DIFFUSE, white); + glLightfv(GL_LIGHT1, GL_SPECULAR, white); + glColorMaterial(GL_FRONT, GL_DIFFUSE); + glEnable(GL_COLOR_MATERIAL); + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT1); + + glClearColor(.5, .5, .5, 0); + + { + GLUquadricObj *q; + q = gluNewQuadric(); + gluQuadricTexture( q, GL_TRUE ); + glNewList(SPHERE, GL_COMPILE); + gluSphere( q, 0.95, 30, 15 ); + glEndList(); + gluDeleteQuadric(q); + } + + BuildTorus(); + + + create3Dgradient(); + + initNoise(); + create3Dtexture(); + + glEnable(GL_TEXTURE_3D); + + /* + glBlendFunc(GL_SRC_COLOR, GL_SRC_ALPHA); + glEnable(GL_BLEND); + */ + glEnable(GL_DEPTH_TEST); + + glColor3f(0.6, 0.7, 0.8); +} + + +int +main(int argc, char **argv) +{ + glutInit(&argc, argv); + + if (parseCmdLine(argc, argv) == GL_FALSE) { + exit(0); + } + + glutInitWindowPosition(0, 0); + glutInitWindowSize(400, 400); + glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); + + if (glutCreateWindow("stex3d") <= 0) { + exit(0); + } + + init(); + + printHelp(); + + glutReshapeFunc(resize); + glutKeyboardFunc(KeyHandler); + glutSpecialFunc(SpecialKey); + glutDisplayFunc(drawScene); + if (animate) + glutIdleFunc(Idle); + glutMainLoop(); + return 0; +} + diff --git a/progs/demos/teapot.c b/progs/demos/teapot.c new file mode 100644 index 00000000000..38ede7ac3e1 --- /dev/null +++ b/progs/demos/teapot.c @@ -0,0 +1,675 @@ +/* + * 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 +#include +#include +#include +#include + +#ifdef WIN32 +#include +#endif + +#include +#include "readtex.h" + +#ifdef XMESA +#include "GL/xmesa.h" +static int fullscreen=1; +#endif + +static int WIDTH=640; +static int HEIGHT=480; + +static GLint T0 = 0; +static GLint Frames = 0; + +#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; + + + +/******************** begin shadow code ********************/ + +/* Taken from the projshadow.c - by Tom McReynolds, SGI */ + +/* Modified by David Bucciarelli */ + +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]); +} + +/******************** end shadow code ********************/ + + +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;ijoy.wXpos) + min[0]=joy.wXpos; + center[0]=(max[0]+min[0])/2; + + if(max[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 char frbuf[80] = ""; + + 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(); + + 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(); + + Frames++; + + { + GLint t = glutGet(GLUT_ELAPSED_TIME); + if (t - T0 >= 2000) { + GLfloat seconds = (t - T0) / 1000.0; + GLfloat fps = Frames / seconds; + sprintf(frbuf, "Frame rate: %f", fps); + T0 = t; + Frames = 0; + } + } +} + +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); + + glPixelTransferf(GL_RED_SCALE, 0.75); + glPixelTransferf(GL_RED_BIAS, 0.25); + glPixelTransferf(GL_GREEN_SCALE, 0.75); + glPixelTransferf(GL_GREEN_BIAS, 0.25); + glPixelTransferf(GL_BLUE_SCALE, 0.75); + glPixelTransferf(GL_BLUE_BIAS, 0.25); + + if (!LoadRGBMipmaps("../images/bw.rgb", GL_RGB)) { + fprintf(stderr,"Error reading a texture.\n"); + exit(-1); + } + + 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); + + + 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 matamb[4] ={0.5, 0.5, 0.5, 1.0}; + float matdiff[4]={0.9, 0.2, 0.2, 1.0}; + float matspec[4]={1.0,1.0,1.0,1.0}; + + float lamb[4] ={1.5, 1.5, 1.5, 1.0}; + float ldiff[4]={1.0, 1.0, 1.0, 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_DIFFUSE,ldiff); + glLightfv(GL_LIGHT0,GL_SPECULAR,lspec); + + glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 15.0); + glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, matdiff); + glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, matspec); + glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, matamb); + + glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lamb); + 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; +} diff --git a/progs/demos/terrain.c b/progs/demos/terrain.c new file mode 100644 index 00000000000..be78ea4950f --- /dev/null +++ b/progs/demos/terrain.c @@ -0,0 +1,656 @@ +/* + * 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 +#include +#include +#include +#include + +#ifdef WIN32 +#include +#endif + +#include + +#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 + +static GLint T0 = 0; +static GLint Frames = 0; + +#define TSCALE 4 + +#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 = 900.0; +static float alpha = 75.0; +static float beta = 90.0; + +static void +calcposobs(void) +{ + float alpha1, alpha2; + static double t0 = -1.; + double dt, t = glutGet(GLUT_ELAPSED_TIME) / 1000.0; + if (t0 < 0.0) + t0 = t; + dt = t - t0; + t0 = t; + + 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); + + if (dir[0] < 1.0e-5 && dir[0] > -1.0e-5) + dir[0] = 0; + if (dir[1] < 1.0e-5 && dir[1] > -1.0e-5) + dir[1] = 0; + if (dir[2] < 1.0e-5 && dir[2] > -1.0e-5) + dir[2] = 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] * dt; + obs[1] += v * dir[1] * dt; + obs[2] += v * dir[2] * dt; + + 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 - 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, "p - Wire frame"); + glRasterPos2i(60, 270); + printstring(GLUT_BITMAP_TIMES_ROMAN_24, "b - Toggle 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 - Toggle 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 char frbuf[80] = ""; + + 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(); + + 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(); + + Frames++; + { + GLint t = glutGet(GLUT_ELAPSED_TIME); + if (t - T0 >= 2000) { + GLfloat seconds = (t - T0) / 1000.0; + GLfloat fps = Frames / seconds; + sprintf(frbuf, "Frame rate: %f", fps); + T0 = t; + Frames = 0; + } + } +} + +static void +key(unsigned char k, int x, int y) +{ + switch (k) { + case 27: + exit(0); + break; + case 'a': + v += 50.; + break; + case 'z': + v -= 50.; + 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 terrain.dat\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", (char *) 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; +} diff --git a/progs/demos/terrain.dat b/progs/demos/terrain.dat new file mode 100644 index 00000000000..2af385e9c25 --- /dev/null +++ b/progs/demos/terrain.dat @@ -0,0 +1 @@ +‚ƒƒ…†„ƒƒƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚„†‡‰‹“•––•––––—˜š›œœš–“‘ŽŒ‹‹‹‹‹Œ‹‹ŽŒŒŒ‹‰†……„ƒ‚ƒ‚‚ƒ…ˆŠ‹‹ˆ…ƒ‚ƒ„…†‡‡†…ƒƒ„„…‡ˆ‰ŠŽ“““’’•˜š›™–•””•˜™—“ŽŽŽŽ‹‰†ƒ‚‚‚‚ƒ…‡…„ƒƒƒƒ‚ƒ‚‚‚ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚„…†‰ŒŽ“•––••–—˜˜˜™œ™•“‘Œ‰ˆˆˆˆˆˆˆ‡‡‰‹‹ŠŠŠ‰ˆ‡†††„ƒ„…ƒƒƒ„†ˆŠ‹ˆ…‚‚ƒ…†‡‡††††ˆ‰ˆˆˆˆˆŠŽŽŽŽ‘”—›š˜———˜š›—”‘‹ˆ†ƒ‚‚‚‚‚„†„„ƒ‚ƒ„†‡…„„…ƒ‚ƒ„ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ…†ˆŒ‘’”•––•••—˜™™›œœœ˜–•’Ž‰‡†…„„††…„„…††ˆˆ‡††……†…„„‡ˆ‡††…†ˆ‹Œ‰†ƒ‚ƒ†ˆ‰‰ˆˆˆŒŒŠ‰ˆŠ‹Š‰ˆŠŒ’–›œ›š›››œœ˜•’‘’’’‘Ž‹ˆ…‚‚‚‚‚‚„…ƒ‚‚‚ƒ…ˆŠˆˆˆ‡…„…‡…‚‚‚‚‚‚‚ƒƒƒ„„ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ…‡‰ŠŽ‘”••–—•”‘‘“•™œœœœš˜•’‰†„ƒ‚ƒƒƒƒ‚‚‚‚ƒ„ƒƒƒ„„„…†‡ˆŠŒ‹Šˆ††ˆŠŒ‹‰…ƒ„…ˆŒ‹‹ŒŽ‘’“Ž‹Š‰ˆ‡††ˆ‹”˜›žœœ›—•’‘‘““Œˆ„‚‚‚‚‚‚„…‚‚‚‚ƒ†ŠŒ‹‹Šˆ‡†ˆˆ…‚‚‚‚‚‚ƒ…†‡ˆ‡…ƒƒ‚‚ƒƒƒƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ…†‰‹Ž‘•————–”’‘“—›œœœœ›˜•‘Œ‡…ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ………‡‰ŠŽŽŽŒŠ‰ˆ‰‹Ž‰…„„†ŠŒŒ’“”•–”‹ˆ††……ˆŒ”˜›žžžœ›š—•’‘“”Œˆ„‚‚‚‚‚„……ƒ‚ƒƒ„†‰ŒŒŠˆ‰‰ˆ…ƒ‚‚‚‚‚„‡ˆˆˆ‡‡‡‡……†‡‡†…„ƒƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ‚‚‚‚‚ƒ‚‚ƒ†ˆŠŠ‹Ž’•——–••’ŽŽ‘”—˜š›š˜–“‘Š†ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ…†‡ˆ‰ŠŒŽŒ‹‹ŠŠ‹‹‡„‚„‡ŠŒ’”“”—™–“ŒŠˆ‡†‡‰Œ“–™œ››››™˜™™—•‘‘“”’Ž‰…ƒ‚‚‚ƒ„…………††‡ˆŠŒŽŽ‹Š‰ˆ…ƒ‚‚‚‚„†ˆˆˆˆ‰‹Œ‹‰‹Œ‹‰ˆ†„ƒƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ…„„ƒƒ…†„„…ˆ‰‹‹Œ“–—–•”“‘ŽŽ‘’”—š›š˜–”’‹‡„ƒ‚‚‚‚‚‚‚‚‚‚‚ƒ…†‡ˆ‰‹ŒŽ‘‘Œ‹‹Š‹ŒŠ‡…„…‡‰‹Ž‘”•”–š›˜•‘ŽŒŠˆ‡‰‹“–™›š™˜˜––—˜–“Ž“”‘‰†„ƒ‚‚‚ƒ„†‡ˆ‡ˆŠ‹‘ŽŠˆ…ƒƒ„„…‡ˆˆˆ‰ŠŒ‘’‘ŽŒŠ‡††…ƒ‚‚‚‚‚‚ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒƒ„…†‡‰‡‡ˆˆ‡†‡ˆ‰Š‹‘”–—–•’‘’’’”—™š™—”’Ž‹‰‡…ƒ‚‚‚‚‚‚‚‚‚„…†‡ˆˆ‰‹Œ’••’ŽŒŒŒŒŒŠ‰ˆˆ‡‡ˆ‰‹’•––˜šœš—’ŒŠ‡†ˆ‹Ž‘”˜šœ›š—•••–•“‘Ž’“‹‰‡…„‚‚‚‚„†‡‡‡‰‹Œ‘‘‘““‘Œ‰ˆ‡†‡ˆˆŠŠŠŠ‹Ž‘“”““““‘Ž‹‰‰‰ˆ…ƒ‚‚‚‚ƒƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ„†……†Š‹Š‰‰‰ˆ‡ˆˆˆ‰Œ’”–—–“Ž‘’’‘“•˜›š—”’Ž‹‰‡†„‚‚‚‚‚‚‚‚„†‡‡ˆ‰Š‰Š‘”˜™•‘ŽŽ‹Š‹Œ‹‹Š‰ŠŒ’•–—™›œš–’Œ‰†ˆŒ’•˜šœ›™–””““”’Ž’’Ž‹‰‡…„‚‚‚‚‚‚ƒ„†Š‹Œ‘‘’’‘‘Ž‹ˆˆˆŠ‹ŒŒŽ‘“““’Ž‹Š‹Œ‹‰‡……†„ƒƒƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒƒ…‡Š‹Š‰‡‡†‡‡‡ˆ‹Ž‘’”“’ŽŽŽ‘’”•—•“’‹‰‡‡…ƒ‚‚‚‚‚‚‚ƒ…‡‡‡‡ŠŠ‰ŠŒ•™š—”’Ž‹‹ŒŠŠŒ’”–—˜—•“Ž‰‡ŠŽ‘”–˜™˜–”“‘’“ŽŒŒŽ‹‰†…ƒ‚‚‚‚‚‚‚‚ƒ†Š‹‹Ž‘’’‘’’’ŠŠ‹ŽŽŽ’‘‘‘ŒŒŽŒŒ‹Š‹‹‡„„ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ„†‰Š‰ˆ†††‡‡‡ŠŽ‘‘‘’’‘‘Œ‘“””•“‘Œ‰‡†ƒ‚‚‚‚‚‚‚ƒ„‡‰‡†‰‹‹ŠŠ‹–›š˜–“‘ŽŽŽŽŒŒŽ’“”–•“‘ŒŠ‹Ž“•———–”’‘““ŽŽŒŠ‡…„‚‚‚‚‚‚‚‚‚ƒˆ‹‹‘‘‘‘’’“‘ŽŽŽŽ‘‘‘‘ŽŽŽŽŽŽŠ‡„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚„†‡‡‡‡‡ˆ‰‰‰Œ‘’‘‘‘’’’‘ŽŽ‘”•–•”“’‘‹ˆ…ƒ‚‚‚‚ƒƒ„…‡‰‰‡ˆŠŠŠŠŠ’˜ž žš˜–•””’Ž’’’‘‘’“’‘’“’ŽŽŽŽŽ’”–––•”’’““ŽŒŒŒŠ‰‡…ƒ‚‚‚‚‚‚‚‚ƒ†ŠŽŽŽ’“”’‘‘‘’“‘‘‘‘“’‘Œ‡ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚…†‡‡ˆˆ‰‹‹ŒŽ’‘Ž‘’’‘ŽŽŽ“•–——–•”’‘ŽŒˆ„‚‚‚‚‚ƒ„†‡ˆˆˆˆˆŠ‹ŠŠŒŽ’˜ž¢¡ ššš™˜•’‘“•””’‘‘‘Ž‘’’’‘‘”–—–––•“’‘ŽŒŒŒŒ‹‰‡†…„‚‚‚‚‚‚‚‚‚„ˆ‹ŽŽŽŽŽ‘’‘‘ŽŽŽŽ‘”’‘‘““‘Ž‹†ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ„†‡…„ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚„††††‡ˆŠ‹‹‹ŒŽŒŒŽ‘‘“–˜˜˜˜™—•“Š‡„ƒ‚ƒ„ƒ„………‡ˆ‰ˆˆŠŒ‹ŒŽ“˜  Ÿœššœœ›˜––•““•––•““‘ŽŒŒŽŽŽ‘’”––—™™–”“’ŽŒŠˆ„ƒƒ„ƒ‚‚‚‚‚‚‚‚ƒ…‰ŒŽŽŽŽ’’ŽŽ’•“‘‘ŽŽ‘“”“Š†ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒƒ…‡‰‹Œ‹‰‡…ƒ‚ƒ„ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ………„…†ˆŠ‹‹‹‹ŠŠ‹ŒŒ‹‹Œ‘“•–™›››œ›—•“‘‰†…„ƒ………„„„…†‡‰‰ˆ‹ŽŽ”˜œŸŸŸœšœžŸ ››š™˜™š™—–”’ŒŒŒ‹‰‰Œ“””•——™››˜—–•“Œ‰†ƒ‚‚‚‚‚‚‚‚‚‚‚‚ƒ†ŠŒŽŽŒ‹Œ‘‘ŽŽŽŒŒŒ‘”‘ŽŽŽŒ‹‹‘“–”’Š†„ƒƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚„„…‡‰ŠŽŽŽŒŠ‡†‡ˆ††…„ƒƒ‚‚‚‚‚‚‚‚‚‚‚‚‚„…‡Š‹ŒŒ‹Š‰‰‰‰‰‰‹Ž‘“—™šœŸŸŸŸœ˜•”’‰†………†‡‡…ƒ„†ˆ‰ŠŠŒŽŽ’•™žŸ¡£¡ ŸŸœ›™˜—“ŒŠŠŠˆˆŠŒ‘“––—˜šš›œ›™˜˜•“‘‰„‚‚‚‚‚‚‚‚‚‚‚‚‚„‡ŠŒŽŽŽŒ‹‹’““‘ŽŽŽŒ‹ŒŽ’”“Ž‹Š‹‘”––“Šˆ†„„ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ…‡ˆ‰‹’‘ŽŠ‰Š‰ŠŠ‰ˆ†ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ„†ˆ‹‹‹Š‰‡†‡‰‰Š‹’–šœŸ ¡¡Ÿœ˜–•’Š‡…†ˆ‰Š‰‡††‡‰‹Ž‘‘“•™œœžžŸ £¤¤¥¤£¡  Ÿ››™”ŒŠ‰‰ˆ‰Œ‘’’“–™™š››œœœ›˜•“Š†ƒ‚‚‚‚‚‚‚‚‚‚‚„†‰ŒŽ‘’””•’Ž‹Œ”—–“ŽŽ’“”•”“Ž‹Šˆ†„ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚„†‡Š‹Ž‘’““‹‹‰‰‡†††††„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ…‡ˆ‰ˆ‡††‡‰ŠŒ’•˜š›žœš˜–•“Œ‡…†‰ŠŠ‰‰‰‰ŠŒŽŽŽ’“““““”—š›œžžŸ¢¢£¥¤£¢¢¢¢¡¡ž›•‘Ž‹ŒŽŽ’•––•–™››œœ›œžžžžžœ—”‘Ž‹‡ƒ‚‚‚‚‚‚‚‚‚‚ƒ†‰‹ŽŽŽ‘“••—˜•’ŽŽŒ”˜—•’‘‘‘’““••••”““’ŒŒ‹‰‡…‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ„…‡‰ŠŽŽ’“”••‹Š‰‡…„ƒ‚„…ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ„†‡†…†‡‰ŠŒŽ‘”˜šœœœš˜—•“ŽŒ‰‡ˆŠŠ‰Š‹ŒŒŽ‘‘“•—––—˜˜šœœžŸŸ ¡¢£¤¤¤¤¤¤¥¤¢ž›–’’”–˜š›š˜™œžŸŸžŸŸ  žœ˜”‘Œ‰„‚‚‚‚‚‚‚‚‚‚ƒ†Š‹ŒŽ‘•˜™››š—•‘Œ‹ŒŽ‘”—˜—”’“””””“•—•••”““’Ž‹ˆ„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒƒ„…†ˆŠ‹ŽŽ‘““•––“‹ˆ…ƒ‚‚‚ƒ„„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ„„„…†ˆŠ’”—š›››œœžœ™—–”‘ŽŽŽŒŠŠ‹ŠŠ‹ŒŒŒ“————˜™šœžžŸŸŸŸžžŸ¡¢£¢¢¢£¤¥§©¦¢Ÿœ˜”‘‘“•˜šœžžœž  ¡¢¡ ¡¡¢ žžž™•“‘Ž‹‡„‚‚‚‚‚‚‚‚‚ƒ‡ŒŒ‘‘’“•˜šœ›—“‹Š‹’’“–˜˜—•••–––•–˜˜—––•“’‘‘‘’’’‹†ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚„‡‡†ˆŠ‹ŒŽ’“•–——•Š†„‚‚‚ƒ„„„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒƒ„‡‰Œ’•™œœ›œœ›š™–”’‘ŽŒŒ‹Ž”˜šššššœ £¢¢¡¡ ŸŸŸ¡¤¤¤£¡¡£¥¨¬­©¥¢™•““–™œŸ   ¡  ¡£¤¥¤£¤¥¥£ ŸŸš˜–”‘Ž‰…‚‚‚‚‚‚‚‚‚ƒ‡ŒŽ’“”–˜˜šžžš–’‰ˆ‰‹Ž“•–”””•••–——™™˜˜—–”’‘“““Š…ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ…‡ˆ‰‹ŒŽ’”•••–——˜–•“‹‡„ƒ‚‚ƒ…††ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ„†ˆŠ‘“—›Ÿžœœ›šš›™—–•”“’’‘‘‘’”–™šœœœŸ¡£¥¦¥£¢¡   ¢¤¦¦¦¤¢¢¤¨­¯°«§£Ÿ›˜––˜šž¡¡ ¡£¤¥¥¦¦¦¥¥¦§¥¢¡¡žœœœš—’ˆ…ƒ‚‚‚‚‚‚‚‚ƒ‡‘“•—šœœœŸ Ÿ™•‘Œ‰‡ˆ‹‹Œ’“””•–——˜™ššš™™™™—•”‘’”•”‹‡„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ…ˆ‰‰ŠŒŽ“•–™››ššš˜—–•“‹†…ƒ‚‚ƒ„†‡„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ…‡‰Œ”•˜¡ŸžŸž›™››š™™™˜—–•””‘“•—šœžžžž ¢¤¦¨©«©§¦¤¤££¥¦§§¦¥££¥«¯²±¯«¦¡žœ™˜™¡¤££¤§©ª©©©©¨§¨§¥££¢žž›˜”Œ‰†…‚‚‚‚‚‚‚„ˆŒŽ’–˜›ž¡¡¡¡¡Ÿœ˜•‘‹‰‰ŠŠ‹Ž‘“–—˜—˜š››œš˜——™š˜—”’’’“–—•’Š†ƒ‚‚‚‚‚‚‚‚‚‚‚ƒ„„„ƒ‚‚‚‚„‡ŠŠŠŒŽ‘•˜™šŸžœœ›˜–••‘ˆ…ƒ‚‚‚‚„‡‡…„„„ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚„†‰“–—™¡Ÿž ¡Ÿš™™™™œžžœ™—–•’’“–˜šœŸ¢£¢¢¤¦§¨©ª¬¬««ª¨¨©©©©©§¦¦¦§©¬±µ·µ±«¥£¡ŸžŸ¢¤¦¥¦§ª¬®®®­­¬ª©¨¦¥¥¤¡Ÿœ™–‘Š‡ƒ‚‚‚‚‚ƒ†‰‹Ž”˜›ž £¤¤¢¡š—”’Œ‹‹‹‹‹Œ“—————™š››š—–—™›š—••”“•——–”‘Œ‡ƒ‚‚‚‚‚ƒƒƒƒ„…‡‡‡†„ƒ‚‚ƒ†ŠŒŒŽ’”–šœžŸ¢£¢Ÿœ˜••”‘ˆ…‚‚‚‚ƒ…†………††ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚„‡ŠŽ’”•—™ž¡¡¡¢¡Ÿœš˜—˜›ž ¢¡Ÿœš˜–••˜›œŸ¢¥§§§¨ª«¬ª«®®¯°¯®¬­­­¬¬ª¨©©ª¬¬¯²·º·³­©§¥£¢¢¤¦¨¨©«­®±±±±°®«ª©§§§¤¢žœœš–’‹‡ƒ‚‚‚‚ƒ…ˆˆ‰‘•šŸ¡¢¢¡¢¢™–•’ŽŒ‹Š‰‹“““’‘’”–˜–””–˜š˜˜˜˜–•–—––•“Š‡„‚‚‚ƒ„…††‡ˆ†„„„ƒ‚‚‚‚…‰Œ‘’•—™šœŸ£¥¦¢Ÿ›—––•“Œˆ„‚‚‚‚‚‚‚ƒ…††ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ†ˆ‹Ž’”—œ ¡¢¡¡Ÿœš˜—™œ ¢¢ œ™˜˜š ¢¤¦¨©©©©©ªªª­°°°±²±°¯°°¯­¬­­¬­®¯²µ¸¹¶²¯¬©§¥£¥§¨ª«¬®°±±°°¯¯­«ª©§¦¤¢žš™˜˜˜•’Œˆ„‚‚‚‚‚…ˆ‰ˆŠŽ“˜› ¢¢  ¢¢˜—–“‘‘‘ŠŠŠ‹ŽŽ’””““”–˜˜™™™˜————˜˜—”Œ‡„‚ƒ„‡ˆ‰ŠŠ‰†ƒ‚‚‚‚‚‚ƒ…‰Œ”•˜š››¡¥¨¨¥¢Ÿ›˜—˜˜•‘Ž‹‡„‚‚‚‚‚‚ƒ„…„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚„‡ŠŒ’–šž ¢¢¡Ÿœ›šš›¡¢¢ ŸŸœ›œ¡¥§©«­­­¬«¬««¬°²±²´¶¶´³´´²°°²²²²³³´¶¸¹·µ²¯«©§¦¨©ª¬®°²µ´²²±°¯­«ª©§¦¢Ÿš–••””’Œˆ„‚‚‚ƒ„ˆˆˆˆŠŽ”™ ¢£¢¡¡¡¡žš™—”’’’ŽŒ‹‰‰Š‹‹Š‹‹‹’“’‘‘“—™š™˜˜˜™™›œ›™–“ŽŠ‡……‡‰ŠŒŒŒ‹‡„ƒƒ‚‚‚‚ƒ‡‹Ž’–˜ššš›Ÿ£¨«¬©¥¡žš˜—–“Œˆ…‚‚‚‚‚‚‚‚ƒ„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ…‡‰Œ’–šžŸ   Ÿœœœœž   Ÿ  Ÿžžž¡¥©¬¯±³²±°°°±°°±±³µ·º¹¸¶¶´´´µ¶¸¹ºº¹¸¸º»º¸¶´±¯«ªªªª­±´¸º·µ´²°¯­«ª¨§¥ ›–“’‘ŽŽŒ‹‡„‚‚ƒ„†Š‰‡‰Œ•š¡£¤¤¢ ¡¡ š™—–––”‘ŽŒŠ‰ˆˆˆ‰‰‰Š‹’‘’—š›™˜™™šœž ›™—’Ž‹ˆ‰ŠŒŽŽŽŠ†„ƒƒƒ‚‚„ˆ”—šœœœ¡¤¨­®¬©¤ ›˜–•’‘‹‡„‚‚‚‚‚‚‚‚„„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ…ˆ‹“—šœž   Ÿœœžžžž ¢¢¡ ¡¢¥©­±´·º¸¶µµµµ´³³´·¹»¼½¼º¸¶¶·¹»½¿¿¾¾½¼¼½»¹¹·´±®­«ª¬®³¸¼¾»¸µ³²±®¬ª¨§¤˜“ŽŒ‹ŒŒŠ‡…………†ŠŽŒŠ‹‘—›žŸ¡£¤¢¢£¤¢Ÿ›ššš™˜•’‹‰‡††…†‡ˆ‹ŽŽ“˜œžœ›š›œž ¡žœš™•’ŠŒŽ‘‰‡………„‚ƒˆŽ“–˜œžžž £¥¨¬®­©¤ž›™˜–“‘Ž‰…‚‚‚‚‚‚‚‚‚‚ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚…ˆŒ”—™œŸ   ŸŸœœž ¢¤£¢£¥§«¯³µ·¼¿½»º»º¸¶·¸¹º»¼¾¾½½½»»»¼½¾¿¿¿¿¾¾¾½º¹·µ³±¯®¬­¯°´¹½¿½»¹·¶´±¯¬¨¤¡œ—‘Œ‹Š‹Ž‹‰‰‰‰‰‹Ž‘’—›Ÿ¡¢££¤¥¦¤¢šœœ›˜•’‹‰‡„ƒ„……†ŠŒŒŒ“™ž Ÿžž¡¤£Ÿœš™•Ž‘’’“’’Ž‹‰ˆˆ‡…„…Š‘–™šž¡¡¡£¦§©­°®ª£žœ™—•“Žˆ„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ…‰Ž“–—™œŸ ¡  ŸžœžŸ¢£¥¥§¨©­±¶º»¼ÁÄÃÁÂÁ¾¼»¼½½¾¾¿¿¿¿ÁÂÁÀÀÀÀÁÁÀÀÀÀÀ¿¾¼¹¶³²²±¯°±²´·º¾ÀÀ¾¼º¸¶¶³®¨£Ÿœ—’Œ‹‹ŽŽŒ‹Š‹‘“’’’’“—›Ÿ¢¥§¨§¨¨¨¥¢žž ¡¡š•‘Œˆ…„‚‚‚‚‚ƒ†‰ŠŒ”™ž ŸŸŸŸ ¢¤¤ ››™—”’’’’’’“”“ŽŒŒŠ‰‡†‰•™›¢¦¥¦§¨©ª­°­¨£ žœ›š—“‡ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ…‰Ž”–˜›žŸŸ ¢¡ŸœœœŸ¢¤¦¨ªª­²·»ÀÀÂÆÉÇÆÇÆÃÂÁÂÁÁÁÂÃÄÄÄÅÅÅÅÄÄÄÄÄÃÁÀÀÀ¿¿¼¹¶´³³²²³µµ·¹¼ÀÃÀ¾½¼º¸·µ°ª£™–‘ŽŽŽŒ‹Š‹Ž‘‘’“’”•”“”˜œ £§©©¨¨§¦¤¡Ÿž ¢¢¡Ÿœ—‘Œˆ…„ƒƒƒ‚‚ƒ†ˆŠ‘–›ž      ¢¤¤¡›š™˜–”“’‘‘’”–•“ŽŒŠ‰‰’—› ¥¨©©¨¨©«®¯¬¨¥¡œœ—“‡ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚„†ˆ‹”–˜›žž £ Ÿœœ››œž¢¤¨ª«­°¶¼ÀÃÄÆÊÍËÊËËÈÆÆÅÄÄÅÆÈÈÈÈÉÉÉÉÈÇÈÈÆÃÁÁÁÁÀ¾¼¹¶µµµ´µ¶¸¸º¼¾ÂÃÁ¿¾¼»º¹·²¬¥ž™•ŽŽ‘Œ‹‹‹‘’”’‘’“–˜›ž¢¤¥¤£¢¡Ÿž››œžŸžœ–’Šˆˆˆ†…†‡‰Š‘“–šŸ   ŸžžŸ ¡Ÿœš›˜•“’‘‘Ž’”–“ŒŠŠŒ“˜œ¡¤§¨§¦¥§ª¬­ª§£ ž›˜“Š…‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚…ˆ‹‘“”–™œœœž žœššš›™™œ¡¥ªª«®²¸½¿ÂÄÇËÎÌÌÍÍÌÊÈÈÈÉÉÊÊÊÉÉÊËËËËËËËÉÇÄÃÂÂÀ¿¼º¸¸·¶¶·¹ºº»¼¿ÁÁ¿¾¼¹¹º¹·±¬¥ž™“Ž‹ŠŠŒŒ‹‹ŒŽ‘ŽŽ‘“•—›ž¡¢¡Ÿžœ›˜˜™šœœš–““‘ŽŽŒ‹Š‹‘•˜›Ÿ ¢¢¡Ÿœœžœ››™•’‘‘‘Ž”–’ŽŒŒ’–› £§§§¥¤¦¨ªª¨¦¢ Ÿ™•ˆƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚„‰‘‘’”•™œœœž›šš›œ›™˜œ¢§«¬®°´º½¿ÁÃÆËÏÎÎÎÏÎÍËËËÍÍÍÌÌËËÌËÌÍÎÍÎÏÎÊÇÄÃÂÁ¿½¼¼»º¹º¼½½¼½½¿¿¾¾½º¹¹¹¹¸³®§ ™’‰ˆˆ‰ŠŒŒŠŒŽŽŒŒŽ’“•˜œŸ¡Ÿœœœ›™˜—˜š›œ›˜—–•““’’“’“–™› ¢¢£¢¢ ››œœš—’Ž“”‘ŽŽ’”–šŸ¡¤£¢¢£¥¦§§¦¤¢¡ž›–‘‹†ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚†Œ“’‘’“”•˜š››œœšš›œ›š™šž£§¬°³µ¹¼¾¿ÀÃÇÌÐÏÎÍÎÍÍÌÍÎÐÏÎÍÌËËÊÊÊÌÌÍÏÒÑÏËÇÅÄÃÁÀÀ¿¾¾¿ÀÂÀ½½½½½¼¼»¹¹¹¹º»»·²«£š’‹‡‡ˆ‰Š‹Œ‹ŒŒŒŒŽŽ‘”—šžœšš›œœš™—˜™š›š™™˜——–•””•–˜™šœœž ¢¢££££Ÿœš™šœœš˜”‘ŒŽ‘’‘‘“”••—š ¡  ¡££¤¤¥¤££¡˜“Ž‹ˆ…ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ„‰Ž“––”•••–—˜™šš™˜™›œ›™™›Ÿ£§¬±¶¹¼¾¿¿ÀÄÉÎÑÑÐÎÍÍÎÎÏÐÐÏÎÍÍÌÊÊÌÍÎÏÐÓÕÔÑÍÊÇÅÄÂÂÂÁÁÂÃÅÇÿ½¼¼¼»¹·¸¹¹º¼¼»·³­¥›“‹†‡ˆŠ‹ŒŽŒŒŽŒŒŽ“•—™›š™š›››š™˜˜˜™™˜™š˜˜˜˜˜—––—šœžŸ¡¡ ¡¡¡ œš—–•–––”’‘‘ŽŽ‘“””””•••–˜š›žŸ ¡¢¢¡£¥£¡ Ÿš•‹ˆ†ƒ‚‚‚‚‚‚‚ƒ„„„ƒƒ‚‚‚‚‚‚‚‚‚‚‚‚‚„†‡‹”˜™™™™˜˜—–––•”–˜š›™˜™›ž¢¦ª°µº¾ÀÂÃÅÉÍÑÕÕÒÎÌÍÏÏÎÏÐÏÏÏÏÎÍÏÒÓÔÕÕÖÖÓÏÌÊÆÄÂÁÁÂÁÂÃÆÉÊÆÁ¾¼¼¼º¶¶¸¸¸º»»º¶±ª¢š“‹†‡‰ŒŽŽ‘ŒŒ‹ŒŒ‘’“–˜˜™››š™˜——˜˜˜˜—˜™™š›››š˜—š ¡  ¡¢¡ ¡¡ ž›˜–•’‘’’‘‘’‘“–——˜˜˜––—˜™™›œŸŸŸ ŸŸ£¤¢Ÿ›–‘Œˆ…ƒ‚‚‚‚‚ƒ‚ƒ†‡‡‡†…‚‚‚‚‚‚‚‚‚‚‚‚ƒ‡‰Œ‘–šœš™—”“‘‘”–˜™˜—™› ¤©®³º¿ÂÄÇÊÍÐÕÙ×ÓÐÎÏÐÏÎÐÑÑÒÒÒÑÑÓÖ×ÙÚÚÙ×ÓÏÌÊÇÄÁ¿¿ÁÁÂÅÉËÍÉÄÀ½¼¼¸µ¶¶·¸¹»»¹´®©¢›”Œ‡ˆ‹Ž‘‘’’“’’ŽŠŠ‹‘‘’“””–˜™˜–•–—™˜˜˜˜˜™šŸ  ŸŸ¡£¤£££¤£¢£¢ ž›˜•’ŒŒ‘’’‘‘•—™š››š™™™™˜˜™›œŸ¡£¡ž›˜“Ž‰…ƒ‚‚‚‚‚„……†ˆŠŠŠ‰†ƒ‚‚‚‚‚‚‚‚‚‚‚ƒˆŒ‘“˜œœš–’Ž’•˜––™›ž¡¥ª®³¹¾ÂÆÊÎÐÔÙÛØÖÒÏÎÎÍÏÑÓÕÖÔÔÕÕÖØÚÛÛÛÙØÔÐÍËÈÄÀ¾¾ÀÁÃÆÉÍÏËǾ¼º¶µµ¶·¹º»¹¶²®©£œ•‰‹“””–—––”’‘‘Œ‹‹ŒŽ‘“””•—™—””–˜™˜™™˜—™¡£¤¤£¡ ¢¤¦¦¥¤¤¤¤¤¥¥¢žœ™–‘‰‰‰Š‹‘“““’“–˜šœœœ›››››š˜™™šš™™œŸ¢¤¢ž™–‘ˆ…ƒ‚‚‚‚ƒ…†‡‰Š‹ŠŠ‰‡„‚‚‚‚‚‚‚‚‚‚‚…‹”•—›žž›˜”‘Ž‘”•–˜›ž¡£¦ª®³¹¾ÃÇËÐÒÖÚÜÚØÔÑÏÏÐÑÓÖØÙØ×ØØÚÜÝÝÜÜÛÙÕÒÏËÉÆÁ¾ÀÂÃÄÇËÎÎÌÉÄÀ½»¹¶µ¶¸¹¹¹·´±®ª¤–Œ“––—™›š˜•’‘‘’“ŽŽŽ’•–—–—™š—••—™šš››š› ¢¤¦¦¥¢¡¢£¤¤£¢£¤¤¥§§£ š•‹ˆ‰‰ˆŠŒ‘‘‘ŽŒ““”–™™™™ššššœ›š˜––——™œ ¤¦£Ÿ›—“Š‡„‚‚‚‚‚‚ƒ„‡ˆˆ‡ˆ‰ˆ†„ƒ‚‚‚‚‚‚‚‚ƒˆŽ’––—šœœ›™–“‘‘‘‘‘“–™›¡£§©¬¯³¸¼ÀÄÊÐÓÖÙÛÚ×ÕÒÑÑÓÔÖØÚÛÚÚÚÚÛÜÜÝÝÝÛÚ×ÕÏËÉÆÁ¿ÂÅÆÇÉËÌÍÊÈÄÁ¾½»¹¸¸··¶·´²°®©¤ž˜‘Œ•˜š™˜™›˜•“’‘““ŽŽ‘‘’•—š›šš››™˜˜™šœžŸ ¢¤§©©¨¦££¢£¤£¡£¥¥¦©©¦¡ž›•‹‰‰‰ˆˆŠŒŽŽ‹ŠŒ’“’“•—˜™š›››ž›–““”•—šŸ£¦£ œ™–’‰†ƒ‚‚‚‚‚‚ƒ…†‡‡‡ˆ‰‡…ƒ‚‚‚‚‚‚‚„†‹•—–—™›››š™—•“’““”“’“•—›¡¥§ª­¯±´¸º¾ÃÊÐÔ×ÛÜÚÖÔÒÑÒÔ×ØÚÚÜÜÜÛÛÛÜÜÞÞÝÜÚØÔÏËÈÆÃÂÆÉÊËËÌËËÉÆÄÂÁ¿½¼º¹·¶µµ³±¯­©¤Ÿ˜’“˜œœšš™–””“‘‘’““’’“”–””–™œœ›œœ››œœ ¢¢£££¥©«­¬«¨¦¥¤¥¥¢¡¢££¥¨©¥¢Ÿ›•Œ‹‰ˆ‡ˆ‰‹ŒŠˆŠŽ’””••—šœžŸŸŸŸžœ˜•””•–˜›Ÿ£¦¤¡ž›˜•‘Š‡„‚‚‚‚‚‚ƒ„‡††ˆˆ…ƒ‚ƒ‚‚‚‚‚…‡Š‘”••–—˜™˜˜˜–”“““““”•–—˜šž£§©«­¯²µ¶¸½ÃÉÏÒÖÚÜÙÕÒÑÑÓÖØÙÙÚÜÜÜÜÝÜÝßàÞÝÜÛ×ÓÐÍÊÈÆÇÉËÍÎÍËÊÈÅÃÃÃÃÁ¿½»¸¶µµµ´²¯«§£ž™•’–šŸœš™˜——•“’“““”••–——––™›ž ŸžžžŸŸžŸ¡¤¦§§§¦¨«­¯®­ª¨§¥¥¥¢¡ ¡£¥¨©§¤Ÿ›–’ŒŠˆˆ‰‰‰‹ŽŒŠ‰‡‰’••••˜›ž ¡¢¡ žœ˜•””–˜™›¢¦¥£ š˜•‘Ž‹†ƒ‚‚‚‚‚‚„†……‡†…„……ƒ‚‚‚…‰‹’”–––––––——•““••••––—˜˜›Ÿ¤¨«¬®°²³´¶¼ÂÈÍÑÔÙÛØÕÓÑÒÕØÚÚÙÛÝÝÞßßÞßáâàßÞÜØÕÒÏÌËÊÉËÌÏÐÍËÊÈÅÄÅÅÄÂÁ¿»·µ´´´´²­¨¥¡ž›—–šœŸ ž›™˜˜˜•“““’‘‘’“••••—›ž ¡¡¡ Ÿ¡£££¥¨©©ª«ª©«¬¯±°­ª©¦¥¦¦¤£¡¡¢£§ª§¥¡žš˜•‘ŒŒ‰‡‰Šˆˆˆ‰Œ’“•–˜šž¡¢£¢ žœš—••–˜™š¢¦¥¢ Ÿœ›—“‹†ƒ‚‚‚‚‚ƒƒƒƒ„…†‡ˆˆˆ†„ƒ„†ˆŠŒŽ’•˜–”““““””“’“••–———˜˜™›ž£§«­­­®±±³¹¿ÄÊÍÑÕ×ÖÖÔÓÔÖÙÛÜÜÞßàâââááãäääãáÝÙÕÒÑÏËÉÈÊÌÌËÊÊÉÈÇÆÆÃÂÂÀ½º¶³²±°®«§£žœ™—˜šœŸ¡Ÿœš™—–“‘‘‘ŽŽŽ‘“”•–™œŸ ¢£££¢¤¦§©«¬¬­®®­­­®°³±­«ª¨§§§¦¤¢¢¢¤¨ª¨¦£ žœ™–”“‘‹‰ˆ‡……ˆ‹Ž‘’”•—šž¢¤¥¦£Ÿš—–—˜˜˜š¢¦¤¢¢¢ œ™•‘‹‡„‚‚‚‚ƒƒ‚‚ƒ„†ˆ‰‰Š‹‰ˆˆˆˆ‰‹Œ“—™—•“’““’’’’”••–˜™™™™™œ¡¥¨¬¬ª«­¯°²¸½ÃÈÌÏÒÕÖÖÖÕÖØÛÝÞßàâåçæäããæçççæäàÛØÕÓÏËÈÈÈÉËËËËËÊÈÇÅÃÂÂÁ¾»·´±®¬¬©¦¡š››œœ ¡ žœš—•’Ž‘”–˜šœŸ¡¢££¤¥¦§©«­¯¯°²´´²±±±²³±¯­¬«ª¨§¤¢¢£¥¨ªª©¨¦¥¢Ÿžœš˜•‘‰†…„…ˆ‹Ž’”–—œ¡¤§¨©¥¡Ÿš˜——˜™™šœž¡¤¤¥¥¥¡›™•‹†„ƒ‚‚‚‚‚ƒ„†‰ŠŠŠ‹ŒŒŒŒŒŽŽŽ‘•˜š™—”’‘‘‘“••–—˜˜™š›Ÿ£§ª«ªª««¬®²·½ÂÆÊÎÑÔÕÖÖÖ×ÙÛÝÞâäçéêèèçèèèçççæáÜÙÖÒÏÍËÊÊÉÈÊÌÌÌÊÈÈÇÅÄþ»¸¶²­ª¨¥£ŸŸŸŸžžŸ    Ÿœ˜“‘Ž‹ŒŽ•˜›ž ¡¢¢£¥¦¨©«®±²²µ·¸·µ´³²³³²°¯®®¬ª§¤¢£¥¨ªªªªª¨§¥¢¡ š–’Ž‰„‚ƒ†ˆŒŽ‘“•˜¡¥¨©©¥¢Ÿ›˜—˜˜™ššš›Ÿ¡£¤£¢Ÿœš–‘Œ‡„‚‚‚‚‚‚ƒ„†‰‰ŠŠŒŽŽ‘“•˜š™—”Œ“–––—˜ššœŸ¢¥ª­­¬¬««¬®±¶½ÁÅÈÌÏÒÓÔÕÖ×ÙÛÝáäçéêëëëëëëêèæçæáÝÚ×ÔÒÏÍÌÊÈÈËÍÎÎËÉÉÈÆÅÃÁ¾º¹·³®«¨¦¤ ž ¢££¢¡¡ ¡¡¡ ™”‘ŽŒ‹Š‹’–™š›œŸ¡¢¤¤¦¨ª¬¯²µ¶¸¹¸µ´³´µ¶³¯­­¬¬«ª¨§¨ª©¨¨ª«©§¦£ Ÿ™–“‘‰„ƒ„‡ˆŠ‹ŒŽ•› ¢¢£¤¢¡˜––––—˜˜™™™™›ž›š˜—–•‘‡ƒ‚‚‚‚‚‚‚‚‚ƒ„†††‡ˆ‰Š‰‰‹Œ’“”—™™˜”‹Š‘“–——™›œ £¥§¬°°°®­®°±³¸¾ÂÅÈÊÍÏÐÑÓÕØÜÝàáãåèëììììììëéèèæáÞÜÚÖÓÑÏÎÎÌÌÎÏÐÏÌÊÊÉÇÅÃÁ¾¼º¸¶³°­ª¨£ ¡£¤¥¥¤¢¡ ŸŸžœ˜•’‹ŠˆŠŒŽ“–˜™™›Ÿ¡¢¢¤§©«¯³µ·¹¹·¶¶¶·¸¸´°®¬­®­¬««­®«¨¨ªª¨¦¤ ›–“‘Œ‰…ƒ…††‡ˆ‰‰Š“™žžŸ Ÿžš—–••••–˜˜—–•–—–””’‘‘‘ˆ„‚‚‚‚‚‚‚‚‚‚‚ƒ„ƒƒƒ„†‡††‡‹”••–˜™™•‘ŽŒŠŠ’”—˜™›Ÿ £¥§ª¯³´´±°²´µ¶º¾ÂÆÈÉËÌÎÑÔ×ÚÝàáââåçëíííìììëêêéæãáàÞÚ×ÕÓÑÐÏÐÒÓÒÐÍËÊÊÈÅÃÀ½¼ºº·´³±®ª¦¤¤¥§¨¨§¤¡ Ÿž›™–’‹‰ˆ‰‹‘”–™š››Ÿ ¡£¥§«°²´·º¹¸¸¹¹º»¹µ²°¯¯®­¯¯±³²¯«©¨¦¥¤¡›œš–’Ž‹ˆ……………………„†‹‘—›œœœœš˜–””••”•––”’’’ŽŽ‹Š‹‹†ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒƒ‚ƒ†Š•—˜˜™™˜–”‹‰‰‘•˜š›œŸŸ £¦©­²···µ´µ¶¸»½ÀÃÈÉÊËËÎÑÔÙÜßâååååçéëíïîííìëêèæäâââÞÙÖÔÔÕÕÖÖÕÓÐÍËÊÉÆÄ¿¼»º¸¶µµ´±­ª¨¦§©ªª¨¥£ žœš—•’‹ˆ…ˆ‹Ž‘•˜™šš›žŸ £¦«¯±´¸»º¹¹º¼½½»·´²°°¯°±³µ¶µ±®«§¥¤¢Ÿ››š—“Šˆ††††……„ƒ‚„Š”˜ššš›™—–•““““““””‘Ž‹‰ˆˆ‡……†…‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ…Š•—™š››š˜•‹‹Ž“—šœž ¡¡¢¦©­±µ¹¹¹¹¸¸¹¼¿ÁÂÆÉÊËËÌÎÑÕÙÜßåééçæçêëíïïîíììêèçæçææáÜÙØØÙÙÙØÖÔÑÎÌËÈÇÆÃÁ½»¹·¶µ¶¶³°®¬ªª«¬¬ª§¤¡š—”’Ž‹‰†„‡Š‹‹’”••–—˜˜™›ž¢§­±¶¹»º¹¹ºººº¹¶´²±²´µ¶¶¶¶´±¯«¨¦¤¡žœšš˜”’Ž‹‰‡††††‡…ƒ‚ƒ†ŠŽ’•˜™›™—–•“’‘Ž‹‰‡…„…„ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒˆ‘”˜š››˜–”’ŽŽ‘•˜›ž¡¤¥¥§ª­°³·ºº»¼¼½¿ÂÅÆÇÈÈÉÉÉÊÌÑÔØÛàæêêèçèéêìîîîíìììêéêêêéäàÞÝÜÛÚØ×ÖÓÐÍÌËÊÉÇÅÄ¿¼¹¹¸·¶¶´³±¯®®®¯­ª¦£Ÿ›˜”’‹‰‡……ˆŠ‰ˆ‹Ž‘’”””–—˜›¡¥«°µ¹¼¼»ºº¹¹º¹¶´²²µ·¹¹¸·¶´²¯¬ª¨¥¡œœ™–“‘ŽŒ‹‰‡†††‡…ƒ‚‚ƒ†‰Œ‘•™›™˜——•’‘Ž‹‰‡…ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒƒ‚‚‚‚ƒ†Š‘–™›š™˜—”“’’”–™¡¥¨©«¬¯±³¶¹¼½¾¿ÁÂÄÇÈÉÉÉÉÊÊÉÉÌÐÔ×ÜáçëêéèéêëíïððïîððííîîíëèæäáàßÛØ×ÖÔÒÏÌÌÊÈÇÇÅÁ½¼»»¹¸¸¸·µ´³±±±®©¥¢˜”‘ŒŠ‰‡†…‡ˆˆ‡†‰ŒŒŒŽ‘“”•––—› £¨¯µ¹¼½¼»º»¼»º·µ´µ·¹»»º¸µ³°®­­ª¦¢žœ›˜—•’ŽŒŠ‡…„ƒ„…„„ƒƒƒ…†‰’—š™˜˜˜–”‘‹ˆ†„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ„ƒ‚‚‚‚‚…‡Š”—™š››š˜—”’•˜œŸ¢¦ª®±³´¶¸º¼¿ÀÁÃÄÅÇÉÉÉÉÊËËÊÉÊÍÐÒ×ÛßåééèèêëîðòóóññòñïïïïïîëêèæãáÜÙØ×ÖÕÒÎËÈÇÆÆÆÂÀ¿¿¾½½¼»º¹·´²²±¬§¥¢›•‹‹‰ˆ‡††‡‡‡††ˆ‰‰‹Ž‘“””•–šŸ¢§­²·»¼¼»¼½½¼»¸·¸º»»½½¼¹¶³±°¯¯¬¨£žœš˜—•”‹Š‡„‚‚ƒ……„ƒ‚‚ƒ„†ŠŽ“—––––”’ŽŠ‡…ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ„„ƒ‚‚‚‚‚ƒ„‡Œ‘–™›œœ›š˜••—š¢¤©®³µ·¸¹»½¿ÂÃÆÇÈÈÉËËÊËÍÍÍÌËÌÏÑÓ×ÛàæêèçèéíðòôõõôôòððïïðïîíìêèåáÝÚÙ×××ÓÎËÉÇÆÆÇÅÃÃÃÂÁÀ¿¾½¼º·´²±­¨¦¢›”ŒŠŠ‰ˆˆ‡‡†††……†‰‰ŠŠ‹Ž‘’“•™ž ¤©®³¸¹¹º»½¾½½¼¼¼¼¼¼¼¼¼º¹¹¶´³±®ª¦¡Ÿžš–“’ŒŠ‰‡„ƒƒ…†…„ƒ‚‚ƒƒ„†Š’‘Ž‹Š‰†ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚„ˆ‹“•–˜˜˜—•••—šŸ¤¨­°³µ·¹»¼¿ÂÅÆÇÈÉÉÊÊÊÊÍÏÏÎÎÎÎÐÓÕØÞäéëêêêëîïñóóòòòðîíììëììêéçåâàÝÜÛÙØ×ÔÑÎÌÉÇÈÊÇÅÅÆÅÅÃÂÁÀ½»¹¶µ³®ª¦¡™”‘ŽŒŠ‰ˆ‡…„………†‡‡‡‡ˆŠ‹Ž”—›Ÿ¡£§«°´·¹º»½¾¿À¿¿¿¿¿¾½½¼»½¼»¹¸µ²¯ª¦£Ÿ™–”’‹‰‡††‡‰‰ˆ…ƒ‚‚ƒ‚ƒ„‡‹Œ‰†…„„ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ†ˆ‹Ž‘“””•–••––™ž¢§«®±´¶·»½ÀÃÆÈÈÇÈÉÊËÊÊÍÐÐÐÑÒÑÏÒÕØÜâèëíîîîîîïðññðñóðîììêéêéçååäáßßßßÜÙ×ÕÔÑÎÌËËËÉÈÈÉÉÉÆÄÄÃÀ¾¼¸·´°«¥¡Ÿœ—”‘ŽŒ‹ˆ…ƒƒƒ…‡‰‡………†‡‰ŠŒ•™¡¢¤§«®±µ¹»¼¾¿ÁÁÀÁÂÂÀ¿ÀÀ¿ÁÁÀ¿¿¾ºµ°«§£ž›™™—”’‹ŠŠ‹‹Šˆ…ƒƒ„………„…††„ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚…†ˆ‹Ž“‘‘’“”—™›Ÿ£¥©¬°³·¸»¾ÂÄÇÊËÉÈÈÉËÌÍÎÐÒÒÓÓÔÒÑÔ×ÚßäèëîîîðñðñññððòóñîìëéèçææååäããââáßÛÙ×ÖÒÐÐÏÎÍÌÌÌÍÌÊÈÇÆÄÁÀ½º·µ°ª¥¡Ÿ›™•‘Ž‹ˆ†ƒ‚ƒ†‰‰†…„ƒ„†‡ˆ‹—œž¡£¤§©¬°µ¸¼¾¾¿ÁÁÂÃÅÄÂÁÂÃÄÅÄÃÃÂÁ¾¹³®©¤ žœ›˜•“ŽŒ‹‰†„„„†…„ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ…†‰’’“–™œž¢¥§©¬¯µ¸»½ÀÄÆÊÌÍËËÊÉËÎÎÏÐÒÔÕÕÔÒÒÕÚÞâæéíðððñóòññðïðòóðîìêèçæææççææååäãáÞÛÚØÕÓÓÒÐÎÎÏÏÏÎÌËÊÇÄÃÁ¾»¸´¯ª¦¢ ŸŸ™•‘ŽŠ†ƒ‚ƒ†‡‡†„ƒ‚‚„…†Š•š ¢£¦¨¬¯±³¶¹»¾ÀÃÄÅÅÅÅÅÄÄÅÆÆÆÅÃÁÀ¼·²®ª¨¤¡Ÿ›š˜–”“‘ŽŽ‰†„„…„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚„†‡‹Ž‘””’‘“–˜š›Ÿ¢¥©¬°´·»¾ÁÄÇËÌÍÍÍËÊËÌÍÏÑÒÕÖÔÒÑÒÖÛßäèëïòñïðñðîíííïñòðíëéèèææçééèèèçäãâàßÝÛØÕÔÒÐÎÏÑÐÐÏÎÍÊÇÆÄÁ¾¼¸´¯«©¦¤£¡žš–’Žˆ„‚‚ƒ„…‡†…„‚‚‚ƒ…Š•™œŸ¡¢¤§ª¬®°±´·¼ÁÄÅÅÅÆÇÇÆÆÇÈÈÈÇÅÄÿ»·³°­©¦¢žžžœš™•“““‘ˆ„…†ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚„†Š’”–•”–˜™š›Ÿ¡¤§«¯³·»¾ÁÄÉÌÍÏÐÑÎËÌÌÐÓÓÔ×ØÕÓÑÒØÜáåéíðñïîïïîìììíïðïîìéççççéëëììëëèåäãããáÞÛØÕÒÏÎÐÑÑÑÑÐÎËÊÉÅÁ¾¼¸´²°­«ª§£ œ–’Œ‡ƒ‚‚‚‚ƒ………ƒ‚‚ƒ„…‰Ž“—šœž ¢¤¦©«­¯²µ¹¿ÃÃÄÅÆÇÈÇÇÇÈÈÉÈÉÉǾ»¸´°¬©¥¢¡¡ Ÿžš———“‰††…ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚„ˆ‹‘”——˜š››œœŸ¡£¥§«¯³·º½ÀÄÈÌÏÒÓÒÏÎÏÐÓÕÖØÚÚ×ÕÔÕØÝãçêîïïîííììëìíííìëêêçææçêííîîîîíéæäåæèåáÞÚÕÑÏÏÐÑÑÑÒÑÐÏÍÊÅÁ¿½¹·µ´²±¯«¦¢—‘‹‡„ƒ‚‚‚„…„„„ƒ„…†ˆ‹”˜š›Ÿ¡¤¦¨«®¯¯²·¾ÂÂÂÃÅÇÈÇÇÇÉÈÉÊËËÈÃÁ¾º¶²¯¬§¤¢¡¡¢¢¡ž›š™”‹ˆ‡†„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚…ˆ‹’–šš›œœœœž £¥¦¨¬¯³·¹¼ÀÄÈÍÒÕÕÔÒÑÑÓÔÖØÙÛÜÚØÖ×ÚÞäèêìîïîííìëëíííìêèççååæèëîîííííëèåääçèåáßÛÖÒÐÎÏÐÑÒÑÐÐÏÌÊÅÁ¿½»··µ´³±¬§¤Ÿ™’Œˆ…„„ƒ„†‡‡ˆ†…‡Š‹‘”–™›Ÿ¡¤§§¨«­®¯²¶»¿ÁÁÂÃÆÈÆÅÆÇÆÇÇÈÇÄÁ¿»·³°­ª§¤¡ ¡£¢ œ˜”ŽŠˆ†„ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚„†‰‹“˜œœž›œžŸ¢¤¥©­°´¹»½ÀÃÇÌÒ×ØÖÕÓÓÔÔÔÕØÚÛÚØ×ÙÛàäèëíïïîîîíììíííìêçæåäääåçéééççæåãáßàãäáÝÛ×ÔÓÐÎÎÐÐÏÍËËËÊÈÃÀ¾¼¹·¶´²°®«¨¥ ›•‘Œˆ‡†††‡ˆ‰‰ˆˆ‹’•—˜™›ž ¡£¦¨©ª¬­­®±´¹½ÀÀÁÂÄÆÆÅÆÅÄÅÅÄÄÂÀ½¹¶²®¬ª¨¥¢¡£¥£¡ ŸŸš•‘Ž‹ˆ…ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚…‡‰‹Ž’•šŸ Ÿ››œœž £§¬°³·º¼¿ÁÄÈÎÔÙØ×ÖÕÔÔÓÓÖØÚÚÙØØÚÝàäèëîðñðïïðïîîîííêèæäãâããäåååäââàÞÜÛÛÝßÜÙÖÓÒÒÏÍÎÎÎÎËÈÈÈÇÅÂÀ¾¼¸µ´²°¯®ª§¤ œ™–‘Š‹Š‰‹ŒŒ‹Š‹Ž“–šžŸ¡£¦§ª¬­¬««­®±¶º¼½¿ÁÂÄÄÅÅÄÃÄÄÃþº·´±®¬¬«©¥£¤¥¥¤¡Ÿžœ˜•’‰†ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚„ˆ‰‹‘”—ž£¢¡žœœ›šœ ¦«°´·»¾¿¿ÁÄÊÑÖÚÙØØ×ÕÔÔÕ×ÙÚÚÚÙÙÛÞáãæéíðñðïððïïîíìëéèæäâááââáàáßßßÞÜÚØ×ÙÚØÖÓÐÐÐÎÍÌÌÌÌÈÆÄÃÃÃÂÁ¾ºµ±°¯®®¬¨¦¤¡Ÿœ™•‘ŽŒŽŽŽ’•™ž ¡¡¡¡£¥§©¬¯¯®¬«¬­°´·¹»¿ÁÁÂÃÄÃÁÀÁÂÂÁ¿»·µ²¯­®®­«¨¥¦§§¥¢Ÿžœ™•’Œ‰„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ‡‹‹”˜£¦¥£¡Ÿžœ›œ¡¨®³·º¿ÁÁÁÄÈÍÓ×ÛÚÙÙÙ×ÖÖÖØÚÛÜÜÛÜÞàâäæéíïñððññðïîíëëêéæãáßßßÞÜÜÜÛÜÜÛÙÖÔÕÖÖÕÓÐÎÎÏÎÌËÊÊÉÆÃÁ¿ÀÁ¾¸²°¯®®­ª§¦¥£ ›˜–“‘ŽŽ‘‘“–šžŸ¡¢¤¦¨¨©¬®®®­¬««­°±³¶º½¿¿¾¿Á¿½½½¾¿½¼¹·µ²°¯®®­­©§¨¨§¥¢ žœ˜“ŒŠ†ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚„ŠŽ’•™£¦¨§¦¤¢¡Ÿœ¡¨®³µº¾ÁÂÅÉÌÐÔ×ÚÙÙÚÛÛÚÚÛÜÝßàßÞÞàâäåçêîðòòòóôóðîîìêéçâßÞÞÞÝÜÛÛÚØ××ÖÕÔÒÒÒÒÑÏÍÌÍÍÊÈÆÆÆÇÄÁ½»¼¾¿À»¶³±°°¯®ª§¨¨¤ žœš˜•”‘Ž’“““•™  ¢¤¦©«ª«­¯¯¯®®«ª¬¯¯±´·º½¼¼¾À¾¼ºº¼¼¼º¹·µ´±¯¯®¯¯¬«ªª©¦£ š—“Ž‹ˆ„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ…ˆ’•—›Ÿ£§©«ª©¦¥£ žœ¡¦­²¶»ÀÄÇÊÍÐÒÔ×ÚÙÙÛÝÜÝÞßàáäåâáàáãäæçëïñóôõö÷ôòðîìêçäàÞÞÞÝÝÜÛÙ×ÕÔÓÑÑÒÐÐÐÏÎÍÌÌËÉÇÅÄÃÄÄÁ½»¹¹º»¼¹µ³²²²°®ª©©¨¤¡ žœ™—•“‘‘“”•˜œ ¢¢¤¦¨«­­­®¯°±°¯¬¬¬­­¯±´¶¹»¼¾¾¼º¸¸¸¸¹¹¸·µµ³³²±°¯¯°¯­ª§¢œ™—“ŒŠ…‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ‡Š“˜šž¢¥§©«­­¬©§¤¡œ›Ÿ¥¬³¸½ÂÈÌÏÑÓÔÕ×ÚÙØÙÛÜÞàâãæçèæåããâãåçêîòõö÷÷÷õõóñíèäáßÞÝÜÚÚÙØÖÓÒÑÐÐÐÏÍÌÌËËËÊÊÈÆÅÄÁÀÀÀ¾¼º¹¸¹ºº¸µ³³³³±¯¬ª©©§¥£ ›˜•““‘‘“•—™ ¢¥§©«®¯®®®®°±°¯­¬¬¬­®¯±µ¸¹º»¼º¹·¶´µ¶¶¶µ´³´³³²°°±³±¯«§¡œ˜”‘ŽŒ‰„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ‡Œ”˜›Ÿ£¨«««­¯®­¬©¦¢›ž¥­³¸½ÃÉÍÑÓÕÔÕ×ÙÙØÙÛÝÞâäæèêêéçæåããäåèìñôö÷öõö÷õóîèäâáßÝÚØÖÕÕÓÐÎÍÍÎÍÌÉÈÇÈÈÈÇÇÅ¿¾¾½½»ºº¸·¸¹¹·¶´´´³±¯­«ª©§¦£ ž›—“’‘‘‘’”•˜›ž¡¥§©¬­­«««¬­®®¯­«¬®®®¯±³´µ¶¸ºº¹·µ´³±±²²°¯®®¯¯¯°±²°®«§£ š”ŽŒŠ†ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ„†Š“˜œ £¦«®¬«¬®®®¬ª¨¤žœŸ¤ª±¶»ÁÆÊÎÒÔÔÕ×ÙØÙÛÜÜÞâåçéêëéçççåääåæéîòôôóôöööõïêçåâßÜÚ×ÓÒÑÎËÉÈÈÉÈÇÆÆÅÆÅÃÁÁ¿½¼º»¼¼¼º¸¶µµ¶¶·¶µ³³³²°®«©¨§¤¡Ÿž›™•’‘‘““““•˜›Ÿ¢¥¨ª¬¬«ª©©ª««¬¬¬¬­¯®®¯°±²³´·¹¹¹¶µ´²®¬®®­¬«««¬­®¯±±¯¬ª§¢›”‘Žˆƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚„†‡‹Ž’—œ¡¦§ª®¯®­®¯®­­«©¥ ž¡¥«±¶º¾ÂÇÌÐÒÓÔÖØ×ÙÛÜÜßâåçèêëéèèèæããåæèìðñòòóõõ÷öðìêçãßÛØÔÐÏÎËÈÆÄÄÄÂÂÃÃÄÄÁ¿½¼º¹¶¶¸¹º»¹¶´´´³´µµ´³³²°®¬¨¦¦¥¢žž›—“‘•˜—••—šž £¥§©««ª©¨§¨¨©ªª«¬®¯®®®®­­¯±´¶¶µµµ´°¬©©ª«««ªªªª«­¯¯®®®ª£›–”“‘Š…‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ„†‰Œ‘“—œ ¦ª«­®¯¯°°°­¬¬«¨¦¢ £¨¬±µ·º¾ÄÉÎÑÓÔÕÖÖ×ÙÛÞàãåæçéêéèèéæääæææéìîñññòóööòíëéäÞÙÕÏÌËÊÈÆÄÂÁÀ¾¾¾¿ÁÂÀ¾º·µ´²²´¶¸º¸¶´³²²±²´µµ´²¯­«§¤¤£ Ÿžœ™–‘‘”—š˜–—™œŸ¢¥¦¨ª«ª©©¨§¨©©©©ª­®®­­¬¬««­°³µ´³´´±­©¥¥¦¨ªªª©ª©ª¬­­®±²¬¥˜–”’‘Œ‡ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ…ˆŒ’•˜™œ ¥«°°°°±²³²¯¬««©¨§¤¢¥©®²µ¶¸»ÁÇÍÐÒÒÔÕÖ×ÚÞáâäåæçéëêéêêèææçæçéêíïïñòóööóïìéäÝ×ÑÌÊÈÇÆÅÄÁ¿½»»º»¾¿¾¼¸´²±°°²µ¸¹¸·¶³²±°±³µ¶µ±®¬©¥£¢¡Ÿž›™—”‘‘“”—™™™š› ¤§¨ª««««««ªªªªªª¬­«ª©©©«¬­®±²²±°°¯«§£ Ÿ¡¥§§¨©ª©ª­®­®°°«¥˜–•“‹‡ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚„„„…ˆ‹’–™œ ¤©¯µµµ³²³´²¯¬«©§¦¦£¤§¬¯³³´·º¾ÄÉÌÎÐÓÕÖÙÝààáâåçêëìëëêêééèèèêêëìíîðòóõõñíêçãÞÖÐÍÊÈÇÆÆÄÀ½»º¸¶·¸ºº¸´±¯®¯°±³µ¶·¸·¶µµ³²²²³³°®«§¥¤¢ œš—–”““““”–™šœœž ¢¥§©«¬¬­®¯¯­¬¬­¬¬¬«©§§¦¨ª«¬¯¯¯¯®­¬¬§¢Ÿœ £¥¥§©ª©ª­¯®®°¯«¥ž™—•’Š†ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚„‡‡†ˆ‹Ž’•™ ¢¥©¯¶ºº¸¶µµµ³°­ª¨§¦¦¦¦ª­±³³³µ·¼ÂÆÊÌÏÓÖÙÛßáááâäçêíííìëëëìêêêëììììîðòôõõòíèåáÜÕÐÍÊÈÇÇÆÄ¿»¹¸¶µ´´µµ´³°®®®¯°±²´µ¶¸¸¸¶´²±°²²°®ª¨¦¤¢ž›˜—•“‘’“”–˜š ¡¤¤¤¥§¨ª¬®°±±°¯¯¯®¬«ª©¨¨§¦¨©«®®­¬­¬«©§¢ž›› ¢£¥©«­­®¯¯¯°±±­¨¢œ˜”‘Ž‰…‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚…‰Œ‹‹‘”—œ ¤§ª¯´º¾¼¹¹¸¶µ³²°­ª©©©©©¬¯±´´´µ·¼ÀÃÇËÐÔØÛÞàâãäååæèëííîîííîííìììíìëìïñóõ÷òìçâÞÚÕÐÍËÊÊÉƾ¹·µ´´³²²²²°®­­®¯¯¯¯°²µ·¹¹·µ³±°²²±¯¬©¦£¡ž›˜•“‘’•–—šœ £¦§¦¦¦§¨©¬¯°±°±±¯®­¬ª©§¦§¦¦¦¨ª¬¬«««©¨¥£ŸœššœžŸ¡¥©«­®¯®®°²³²®ª¥Ÿ™”Œ‰…ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ†‹ŽŽŽ‘”–—šž£§«¯³¶¼Á¿¼¼»¸µµ´²¯¬ª«¬¬¬¯°²µ´µ¶¸¼ÀÃÇÌÑÕÙÜßáäåæææåæêìîïïïïïððîíííëêìïñô÷÷ñëæáÝÙÔÐÍËÊÉÇÅÁ½º·´³³³±±°¯®¬¬­­¬¬­­®°²µ¸·µ³±¯¯±³±®­ª¦¢ žœ™–“’“•——˜™œ £¥§¦¦¥¦¦§©ªª¬­®¬ª©¨§§¥¤¤¤¢¢¢¤¥§§¦§§¦¥¢ œ™——˜šœ¡¥¥¦¨ªª«®±²±®©¤ž˜“Ž‹‰†ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ…‰Ž’–šœžŸ¢¦©¬¯²¸ÀÄÂÀ¿¾º·¶µ²¯­­­­®°²³´µ¶¸¹º½ÁÃÇÍÒÕ×ÛÞàâäååååæéìíîîððïïïïïíìêéëïòôööñìæáÛÕÐÌÊÉÇÄÃÁÀ¿½º¶³²²±°®¬ª¨§¨§¦¦§¨ª¬®°°®®¬ª«­±´±®¬©¤ Ÿžœš™˜—˜™šš™šœŸ¢¥¦¥¤¤¤¤¦¦¦¦§¨ª¨¦¥¤¤¤£¢¢¡Ÿ  ¡£¢¡¡¢£¢¡Ÿ™–•–—™ŸŸ¢¤¦§ª­±²²¯ª¤˜“Ž‹Š‡„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚…ˆ‹Ž‘“—œ¡££¤§©«­°´ºÃÈÆÄÃÁ½¹¸¶²¯¯®®¯±´µµ¶¶¸º»»¿ÂÅÊÎÒÔÖÛÞáãääääääçéêìîðïîîïïíëéééíðòôôôðìçâÛÔÍÇÇÇÄÁ¿¿ÀÀ¾»¶³²²±¯®«¦¤££¢¢¢£¤¦¨©©¨¨§¦¦©­²´±®«¨¤ žœœœœœœœœ›››œž¡£¥¦¥¥¥¤£¢£££¤¦¤¢¡¡¡¡   Ÿžœœœœœœžžžœœ›™–•••˜™š›ž £¥¨«¯²´¯©£ž™“ŽŒ‰‡…ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚†‰‹‘“–šŸ¥¦¦§ª«­¯²¶½ÄÉÈÇŽº¸µ±°°°°²´¶¶¸¸¸¹»¼¾ÁÄÇËÎÑÔ×ÛßáääåäãâãäåçêîðïîïðîìéçèêíðòóòòðíèâÛÔËÆÅÄÂÀ¾¾¾¿¾»·´²±°¯¬©¤¢ ŸžžŸ¡¢¤¤¤££¤¤£¤§«°²¯¬ª¨£Ÿ›š›œžžœœž ¢¥¥¥¥¥£  ¡  ¡¡ŸžžžžŸŸŸœ›š˜—˜™˜˜™™ššš›š™—•””•–––™› £¦ª®³´¯ª¥ š”Œ‰‡„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚„ˆŒ‘”–™¢¦¨©ª«­¯²¶º¿ÅÊËÊÈÅÀ½¹¶³³´´³µ¶·¸»ºº¼¾¿ÂÄÈËÎÐÓÕØÜáãåæåäãâáâäæéíðïîïïîëçæéêìîðñññîëèâÛÓÊÅÄÃÁ¿¾¾¿¿¾»¸µ³°¯­ª¦¢Ÿš™™› ¢¡ŸžžŸ  ¢¥ª®°®¬ª§¢Ÿ›™™›ŸŸžžžžžžŸ ¡£££¤¤¢¡ žŸžžœ›œœœ›šš™˜—•–—˜˜˜————˜˜—–”’“”•••—š›œž¡¤¨¬°±­¨¤ ›–‘Š‡„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ†‰Œ’•™œœž¡¤¥¨ª­¯±´¹¼ÀÆËÌÌÊÇÄÀ½¹¹¹¸·¶··¸»½¼¼ÀÂÄÆÉÍÐÓÔÖ×ÙÝáâãããäæåäãäçëíîííîîíëèææçéëîðïîëéåß×ÐÉÄÃÄÃÀ¾¾¿¿¼¸µ³±°­«¨¤ ›—”’’”—šœ›š™šœŸ ¢¤§«­«¨¦¥¢ž›š›œžŸ¡¡¡ ŸŸŸ     ¡¢££¢ žž›››š››™˜˜—–”””–˜˜–•””•–––•“‘’’’“”—™››œŸ£¨¬¯°¬¨¥¡œ˜“ŽŠˆ…ƒ‚‚„„ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚„‡Š•™œŸŸ¡¢¢¤¨«¯°³¸½ÁÅÊÍÎÍÌÊÈÆÁ½¾½¼»¹¹¹»¾¿¿ÀÄÈÉÊÍÑÕ×××ÙÛÞàáááâåèçæåæéììííííììëéæææèëííîíêæáÜÕÎÈÄÄÅÄÂÀ¿¿¿¼·µ³²¯¬©¥ ›•’Ž‘”—–•–—™›ž ¢¥©¬©¦¥£ žœœœ ¢£¥¢¡ŸžŸŸœ›œž ¡¡¡¡žœœ›š›šš™™—–••””’’•—•“‘‘“”””’‘’”˜š™šœ ¥ª®°¬§¤ œ˜“ŽŠ‡…ƒ„……†„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ†ˆ‹‘•™ž¢¢££¤¦ª­±³·¼ÁÅÉÍÑÐÎÍÌËÈÃÀÀÀ¿¾½½½¾¿ÁÂÄÈËÍÏÑÔØÚÚÚÜÞßàáâãåçèèèééëíííìëëëêêèççæèêëëîïêåáÝÕÏÉÆÄÃÄÄÂÀÀ¿¼¹·´°­«§¢œ–’‹‰‹Ž‘’”—›Ÿ¡¤¨©¦¤£¡ŸŸžœœœŸ¢¥¦¤¢¡ Ÿ›™˜™œžŸŸ  œš™˜™™™——–”“”•”’‘’““‘ŽŒŒŽ‘’’‘ŒŒŽ“–˜™™šœ¢¨¬­«¨¤ ™”Šˆ‡‡ˆ†‡‡„ƒ‚ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚†‰‹Œ“–›¡¤¤¥¥§©­°³·»ÀÄÈÍÒÕÓÐÏÎÌÊÆÃÂÂÁÁÂÂÂÁÂÃÅÈÊÍÐÒÓÖÙÛÛÛÜÞßßàâãåçèèéêëìíííìêëëëêèèççéêëìïîéåáÜÕÏÉÅÂÃÅÅÃÁÀ¾½º·²®«¨¤Ÿš”Ž‹ˆ†‡‰Š‹ŠŠ‹Ž‘—œŸ¢¥¥¤£¡ ŸŸžœž¡£¤¥¥¥¥¥¢Ÿœ™˜˜˜™š›žœ™–“’’’’‘‘’“’‘’‘ŒŒŒ‰ˆˆ‹ŽŽ‹ˆ‡‡ˆ‹‘“–˜™˜šŸ£¦©¨¦¡žš–“ŒŒ‹ˆ††…ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ…ŠŽ’•˜œ¡¤¦§¨¨©¬±´·»¿ÄÈÍÓÖØÖÔÑÎÌÊÇÅÄÅÄÅÄÃÂÁÂÄÄÆÉÎÒÓÔÖ×Ø×ÖØÚÝßàáâäåææèèéêêêëëíííìëéèçéééêëìëçãÞØÑÌÇÃÂÃÃÃÂÂÀ¾¼¹´®©¦¢žœ˜“Œ‰†„…‡‰‰ˆˆˆˆŠŽ”™›œž   ŸŸž››ŸžŸ ¢¤¦¦§©¨¤ žœš™–•–˜šœš–’ŽŽŒ‘‘‘’ŒŠŠ‰…„…‰‹‹ˆ…ƒƒ„†‰ŒŽ‘•˜™˜—œ¡¥§¥¤Ÿœ˜–“‘‰††„ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ†Š“–˜šŸ£§¨ª¬¬¬­±µ¹¼¿ÃÈÌÑÖÙÚÙ×ÓÐÍÊÈÇÈÉÉÉÇÅÃÂÃÄÅÇÊÏÑÓÔÕÕÖÔÓÔ×ÛßâãããäååççééêêëìíîîíëéèèééèèééèäàÚÓÍÉÄÁÁÂÂÃÃÃÀ¿¼¸³¬§£ž›š—“ŽŠ†…ƒ„†‡‡………†ˆ“——˜›œœœœ›š›Ÿ ¡¡¡£¦§§©««¨¤¡Ÿœš—“”–˜™–‘Œ‹ŠŠŠŠŠŒŽ’Œˆ†……ƒ‚„†‡‡…ƒ‚‚‚„†‰’•–—––› ¤¦¥£ ›™•“‘‘Œ‰†…„ƒƒƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚„‡Œ‘—›Ÿ¢¥¨«­¯°°¯±µ¹½ÁÄÇËÏÔØÛÞÜÚÖÔÐÎÍËËÌÎÎÊÆÄÂÂÃÅÇÉÌÎÑÑÒÒÑÐÏÑÕÚßãååäãåæçèéëìììììíîìêéèççæååååãÞÚÖÑÌÈÄÂÂÃÃÄÄÃÂÀ¼·²¬¦¡œ™–”Œˆ„ƒƒ„……„ƒ‚ƒ…‡‹Ž’”–˜™™š››š™™œŸ¡£¥¥§¨ª«¬¬­ª¦¤¢Ÿ›–’“•––“Œ‹Š‰ˆˆ‰Š‹‘’ŽŠ†ƒƒƒ‚‚ƒƒƒƒ‚‚‚‚‚ƒ„†Š’””••–šž¡¤£¢ œ›˜–”’’’Œˆ†……„ƒƒ„„ƒƒ‚‚ƒ‚‚‚‚„…‡‰Œ‘–› ¥¨«¬­°²²²³µ¹½ÂÅÇÊÍÑÖÚßâàÝÛØÕÓÑÐÏÏÒÒÎÉÅÃÄÅÇÉÉÉÍÐÐÏÎÎÎÏÑÕÚÝâååãäæçèéëííîîîíîîìëêèèæåããâáßÚÕÒÐÍÊÆÃÃÃÃÃÃÃÃÁ¼¶±«¤Ÿ™•“‘‰†ƒ‚‚ƒƒƒƒƒƒƒ…‡ˆŠ‘•—–•—˜˜˜™œ ¢¥§¨¨«®®®®­©¦¥£Ÿ›–’‘‘‹‹ŒŒ‹Š‰ŠŠŠŠ‹Ž‘’‰„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ†ŠŽ‘‘’’“—›žŸŸžœš™™™™–““’ŒŠˆ†„ƒ„………„ƒƒ„„„„†‰Œ”™œ ¤©¬®®¯±³´¶·º¾ÂÆÉËÍÏÓÙßãæåäâßÜÙ×ÕÔÓÔÓÐËÇÇÈÉÊÊÉÉÍÏÏÎÍÌÍÎÐÓÖÚàäãâäææçéëìííïïðïíìëëëêéåãâáßÞÚÖÓÒÏËÇÅÃÂÀ¿¿¿À¿º´®§¢—’Š‡„‚‚‚‚‚‚‚ƒ„‚‚…‡‡ˆ‰Œ‘’“•˜œŸ¢£¤§©­±°¯®­ª¨¦£Ÿš•ŽŒ‹Š‰‹‹‹ŠŠŠ‹‹‹‹ŽŽ‰„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ…‰ŒŽ‘•˜™ššš™˜—˜™š˜–•”‘ŽŒ‰†……††‡‡†…†‡ˆˆŠŒ‘”—šž¡¥©¬¯²±°²´µ·¹¾ÃÇËÏÐÑÓÖÝãçëìëèäâàÜÚÙ×ÖÕÑÍËÊËËÌÍËÊÌÌÍÍÍÌÌÎÐÑÔÙÞáâäæèççèêììîðññðîííííìêæãàßÞÜÚ×ÕÔÑÍÊÈÄÁ¾½½¼½¼¸³«¤Ÿš”Œ‰†„‚‚‚‚‚‚‚‚ƒƒ‚ƒ„„ƒ„…‡‰Š‹ŒŽ’–šŸ¡¢£¦ª¯³±¯®¬©§¥£ž˜“Œ‰‡‡†‡ˆ‰ˆ‡‡ˆ‰‹ŒŽ‘Ž‰…‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ…ˆ‰‹’”–—––––•—™šš™˜–“Ž‹‰ˆ‡†‡‰ŠŠŠ‹Œ’“•˜›ž¢¦«­¯²´³²²³µ¸»ÁÆÉÍÑÓÖØÛáçíòòñîëèåàÝÛÚØÕÒÐÎÎÍÍÎÎÍÌËÊËÍÍÍÍÍÎÐÔØÜàãæèêèçèéìíïññððððððïïìèãàßÝÛÙ×ÕÔÑÏÌÉÅ¿¼»»»º´®§¢œ–Œ‰†„ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ„„…‡‰Œ‘—›ž ¢£¤¦«°µ²°­«¨¥¤¢˜”Š‡†„…†‡ˆˆ‡‡‡‰ŒŽ‘‘‰…‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ„‡ŠŒŽ‘“””“““”•—š›š™—“ŽŒ‹Š‰‡ˆ‹ŒŽŽŽ“–——™›Ÿ¢¥ª®°±´µ³²²³¶¹¾ÄÇÊÎÒÖÙÛßåëñõõôòïìçäáàÞÛ×ÖÓÒÑÏÏÐÐÐÏÍÌÎÏÏÏÎÍÏÒÕØÜàäæèééééêìïñóòññðïïïïîëèãßÝÛÙØÖÔÒÑÏÌÉƾºº¹¹¶°ª¦¡›”Ž‹‰…ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚„‡‹‘— ¢£¤¥§¬±¶´±­«©¦£ ›˜”Š†ƒ„…‡‰ˆ‡†‡ŠŽŽŠ‡„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ†‰‹Ž’‘‘‘’“•—™˜––”‘ŽŒŒŒŒ‰‰ŠŒŽ’•˜™™›ž¡¤§«®±³µµ´´´µ¸¼ÀÄÆÈÌÒÕ×ÛàåêîñððîîêçåãâáÝÚ×ÕÖÖÓÒÒÓÓÓÒÓÓÒÐÏÏÐÓÖÙÛÞáâäæèéêêëíðññðïîìëêèçæåâßÜÚ×ÔÓÒÐÎÎÍËÉÅÁ¼¸¶´´±«§¤ ›•’‘‡„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚…‰’˜ ¡¢£¥¨­³·µ°­ª©¦£Ÿœ™–“‹†ƒ‚„‡ˆˆ‡‡‡‹ŽŽŽ‹‰†„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚„ˆŠ‹ŒŽ‘‘’‘‘“—˜•”’‘ŽŽŽŽŽŒ‹‹‘’•˜š›œž¡¤§ª­°±³µµ¶··¸»¾ÂÄÅÈÌÏÒÖÛáæéìîìëëëéççåäâßÛÙÙÚÚ×ÖÖÖÖÖØÙØÕÒÐÒÓ×ÛÝßáâãäçêëëìíïòòñïîëêçåáßàßßÝÙÕÒÏÏÏÍËÌËÊÊÅÁ»·´±¯­¨¥¢žš——•Š†ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ‡‹•šž ¡£¤¦©¯µ·³¯¬ª©§¤ œ˜–“Š†ƒƒ„†‡††‡‰ŒŽŽŒ‹‰ˆ…ƒ‚‚‚‚ƒ„ƒ„„„ƒƒ‚‚‚‚‚‚ƒ†ˆ‰‹‘’’“’’‘’•–•“‘‘‘ŽŽ‘Ž‘“–˜ššš›ž¢¥©­°³³³´µ·¸º¾ÁÃÄÅÇÉËÎÑÕÛáãåçéèççèççèèæäáÞÝÜÞßÝÜÚÙÙÚÜÝÚ×ÔÓÓÕÙÝßáâäååéìììíîðòòñîìéæãàÜÛÛÜÜÚÕÐÍËÊÊÉÊÊÉÉÈÿ»¶±®¬ª§¥¢žœœ›™“Œ†ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ†‹‘–œ £¥§¨©¬±¶¸´¯­«©¦£Ÿš–”‘‰†„„„„……†ˆŠŒŽŒ‹‹Š‡…ƒ‚‚ƒ…‡‡‡‡‡†…ƒ‚‚‚‚‚ƒ…†‡‹’’“””’’“”–•’ŽŽŽŽ“–™™š™™›ž£¨«¯²´´´´µ¸»¿ÃÄÅÅÆÈÉÉÌÑÖÜàáãåææåæççèêìéçäãâáááááÞÜÝÞàáÞÛØÖÖÙÝáââãææçëîíìíîïññðíêæâßÛØÖ×ØÙÖÑÌÉÇÅÅÇÈÈÈÈÅÁ¾ºµ°­«¨§¦¢Ÿ žš”†ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ†‹’˜¡¥§©ªª®³¶¹¶±­ª¦£ œ˜“‹ˆ…ƒ‚‚‚ƒ……„…†‡Š‘‘Ž‰…ƒƒ…†ˆ‰ˆ‰Š‹‹‰†„ƒ‚‚‚‚ƒ…ˆŒ‘’”–•”••––•’ŒŒŒŽŽŒŒ’•—™™™™›œ¢§«®°²´µµ·¹¼¿ÂÂÂÄÆÈÉÉËÐÖÚÞáååææççèèèëíëèççäãááâãáßßâäåâàÝÜÝßáäããåççéíïíëêëíîîíêçâÝÙÖÕÔÓÒÒÐÍÉÆÄÂÂÄÅÃÃÂÀ¾¼¸´±­ª§§¥¡ Ÿ žš•ˆ„ƒƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ‡Œ“—œŸ¢¦¨©ª°µ¹¼¹³­¨£Ÿœ™–‘Œˆ…ƒ‚‚‚‚ƒ„ƒ‚‚ƒ…ˆ‹‘’’’’’’‘Œˆ…„†‰Š‰ŠŒŽŒ‰‡…ƒ‚‚‚ƒ…‰Œ“•—––———–”’ŒŒ‹ŠŠŒ‹Š‰‰Š‘“•—˜˜™šœœž¢¦ª¬¯²µ·¹»¾ÀÁÂÂÂÅÆÈÉÊÌÑÖÚÞâååæçèçççéíïìêëéçåããääãâãåæçåãâáâãäæååæèéëíïíëêêëììêèæàÚÖÓÒÐÍËËÊÈÅÃÁÀ¿ÀÁ¿¿¾¼»¸µ²¯­©¦¦¥£¡¡¡Ÿ˜’Œ‡‡…‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ†Œ’–šœ ¤§©«°µº½¸²«¥ œ˜•’‹‡„‚‚‚‚‚ƒ„ƒ‚‚ƒ„…‰ŒŽ‘““””“Œˆ†‡ˆŠŒŽ’”‘Ž‹ˆ…ƒ‚ƒ„†‡Š’–˜™™š˜–•”’‹‹Šˆ‡‡†‡ˆ‰Š‘“•——˜šœž ¢¤¦ª®²µº¼¿ÀÁÃÄÃÃÃÄÆÉÊÌÐÓÙßáãäççèèèéìïïíííìêçææåååæçèéêèçççççèèççæçèéëíìëëëëííëèäÞØÓÏÍËÈÆÅÃÁ¿¾½»»¼½½½»º¸¶³°­¬¨§§§¥£¢¢¢¡œ˜’Œ‰†ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚„‰“˜œ ¤§©¬°¶»½·°ª¥Ÿ™•‘‰†ƒ‚‚‚‚‚ƒƒƒ‚‚‚‚ƒ‡‹‘”•”””‘ŽŠ‡‡‰‹Ž’–—•‘Ž‹ˆ††‡ˆˆ‰ŒŽ’–šœœœœ˜”“’‘‹Š‰‡†„„†‰ŠŒŽ’“”––˜šœžŸ ¡¤¨­²¶º½ÀÁÃÅÄÃÂÂÄÆÈÊÌÐÔÚÞàâåèèèèéëíïðïïðïìêèæææèéêëííííììëëêêéèççèêëëëìëêêëëéåàÚÖÒÎËÈÆÄÀ¾¼¹¹¹¸·¸ººº¹¹¶´±¯­«ª©¨§¦£¢¡¢¢Ÿ›•Š†ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ‡‘–œ¡¥§©¬±µº»´®¨£ž™”Œˆ†…ƒ‚‚‚‚‚‚‚‚‚‚‚‚„‡Š‹Œ’’’“‘Š‡†‡‰Œ’•—–”‘‹‹‹ŒŽ‘•™œœœ—“‘ŽŠˆ†„„ƒ‚ƒ†‰ŠŒ‘”••–—™š›œŸ¢¤§¬°³¸»¾ÀÂÂÃÄÅÅÆÇÈÈÊÎÔÚÞàãæééèèéêíîððððïíêæãäåæçéëíîïðïîîîììëéèèêìëêééééèçæäßÚÕÒÎËÇÅÃÁ¿¼¸···µ´µµ¶···µ²¯®¬«ª¨¦¥¤¡ ¡¢¡ž™“ˆ…ƒƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚„‰•›¡¤¦¨«¯´¹¹²«¦£Ÿš•Š‡……„‚‚‚‚‚‚‚‚‚‚‚ƒ„‡‰Š‹‰††…‡Š’“•˜˜–”’‘‘’‘‘’’•—œŸŸ›–’Œ‹‹Š‰†ƒ‚‚‚ƒ‡‰Š‹Ž‘”•–—™›››š £¤¦«¯²µ¸»¾ÀÁÄÆÇÇÇÈÈÇÈÎÕÚÞàãçëëêéèêìïòòòñïíêåâãääçéìïñóõôòñðîíìëééëìëêéêéçåâáÞÙÔÐÌÉÆÄÂÀ¿½»¸¶µµ³²±°²´µ´²°­­««©§§¦¢Ÿ ¢¢ ˜‘Œˆ†…„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ‡“š¡£¥¦©®³¶¶°ª¥¢˜“‹ˆ†„‚‚‚‚‚‚‚‚‚‚‚ƒƒƒ„…‡‰‹Œ‹ŒŒŠ…ƒƒƒ„‡‹‘’•˜—˜˜˜˜˜™™—–••–™ž   ž›—“‹‹‹‹‹ˆ„‚‚‚„‡‰‰‹Ž’“•˜š››š›Ÿ¢¤§ª®±²µ¹½ÀÂÅÆÇÈÈÉÊÈÉÍÓØÞáäèìëêèèêîòôòñïíêèäááâäçêïòô÷øöôòñïíììëëììííììéæâÞÛØÔÐÌÈÄÂÁÀ¿½»¹·¶µµ³²¯®¯°°¯­¬««ªª§¦¦¥¡Ÿ¡¡¡ ˜’ŽŠˆ‡…‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚…Š˜ž ¢¤¨­±´´¯©¥¡œ—‘‹Š‡ƒ‚‚‚‚‚‚‚‚‚‚ƒ„ƒƒƒƒ…ˆ‰‰‰‰ˆ‡„‚‚‚ƒ†‹’•˜˜™šžŸŸŸœš˜™›ž ¡¡Ÿœ˜“‹ŠŠŒŠ†ƒ‚ƒ†ˆ‰ŠŒ‘’”—˜™š™š›Ÿ¡¤§«¯¯°´¸»¿ÂÄÅÇÇÇÈÈÇÈÍÒØÞáãçêëêééìðôöóðîëéæãàáãäçìñô÷ø÷÷öóðîîîîîîíîîîìéçåàÚÖÓÏËÉÄÁÀ¿¾¾¼º···¶´³±¯¬¬¬««©¨¨¨©©¨§¥¤¡ ŸŸ Ÿœ˜“ŽŒ‹‰†ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒˆŽ–œ £§«®²²¬§£Ÿœ—‘‹‰†ƒ‚‚‚‚‚‚‚‚‚‚‚ƒƒƒ‚‚„†„„……„…„ƒ‚‚„‰‘“–š™™œžŸ¡¡¡ Ÿœš›œž   žœ—’ŒŠŠŒŽŒˆ„‚ƒ†ˆ‰‹Ž‘”—˜—–—˜™š ¤§«¯±°±³¶¹»½ÀÂÃÂÃÅÆÆÈÍÓØÝàãåèêëêëïóôõòðïîëçäâãããæëîòõõôôõòððððïîííîíìèåäãÝ×ÔÐËÇÄÂÁ¿»ººº¸···¶´³±­ªª«ª¨§§§§§¨§¥¢ žœœœ˜•’Ž‹ˆ…ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚†‹‘–›ž¡¤¦¨«°±¬§£Ÿ›–Œ‹‰‡„‚‚‚‚‚‚‚‚‚‚ƒ„„„‚‚ƒƒ‚‚‚‚‚‚ƒƒ‚ƒ‡‹‘’“˜›››Ÿ¡£¤¥£¢žžŸ    Ÿ˜“ŒŒŽŽŒˆ…‚ƒ…‡Š‘”—™™–••—™šœ ¤¨¬°³²±³¶¸¹»¾¿¿¾¿ÂÄÅÈÎÔØÛßãåéëììîñóôôòññðìçåååååçëíñôóòóóòòóôòðïíííìéæââßÚÕÑÌÈÄÁÀ¾»·µ·¹··¶¶µ´³°«©©ª¨§¦§§§§¨¥£ ž›››š™™—•’Ž‹ˆ†„„ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒˆŽ’—›Ÿ¢¤¥¦©®®ª¦ ›—“‹ˆ…ƒ‚‚‚‚‚‚‚‚‚ƒ„„ƒ‚‚‚‚‚‚‚‚‚‚‚ƒƒ†‰Ž’’”˜››œž¡£¥¨¨¥¢ŸŸ¡¢¡¢¡ Ÿ™•ŒŽŽ‹ˆ…„„†‰ŒŽ‘”——˜—––——™›ž¡¥¨¬±´²²³¶¸º½½¼¼¼½ÀÂÅÉÎÓÖÚÞáåêíïðòóôôôóóòòíèçæçèèéëîñóòñññòõ÷÷óïìëêéèçäáàÝØÓÎÉÅÂÀ½º¶³³´´¶·¶µ´´³¯«©¨§§¦¥¥§¨¨¨¥£ š™˜———•“‘ŽŒ‹‰ˆˆ‡…ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚„Š”˜œŸ¢£¤¦¨«©¦¡™•‘‹‰†ƒ‚‚‚‚‚‚‚‚‚ƒ„ƒ‚‚‚‚‚‚‚‚‚‚‚‚„…ˆŠŽ’“”˜ššœž¡¤¦¨©¦¢¡¡£££¢¡ Ÿ™•ŒŽŠ†…††‡Š’–˜—––—˜˜˜š ¤¦©¬°²²³µ¸¹º¼½¼»¼¾ÀÃÇËÏÓ×ÛÞáåëîïóõôóôõôóòñíéççééêêíðòóòññòôøúøóîìëéèçåâßÝÚÕÑÌÆÃÁ¾»·²°°°±³µ³³´´±®«©§¦¦¤£¥§§§¦¤¡žœ™˜—–•”“’Ž‹Š‰ˆ‰ˆ†„‚‚‚‚‚‚‚‚‚‚‚‚‚‚…‹•˜šŸ¢£¤¥¥¢ž›—’ŽŒŠˆ†…ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ…‡‰‹‘‘’”•–—™œ £¤¥£¢  ¡¡ Ÿžœ™–’Œˆ‰‹ŠŠˆ‡‡‡††‰‹Ž‘•—–•••––˜œŸ¢¤¦¨ª­°°²µ¸··º½½½¿ÁÄÈÊÎÑÕØÜßâæëìîðòòôõõóððïìèççèéëîñóôõôõõõ÷ùøöóðîîëéæäàÛ×ÔÐÍÉÅÁ¾»¸³®­¬«¬­®¯²³³±®«¨¦¥¢ ¡¤¤¤£¢ žœš™™˜–“‘‘ŽŒ‹‰†………„„‚‚‚‚‚‚‚‚‚‚‚‚‚‚…‰Ž“–™™›œž ¡¡ž™–’Ž‹‡…ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚„‡‰Š‹‹‘‘’”–™œžŸ ¡ žŸŸžœ›™—”Š††‡ˆ‡ˆˆˆ‰ˆ‡‰Š‹Ž“•–•”““”˜œŸ¡¤¥§«­¯¯±µ···º¼¾ÁÃÅÊÍÏÒÔÖÙÜßäéììíïñòôõõñïîíêèçæçêîñóö÷÷øøøøúú÷õóððïíéçåàÚÓÏËÉÆÃÀ¼¸´°¬ª©¨©©©¬¯±³±¯ª§¥£ ž ¢¢¡ žœ››š™˜—•’ŽŒŠˆ…ƒ‚‚ƒ„‚‚‚‚‚‚‚‚‚‚‚‚‚‚…‰‘”––—˜šœœ™•‘ŽŒŠ‡ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ…‡ˆ‰‹‰ˆŠ‹‹ŽŽ’“•—š›œœœœœ›ššš™—•’ŽŠ‡……††‡‰Š‹Œ‰‡‡ˆˆ‹’““’‘‘“—œ ¢¥¨«¬­®¯³µ¶·¹¼ÀÅÈÌÎÐÒÔÕ×ÚÝâèíïïðïîïñóõñíìëéèçåéíñõ÷ùúüüüûûüüøõòððïëéèåßØÐÊÇÅÂÀ½¹´°­ª§¦¥¥¥¦ª®±²±­§¤£¡Ÿžžžœœ›šš™˜—”’‘ŒŠˆ…‚‚‚‚‚ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ„ˆŒ‘““““•••––’Ž‹‰†„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ„†‡†ˆŠ‰ˆˆˆ‰ŠŒŽ‘’’“•–—˜˜™™——™›š—“‹‡…………†‡‰ŒŽŒˆˆ‡ˆŠ‘”˜œŸ¡¤§ª«­­®±´µ¸º½ÂÈÌÏÑÒÔÖ×ØÛßåêðóòñîììîóôñîìêééçæëïòöøúûýþýýýüûùöòññîêèçåÞÖÎÈÅÂÀ¾ºµ±­ª¦¤£££££§¬°²°«¦£¡Ÿœ››œ››ššš™—•’’‘‘‘‹‡„‚‚‚‚‚ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ…‰‹ŒŽ‘‘’““ŒŠˆ„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒƒƒ†ˆˆˆ‡‡‡ˆ‹Ž‘’’“““•—–—š›˜”Œ‰†„…‡‡‡‰‹ŽŒŠ‰ˆ‰ŠŒŽŽ‘”—›Ÿ¢¥§ªª«­¯²¶º¿ÄÈÌÎÑÒÓÖØÚÜàåêðôóòðîíïòóñïìëêêççëîñóöùúûûûûûúúù÷óðîêèæåâÛÔÌǾ»¸³¯¬©¥¢¡¡ŸžžŸ£©­¯¬¨¦¥¢   žœœš˜•“““’‘‘Š‡…‚‚‚‚‚ƒ‚‚‚‚‚‚ƒ„„ƒƒ‚‚ƒ‡‹ŒŒŒŒŽ‘’“”‘Šˆ†ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ…‡ˆ‡‡‡†‡ŠŽŽŽ’•–—šœš•‘Ž‹‡…†ˆˆˆŠŽ‹‰‰ˆˆŠ‹ŽŽ“–™››œ £¤¥¥§ª¬°µºÀÅÈÊÍÐÒÕØÚÜÞâçìñôôóóñððòóñðîìëêééìîðòõùúûûüûûúøùøôïëçæäãßØÒËž¹·²­ª¨¥¡ŸŸŸžœž¢¦ª¬ª§¦¥¤££¢ žžžŸŸž›˜•“””““’Œˆ†„‚‚‚‚‚ƒ‚‚‚‚ƒ„†ˆ†…„„ƒƒˆŽŒŠ‰Š‹’’‹‡…ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚„††…………†ˆ‹‹‹ŠŠˆˆ‰‹ŒŽ“–˜›œ™•’Œˆ†‡Š‹Œ‘’’‹‰ˆ†‡ˆ‰‹ŒŒ‘”–˜™™›žŸ¡¡£§«¯´ºÁÅÆÉÍÑÕØÛÞáâåéîòõõöõõóððñññññðïííîîîðô÷úüýýúù÷õööñìèååãáßÙÒÊü¸´¯©¥£¡ ŸžžžžœŸ¡¥©©¨§§¦¥¤£ žžŸžžœ™–••••–”‘Œ‡„‚‚‚‚‚„†…„ƒƒƒ„‡Š‰ˆ†…„†Š‹ˆ‡‡ˆ‹ŽŽ‰†ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ…†…ƒ„……†ˆŠŠˆˆ‰†…†‡ŠŒ‘•™œž›˜•“‹ˆ†ˆŠŒ’”••‘ŒŠ‰ˆˆˆˆŠ‹Ž“•––˜™ššœžŸ¢¥¨­³»ÁÃÆÊÎÓØÛßâäæéëïôö÷øø÷ôñðñòóõõóòðîîíîðóöúüýüúøöõõõðëçäãââàÙÑÈÀ»¶²­¨¤¡Ÿžžœœ›œž¡¥¦§¨§¦¥¤£¢ Ÿžœ›œš˜–•””–˜•Š…ƒ‚‚‚‚ƒ…‡‡…„„„…‡‰‰‰‡‡‡‰Œ‹‰‡††‰‹‹‹Œ‹ˆ…ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ†……„ƒ„‡ŠŒ‹ŠŠ‰‡†„…‰ŒŽ‘•˜šš–”’Œˆ…ƒ„‡Š“””‘ŽŒŒ‹‰‰‹‘‘“”––—˜šŸ £¤§®µ¼ÁÄÈÌÏÓ×ÚÞáäçêíñõøøø÷õòñðñòôõõòðîííîîïòöøúúùøøöõ÷÷ñëæãâââàØÐÇ¿º¶±­«¨¤ žœšš››š›žžž ¢££¢¡¡¢ Ÿžœ™˜š›™–”“’“••‘ŽŠ†…„„„„„……ƒ‚‚ƒƒ„……†……†‡‰‹ŒŠ‰ˆ†„…‡‰ŠŠŠ‰†„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ………„ƒ…ˆŒŽŒ‹‰‡…ƒ…ˆŒŽ‘”–˜—”‰…ƒ‚ƒ†Š’“”’ŽŒ‹Œ“”’‘’“”–˜™œŸ¢£¤§¯·½ÂÅÉÍÐÓÖÚÞáåèëïó÷úúù÷óñïïñòóôôñïìëííîðòõ÷ø÷ö÷÷ö÷úúóìæââããáÙÑÇÀºµ²®­«§¤ ™™™™šœœ›™˜š›žžŸž›˜––—™˜•“’‘’““‘ŽŠˆ‡‡†††…„‚‚‚‚‚‚‚‚ƒƒƒ„†ˆ‰‰‰‡‡‡‡……†ˆ‰‰ˆ…ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒƒƒ‚ƒ„‡‹ŽŒŠ‰ˆ†„„†Š’”••‘‹Š‡„‚‚ƒˆŒ‘’”––”“’‘‘Ž’•–•”Ž’”•—šžŸ¡£§®¶¼ÁÄÇËÏÓÖÛßãçéëïóøüúùöóðîïñòóôôòñíìììîððóöøöõõõöùûúôíæãäææäÜÓÉÁ»·³¯­«©§£Ÿš˜˜šœœ›™•“”–˜š›œœœš™–”””–—•”“’‘’‘ŒŠˆ‡††„ƒ‚‚‚‚‚‚‚‚‚ƒƒ„„†††…„„„†‡‡ˆˆ‡††„ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚„†‹ŽŒŠˆ‰‡…„„†‰‘‘’’ŽŠˆ†…ƒ‚‚…‰‘‘’–˜˜—–•”“’•–˜–“ŒŽ‘”—›Ÿ¢¤©¯µ»¿ÂÅÊÎÑÖÛáäçèëïõúüûú÷ôñðññòôõôôòïíììîððòô÷öõôõ÷úûúôíèåæèèåÝÓʼ¸´±®¬«©¦¡›–—™›œš–‘Ž‘•˜™™™˜—•’‘‘’“””“’‘‘‘‘‹‰‡†††„‚‚‚‚‚‚‚‚‚‚ƒƒ„…ƒ‚‚‚ƒ„†‡ˆˆˆ‡†„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚„„‡‹ŒŠˆ‡…ƒ‚ƒ†ŠŽ‰†„ƒƒ‚‚‚ƒ‡‹‘“–˜™™—•””““”•••’ŽŽŽŽ‘”™›¡¤¦ª®´¹½ÀÃÇËÐÔÙßâäæéïõùýüû÷ôóóòòóõõôôóðïîïðññóõööööö÷øùøòíéææçæâÛÓËĽ¸³¯­­«©¦£œ––—™™–’Š‹‘””““”’ŽŽ‘’’‘‘‘’’’’‹Š‰ˆˆ‡…ƒƒƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒƒ„…‡ˆˆˆ‰‡…ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ†‰Œ‹‰‡†„‚‚‚…ˆŠ‹‰ˆ‰ˆ„‚‚‚‚‚‚‚ƒ†Š’“—šœ™——˜———–•“ŽŽ‘•˜›¡¥¨«¯³¸¼¾ÁÅÉÎÒØÞàâæêïõùüýüøööõôôõööõôòñññññòóõ÷ö÷÷øøøùùøôïëèèçåâÛÓÌž¹³¯¯¯¬©§£—–•——”Ž‰‡‡‰ŒŽŽ‹ŠŠŒŽ‘’’’““’Œ‹Š‰‰ˆ‡‡…ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚„……†ˆˆˆ‰Šˆ†ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ…‡‰ˆˆ‡…ƒ‚‚ƒ„…†‡‡†…ƒ‚‚‚‚‚‚‚‚„‡ŠŽ”™žŸžœ›œœ›š˜—•’‘’‘Ž’•˜›ž¡¥¨¬¯±µº½ÀÃÆÊÏ×Ýßáåêïôùýþýûúø÷÷øø÷÷÷õôôõôóôõö÷øúúúøø÷÷øøôðíëéæäáÙÒÍÇÀº´±°°­«§£žš—–••Š†„…‡‰Š‹Œ‹‹‰ˆˆˆ‰Š‹’““•–”’ŽŒ‹Š‰‰ˆˆˆ…ƒ‚‚‚‚‚‚‚‚‚‚‚‚„‡‡‡‡ˆˆ‰Š‰†ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒƒ„……†…„‚‚ƒ‚‚ƒ…‡†ƒ‚‚‚‚‚‚‚‚‚ƒ†‰‹Ž‘–œ¡¡Ÿžžž›™–”’’“’’’‘’•™ž¢¤§ª®¯±µ¹¼¿ÂÃÈÎÖÜßáæêïôùüüýüüúùúúøö÷÷öôõöôôôõö÷ùûúù÷õõõ÷øôðíëèåâÞ×ÐËÅ¿¹´°¯®­ª¦¢Ÿ›˜–”‘‹†ƒƒ„…†‡‡‡ˆ‰ˆ‡‡†…†Š‹Œ’“•––“‘‹‹‹‹Šˆ‰ˆ†ƒ‚‚‚‚‚‚‚‚‚‚‚‚…††‡††ˆ‰Š‰…‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ„„„ƒƒƒƒ…‡‡ˆ…ƒ‚‚‚‚‚‚‚‚‚ƒ‡‹’•˜œ¡ ž›ššœœ›˜•“““““•”“‘’—¢¦¨ª«¬®²µ¸º½ÀÃÉÏÖÜßâåêïôøúúúúûúùøøõôóòññòòññðñóôõõóòññðñóõòîëèãàÜØÒÌÆÁº´¯­«ª©§¢Ÿš—”‘‡ƒ‚‚‚‚‚‚‚„†‰ˆˆ‡„ƒ…ˆŠŠ‹‘“’‘Œ‹ŠŠ‹‰ˆˆ‡…ƒ‚‚‚‚‚‚‚‚‚‚‚‚ƒ…„ƒ‚‚ƒ„…„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ…„„„…‡‰‰ˆ†ƒ‚‚‚‚ƒ…†…„…ˆŽ‘•—˜œ Ÿš˜™›››˜•••“”•––•““™ ¦ª¬­¬­°´·¹»¾ÀÄÉÏÖÜàäçêïô÷ùùùúûúùø÷õòïììííîïïîîïïïíìëììíîñòðìéåáÜ×ÓÍÈþ¶°¬ª¨¦¤¡ž›™–“‘ŽŠ…‚‚‚‚‚‚‚‚‚…‡ˆ‡…ƒƒ„‡‰ŠŠ‹ŒŽŽŽŒŒŒ‹ŒŒŠˆ‡…„ƒ‚‚‚‚‚‚‚‚‚‚‚‚ƒ„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚„††……††‡ˆˆ†ƒ‚‚‚„†ŠŠ‰‡‡Š‘–™šž Ÿ›™™š›œš™˜—••–—––•–œ£©®°±¯¯²¶¹¼½¿ÂÆÊÏÕÜáæéìðóöøùùùùùúø÷óðëççééêëëëëêéçååæèêëíîîêæãáÛÕÒÏÊÅÀº²¬§¤¡Ÿ›™–”‘‰…‚‚‚‚‚‚‚‚‚‚ƒ……„ƒƒ‚„…†‡‡ˆŠŒŒŒŠ‰‰Š‹ŒŽ‹‡„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚„†††††……‡‡…ƒ‚‚ƒ†ŠŽŒŒŒ”™›Ÿ Ÿžœ™™šœœ››š˜––––———š ¦¬±³³²²µ¹¼¾¿ÁÃÈÌÏÕÜáçêíñóöùúúùùùùøöòíæããääåçèçæãâáààáãåçéêêåáÞÛÕÐÍÉÅÀ»¶¯¨£ž›™˜–”’Ž‹ˆ„‚‚‚‚‚‚‚‚‚‚‚ƒƒƒƒƒƒƒƒ„………†‡‰Š‰‰ˆ‡‡‡‰ŒŽ‹‡ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ„……‡†…„…†‡…„‚‚‚†ŠŽ‘“–˜š›œžŸž›™™š››ššš™—–•””–™œ£©®²²²²´¸»¾ÁÂÂÅÈËÏÕÜáæèíðòô÷øùùùøöôòíæàÝÜÜÜÜÞàààßÞÝÝÝÞàâäååäßÛØÖÐÊÆÄ¿ºµ±ª¤ œ˜–•“ŒŠˆ…ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ…‡†…„„………†…„ƒƒ†‰‹Œˆ…ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ„…„…‡†…„„†‡…„‚‚„ˆ‹Ž’“•—™šœœžžž›˜˜—˜˜˜˜™™—•““”—›¡¦¬±²²³µ¸»½ÀÁÂÄÆÈËÐÖÛàäçìïòôö÷øùù÷óñîèâÝÙ×ÕÔÕ×ÙÙÚÚÚÚÛÚÛÜÞÞßàßÛÖÔÑÌÆÃÀºµ±¬¦¢ž›—•“ŒŠˆ…ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ…‡†„‚‚‚‚ƒƒ‚‚‚ƒ…‡‰Šˆ†ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ„……„„ƒ‚‚„†…„ƒƒ†‹Ž’”—™›œœžžžžžžž›™–”““““”••”““•˜£¨®±´¶¸¹»¼¾¿ÀÃÇÈËÎÑÕÚÝáæëïóöøø÷øøóïíêæàÚÖÒÐÏÐÑÒÓÔÕÖÖÖÖÖÖÖÕÖÙÛÖÒÏËÇÃÀ¼¸³®¨¥¢ž›˜•‘Šˆ…‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚…ˆ†„‚‚‚‚‚‚‚‚‚ƒ…‡‰‹Š‡„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ…‡…„ƒƒ‚‚„†……„…ŠŽ’”–™œŸžž   ŸŸŸŸŸ™–”“’‘‘“––•““–™Ÿ¥ª­²¶¸º»»¼¾¿¿ÄÈÊÍÏÐÔ×Úßäéíòöøø÷öôðëéæáÜ×ÒÏÌÊËËËÍÏÐÑÒÓÓÒÑÐÏÒÕÖÓÎÉÆĽ¹µ±«¥£¡š—”‹ˆ…ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ†‡…ƒ‚‚‚‚‚‚‚‚‚ƒ„‡Š‹Šˆ„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ‚‚‚‚ƒƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚„†…„ƒƒƒ„†‡‡‡‡‰‹‘”•—šœœœžŸŸ¡¡ œ™˜˜–“’“–˜––”“•™Ÿ¤§¬±·¹º¹¹»½¼¾ÂÇÊÍÎÐÒÕØÜàäêïòõõóòñìçäàÜ×ÒÏÍËÉÈÆÅÆÇÈËÍÎÎÎÍÌÍÐÓÕÐÊÆľ¸´²¯¨¢ —“’‹†ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚„†…ƒ‚‚‚‚‚‚‚‚‚‚ƒ†‡‡‡†ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒƒ‚‚‚‚ƒƒƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚„…†…ƒ‚ƒ…ˆŠŠŠ‹ŒŽ‘“”–™››š™šž ££¡ššš—•••™š˜–””—› £§«±¸¹¸··¹º»½ÁÆÊÎÏÏÒÔØÜßâæêïòñðïìèäßÛ×ÒÎËÊÈÇÅÃÁÁÁÃÆÉËÊÊÉÊËÎÑÓÎÈÅÁ¾¹´±¯¬¦¡™“Š†ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ…„ƒ‚‚‚‚‚‚‚‚‚‚„††……„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒƒ‚ƒ…†††…„ƒ„…†……„ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒƒ„…„ƒƒƒ„‡‹‘’’’’”•–—˜˜˜˜™›¡¥¥¤ ›˜—–—šœš——š¡¤¨¬²¸·¶µ¶·¸»¾ÃÈÌÏÐÑÓÖÙÜÜÞãèíñïìéæãßÛ×ÒÍÊÈÅÂÁÀ¿¾¼¼¿ÂÇÊÉÉÉÉÊËÎÐËǾºµ±­«¨¥¡›•‹ˆ…ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ……ƒƒƒƒ‚‚‚‚‚‚ƒƒƒƒ„„ƒƒƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒƒ‚ƒ†ˆ‰ˆ‡†††ˆ‰ˆˆ‡‡…ƒ‚‚ƒƒ„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ„„ƒ‚ƒ…ˆ”——•”””•––—˜˜˜™œž£¦¦¥¢¡ žœšššžœš›Ÿ¢¦ª®³··µ´µ·¹¼ÀÅÊÍÏÑÒÔÖØÚÙÛàæêíëçäáÝÚÖÒÎÊÇÿ½»ººº¹¹»¿ÅÈÈÇÈÉÈÉÌÌÊÆÁ¼·²¯«¨¦¤ ™’‰…‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ‡…„„ƒ‚‚‚‚‚‚ƒ„‚‚‚‚‚ƒƒƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒƒƒ„†ˆ†…†‡……†‡‡†‡ˆ††‡‡‡†„ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚„„ƒƒ„‡ŠŽ‘“•—˜——–•””•–—™šœž¡¥§¨§¥¤££¡   ¡¡ ŸžŸ¡¤§«¯³¶¶´²³¶¹»¿ÃÇËÏÐÑÔ×ØØÖ×ÛàãååãÞÙÖÓÎÉÆÄ¿¼º¸¶´´µ¶·¹½ÂÆÆÇÈÉÉÊËÊÇÄÀ¼¶±¬¨¥¤¡˜’Œˆ„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ…ƒ‚‚‚‚‚‚‚‚ƒ„„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒƒƒƒ„„ƒ„†‡†„†‡†‡‰‹‹‹ŒŒ‹Šˆ†ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ„„…†ˆ‹Ž’•–—™™™˜—•“”•–˜›Ÿ¡¤§©©©¨§§§§¦¦§¦¤£¢¡ ¡£§ª­°³µµ³²²µ·º¾ÂÆËÎÏÐÔØ×ÖÔÕØÜàâàÜ×ÒÏÌÅÀ¿¼¸µ³±¯®®°²´·»ÀÄÅÇÉÉÉÉÉÈÅ¿¼¶¯ª¦£¡ž›–‘‹‡„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ„ƒƒ‚‚ƒ„ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ…††……†‡ˆ‰‹Ž‰…„ƒ‚‚‚‚‚ƒ„ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚…‡ŠŠŒ”—™›œœ™—–••••˜›ž ¢¤§©ª©¨¨©¨©©«««©§¤¢¡ ¡¤§«¬¯±²±°°±±³·»¿ÅÉÌÍÐÕØÖÔÓÔ×ÛÞÞÙÔÏÌÉžº·´±®«¨§§©­¯²µ¸¼ÀÃÆÆÇÆÆÇÇÄÀ½º´®ª¥¡ž›˜“ŽŠ†ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ„……………„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ„…„„……‡‰‰ŠŒ’“““““Œ‰ˆ†…„ƒƒ„†‡…ƒ‚‚‚‚‚‚‚‚‚‚‚‚„‡ŠŽ’•˜›Ÿž›™—–––—™¡£¤¥¦¨©¨¨©ª©©¬­¬¬ª¨¥£¡ ¢¥¨¬¬®¯¯¯¯¯¯¯±´¸½ÃÇËÌÎÓÕÔÒÒÒÕØÚÚÔÎÊÇÿ¹´¯¬ª§¤¡  £¨«­°³¶»¿ÁÂÄÄÃÅŽº¸²­©¤Ÿš˜”‹‡„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ…†‡‡…ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ„„„„„ƒƒ„…††††‰‘‘‘Š‰ˆˆ…ƒ„…‡ˆ…ƒƒƒ‚‚‚‚‚‚‚‚‚‚„ˆ‰ŠŒŽ‘”–™œ ¢£ š———˜›ž¡¢¢¡¢¤§§¦§§§¨ªª©§¥¤£¢ŸžŸ ¤©ª¬­¯±²±°±³´µºÀÄÈÉÊÍÏÏÏÍÍÑÔÖÖÐËƽ¹´¯©¥¤¢¡ žŸ ¢¤©¬°³µ·¹¼¼½½½»¸¶³®ª§£˜’‰…‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒƒƒ„ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚„‡‡††…„ƒ„„…†…†ŠŽŽ‘‘ŠŠ‰†„…†‡ˆ‡…†…ƒ‚‚‚‚‚‚‚‚‚„†‡ŠŒ“–˜› £¥§¥¡œšššœŸ¡¢¡ Ÿ ¢¤¤¥¦¦§§¨§¥£¡¡  œœž£¦©«­±³³²±³³²³¸½ÂÆÇÆÇÈÊËÉÉÍÐÓÓÎǽ¸³®©¤ žž›šš›¡¦ª­­®°³µµ¶¶µ´²¯ª§¥¢œ•Žˆ„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚…ˆ‰‰ˆ‡†……††……‡ŠŒŽ‘’’‘ŽŒ‰‡††‡ˆˆ†…††„ƒƒƒ‚‚‚‚‚‚ƒ…‡ŠŒ’–› ¢¤¨ª¨¥ žŸ¢£¢¡ŸŸŸŸ ¢¥¥§§¦¥¤¢ ž›˜˜š ¢¦ª®³´´²³²±°²µ¹¾ÂÁÁÂÃÅÆÆÇÉËÍÎÊü¶²­§£Ÿœ™—————–—–—šž£§§¨¨©ª¬¯°°¯®«§¤¢ š“‹…‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚„ˆ‰‰ŠŠ‰ˆˆ‰‡‡‡ˆ‰‹ŒŽŽ‘’’’Œ‰‰‰Š‹Œ‹Š‰‰‰ˆ‡†…„ƒ„ƒƒƒ„†ˆ‹’–šŸ¢¥§«®«§£  ¡£¤¤¢ ŸŸžž¡£¥§§§¥£  ž›™——™œž¡¥©¯´´³²±±°°±³·»¾½½¾¿ÀÂÃÅÆÇÉÊž¶±­¨£ž›š—•“’“”””“”–šž¡¡¡¡¡¢¥ª«ª©¨¦£¡ —ˆƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ†‡ˆ‹ŽŒŒ‹‰‰ˆˆŠŒŒŒŒŽŽ‹‹‹Œ‘’ŽŒ‹ŠŠ‰ˆ‡††‡‡‰‹“—›ž¢¥©¬®¯¬¨¤¡ ¢¢¡ Ÿœœœ››Ÿ£¦¥¤¢¡¡¡Ÿœ›™˜šŸ¢¦ª¯³³²±¯¯®°²³µ¸º¹ººº»½¿ÀÀÁÃþ·±­©¥¡š˜”’Ž‘“”–—™›œžŸŸ¡¤¥£¡ Ÿœ›˜’Œ‡ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ…†ˆ‘ŽŒŠ‰ŠŒŒŒ‹ŠŠŠŒŽŒŽ‘“–—–”“’‘ŽŒŠ‰‰ŠŒ“–›ž¢¥©­°±±­ª§¤¤¥£¡Ÿ›š››™™›ž£¥£¢¡   žœš™™› £§¬¯±±°®­­®°²²³´µ´´´´·¹»¼¼¾¿½·±¬¨¥¢Ÿœ™•’‘ŽŒŒŒ‹Ž‘‘“•–˜š›œœžŸ›››š˜–“ŽŠ‡ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ…Š••”’‘ŽŽŽŽ‹‰ˆ‰‰Š‹Ž‘’“—šœž›™–”“’’‘Ž‘”˜œŸ¤¨¬¯²´³¯¬ª¨¨§¥£¡Ÿœš›š˜˜›ž¡££¢¡ žœœœš˜——›Ÿ¡£§«­°¯­««¬®°±±°¯®­¬­¯²´µµµ··µ±­¨£ ž›˜•’‘Œ‰ˆ‡‡ŠŒŒ‘“•——˜˜˜—˜˜˜—•’Š†„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ„…„‚‚‚‚‚‚‚‚‚‚„ˆ”š›™—•“‘‘‘‘ŽŒŠŠŠŠ‹’“”–™ ¢£¢ ™—––—•”””““”–›Ÿ¢¦«°²µµ³°®¬ª¨§¥£¢žš™˜˜——šœž¡¡   ž›››˜——™œž £¦©¬®­ªªª«­¯°°®¬©§¨©«­®¯¯¯°°°­ª¤Ÿ›˜”‘ŽŒ‰†…„„†ˆˆ‰ŠŒŽ‘’“““’“““”“‘Œ‡„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚„†‡†„‚‚‚‚‚‚‚‚ƒ…ˆŠ”šš˜™˜•’‘‘‘’‘ŽŽŽŽŽ’”•–––˜šŸ ŸŸ›š™™›››šš™˜—š¢¥¨­²´µ´²°­¨¥¤¢¡ ™———–”•—™œŸŸžŸ ›š——˜™š›œŸ£§ª­«ª«««¬®¯®¬ª¨§§¦¦¦§¨©ª«¬«¨¥ œ™–“Šˆ‡…ƒ‚‚‚„„…‡‰‰‰‹Ž‹‰‰ˆ„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒƒ‚‚‚‚‚‚‚‚‚‚„‡‹—ššš››—”’‘‘’’“’’’’’“”––—˜˜———˜šœžžœœž ¡¡¡ Ÿœ ¤¦©¯´¶¶µ²¯«¨¥¡žœ™––—–•“”–™œžœžŸžœ˜–—˜šœšš›œ¡¦©«ªª«­¬¬­­¬©§¦¥¤¢   ¡¢£¦§§¥¢˜”‘ŽŒ‹‰…„„ƒ‚‚‚‚‚‚ƒ…‡†‡ˆŠŒŒŒŒŽŒŠ†……†…‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚„ˆ“–™ššœœ˜–••–————˜˜˜™™˜˜——™›™˜–•–˜š›žŸ¡£¤¥¦¦¦¥¤¡¡£¥§¬°´¶·¶´¯«¨¤Ÿœ™˜—–•”“““”–˜šœœŸ ž›—•–˜šœ™™™šž¡¥¨©ª¬®¬ª©©¦¤£££¡š™™™šœž¡¢ œ™–“‹‡…ƒ‚‚‚‚‚‚‚‚‚‚‚ƒ„……„…‡‰ŒŒŠ‡„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚„‰‘”—˜š››šššš››››œžœ›š™››š™—–•—™›Ÿ£¦§©ª«ªª©©¥¤¤¥ª®²´¶··µ°«¨¥ ›˜—–•”“’’’“•˜™›œžž›—•—˜›œ™˜˜™›ž¢¦¨ª¬¬ª¨¨§¤¢¢¢Ÿœ˜•“’’“–™ž›—•“‡„‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒƒ‚‚ƒ„‡‰‹Š‡ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚…‹’”–˜šœžžžŸŸžžžŸŸ  Ÿ   ›››œœš™™š›Ÿ¢¥§¨ª¬®­¬«©§§¨«®°²´¶¸¹¸²­«¨¢œ˜–•”“‘‘’’’”––—™œœœœš–”–™œœš™šœžŸ ¢¥§¨©©©¨§¦¤£¡œ—’Ž’–——”’Ž‹†ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ…†…ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ†‹‘’’•—™œž ¡¡¤¥£¡¢£¢¡¡¢£¤££ žžžžžžŸŸŸž ¤¦©ª­°²°¯­«ª«­°²³´µ·¸ººµ°®¬¥žš—–•“’’’‘‘“”””—šš››™–•—šœ››œŸŸžŸ¢£¤¥§©¨¨§¦¤ ›”ŒŒ‹ŒŽ‘‘‹‰…ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ…Š’”–™›ž¢¤¦¨©§¥¥¦¥££¥¦¦¦¥£¢¡Ÿžž ¢¡¡ Ÿ¢¦ª­®°³µ´²°­­¯²´µµµµµ·»¼¸³±­§¢™—–•”‘‘’““”•˜š™˜˜˜˜™›œœžž››› £¥¦§©¨¥£ š”Œ‹ŠŠŠŠ‹‹‹ˆ†„ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ…ŠŽ‘”–™œ ¤¥¨ª¬ª¨¨¨§¤¤¤¥¦§¨¦¥£ Ÿ ¢£¡¡Ÿž¡¦«®¯°²³³´±°±³µ·¸·¶¶¶¹¼¼¹µ²¯ª¥ž™———•‘Ž“—š˜———˜˜šœœ›™—™œ ¤¥¥§©¨¦¤ š“‹Š‰ˆ‡‡‡‡‡„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚„„‡‹“–˜›Ÿ¡£¤§ª©¨¦¦¤¢¡¡¢£¦§¥£¡¡¡¢£¢Ÿœœž¡¥¨ª««¬®°°°²´¶¸¸···¹»»»¹·´°ª£™˜˜—•’‹‹Š‹’–š˜–•–••˜›œœœœœœššœž¢¦§§§¨¦¤¢ž˜’‰‡‡‡‡‡‡ˆ‡„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚„‡‡ˆŒŽŽ“•–˜œž¡£¦ª©¦¥¤¢¡Ÿ ¡£§§¥££¢¡¢¢¡ž›šš›Ÿ£¥¦¦§ª­®°²´¶¸¸···º»»»º¸¶²«¤žš™—–”’ŽŠ‡†‡‰‹Ž’–š™—•”“”˜›œœ›šœœ›œž ¤§§§§¦¤£ œ—“‰‡††‡‡‡ˆ‡„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ…ˆ‹ŒŒŒŽ“””—˜›Ÿ¢¦©¦£¢ ŸŸžŸ¡¤¦¦¥¥¥¤£¢¡ ™——˜™œ ¡¢¢£¥¨«®°²´¶¶¶¶·º¼¼¼¹¶µ²¬¥Ÿ›˜–”’‹†ƒƒ…ˆ‹”™™—”‘’—ššš™›œœžŸ¡£¥¥¥¥¥¤£ œ—“Š†„„………†‡„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ„‡ŠŒŽŒ‘’’”•–˜£§§¤¡ŸŸ¡£¤¤¤¦¥¥¤¢¡ œ˜–•–—šžžž ¤©®°²´¶¶¶··¹»¼»¸µµ³®¨¢™–”’Ž‰„‚ƒ„ˆ‹”˜˜–“’•—˜˜š›œœžŸ¡£¥££¤¤¤¢ ›—’Ž‹ˆ†…„„„……ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚„‡ŠŽ‘‘‘”—˜™¡¤¥¢Ÿœšš›œžžžžž ¢¢£¢¡Ÿ›š˜˜——™›š™š›Ÿ£§«¯²µ¸¸¸··¹¼¼»¸µ´³¯ª¤žš—•’‡ƒ‚‚ƒ†‰“–•”’‘“–˜™š››œŸ ¡¢¢¡¡¢¢¡Ÿš–’ŽŒ‹‰‰‰ˆ†„ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒƒ…ˆ‹ŒŒŒ‘‘’•˜šœŸ¢¤¡žš™˜™››šššŸ ¡ Ÿ›ššš™˜———–•˜›ž¡¤¨­±·º¹¸··¹»¼¼¸µ´²¯«¦£ž™–’Œ†ƒ‚‚‚…‰‘’’“’’‘‘“•–——˜œŸŸžŸ  ŸŸ¡Ÿœ›–“‘Ž‹‰†„ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚…†ˆ‹ŒŒŒŽ‘“–™›œŸŸžœ™——™›››š™™œŸ ¡Ÿžœš™š™˜•“““’‘“—œ ¤§«°¶¹¸·¸¹¸¹»»¹·µ±­ª¨¦Ÿš–‘‹†ƒ‚‚…ˆ‹ŒŽ‘‘‘‘Ž‘’’”—œŸžžžŸ Ÿžž˜•‘‘ŽŒ‰†„„„ƒ„„ƒƒƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚…‡‰ŒŽŽŽ‘“–™›››››˜–—™š›››™˜›ž ¡ Ÿ›››™˜”’‘‘‘•šŸ£§ª¯´¸¸¹¹¸·¸ºº¹¸µ°¬ªª§ ™•Š…‚‚ƒ…ˆŠŠ‹Ž‹ŒŽ’—œžœ››œœž   ŸŸ™•’‘‘‘‹‡…„………†………„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ‡‰‹‘ŒŒ‘““”–—˜™›œœš™—•–™›œœ™˜›ž¡¤¤¢ žŸž›™–“’’‘’“”—›Ÿ£§«±µ·¶µµ¶¸¹¹·µ±­«ª§¢˜‘‹†ƒ‚‚‚ƒ‡ŠŠ‹ŽŽŒŒŠ‰Š’•˜™˜˜™™š››œ›—’ŽŒ‹ˆ…ƒ‚‚‚‚‚‚‚‚ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ„†ˆŠ‹ŽŽŒŒŒŽ‘“““”””–˜šœœš˜––˜›œžŸŸœ›Ÿ¢¦§¦¤££¡š˜•“’“””•—›ž¢¤¨®²´³²²³µ··µ³¯­«¨£Ÿ›”‡„ƒ‚‚‚ƒ‡ŠŠ‹ŒŠ‰‰Š‹‰ˆŠ‘’“”•——––˜˜˜™ššš™”Ž‹‰‰‰‰ˆ†…ƒ‚‚‚‚‚‚‚ƒ„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ†‡ˆ‰ŠŒŒ‹ŒŽ‘““’“••—™›š˜˜šŸ ¢£¢  ¡£¦©©©©©§¤ ™—””•––—˜œŸ¡£¦ª®®­­®®°²´³³±®©¥Ÿš•‹‡„ƒ‚‚‚„‡ŠŠ‹‹‹ŠŠ‰ˆˆˆ‡‡‰Œ‘’“”••”•––—˜———–‘Œˆ‡‡‡†„‚‚‚‚‚‚‚‚‚‚„„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ…††………‡ŠŒŽ‘’‘’”••–šœš™šœ £¤¥¥¤¤¤¥§©ª«¬««ª§¤Ÿ™–•––——™œŸ¢£¤§ª©¨©«¬­¯±²²°­¨¢š”‘Ž‹‡„ƒ‚‚‚„‡ŠŠ‹‹Œ‹‰ˆ‡‡ˆˆ‡‰‹‘“””””••–—•““‘ˆ†……„‚‚‚‚‚‚‚‚‚‚‚‚ƒ„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ„††„ƒƒ…ˆ‰‰ŠŠ‹Ž‘‘’““”—™š™™›Ÿ¢¤¥§¨§¦§©««ª©©©©¨¦£¢žš˜˜——–•—™œŸŸŸ¢¥¦¥¦§©¬­¯°¯®«¥Ÿ–‘ŽŠ‡„ƒƒƒ„†‰Œ‹ŠŠŒŠ‡†††‡‡‡‰ŽŽŽ‘’””Œ‹‡…„ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ„†„ƒ„†ˆˆˆ‡‡ŠŒŽ‘‘’’“•—˜™™› £¥¨ª©§¨ª¬­¬¬ª©©©§¤¤£ žœ›™˜–””—š›šš¡¢¢¢£§ª¬®®­¬©¢›“Ž‹Š‡„ƒƒ„‡‰Œ‹‰ŠŒ‰††‡ˆ‰‰ˆ‹ŽŒ‹‹ŠŠ‹‹Œ‘Œ‰‡…ƒƒƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ……ƒƒ…†‡‡†…†‡ˆŠ’““”•••–˜š £§©ª©¨©¬­­®¯¬ª©¨¥¥¦¦¤¡ Ÿš–“”–———˜š››œŸ£¨«­¬¬ª¦ ™’ŽŒŠˆ†…„„†ˆŠŒŒ‰ˆŠ‹‰‰‰Š‹‹‹ŒŒŠŠˆ‡‡‡ˆŠ‹ŒŠ†ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ„†…ƒ‚‚‚ƒ„…„„…††ˆŒ‘“”””““”–™ž¢¥§¨©©©«®­­¯°¯¬©¦¥¦¨©§¥¤¢Ÿ™“‘’””•––———˜™œ¡¦ª­­ª¦¢˜’Ž‹‰‡††‡‡‡ˆŠ‹Š‰‰Š‹‹‹‹ŒŒŒŽŽŽŽ‹‹‰ˆ††…†‡‰Šˆ„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ„„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚„……ƒ‚‚‚‚‚ƒ†………‡ˆŠ‘“’’’“–› ¤¥¥¦¨©«­°®®°³²¯«¨§¨©©¦¤¡žš•‘“”””••–—˜› ¤©­¬¨¤žš–’Ž‹ˆ‡††‡‡††ˆ‡‡‰Š‹Œ‹Š‰‰Š‹ŒŒŒŒŒ‹ŒŒ‹Š‰ˆˆ‰ŠŠ‡„ƒƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ„ƒ‚‚‚‚ƒ†‰‡……‡ˆŠŒŽŽŽ‘‘‘’”—›¡¥¦¦¦§©«¯±¯¯²´³±®ªªªªª¦£Ÿš–‘Œ‹ŒŽ‘‘‘”–—™œŸ£¨­«¨¢›˜”‹‰ˆ‡††………„„…ˆ‹ŽŠ‰ˆ‰ŠŒŒ‹Œ‹ŒŽŽŒ‹Œ‹Š‡………„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ„ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ„ƒ‚‚‚ƒ…ˆŠ‡………†ˆ‹ŽŽ‘“•˜œ¡¥¦§¦§¨ª®°°±²³³²°®­¬«©¤ ›—’ŠˆˆŠ‹“–™›ž¡¥©¬©¥Ÿš–’‹‰ˆ†„ƒ‚ƒ‚‚‚ƒ‡ŒŽŽŒŠˆŠŒŽŒ‹‹‹Œ’’“‘ŽŠ‡‡‡ˆ‰‡„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚„†‡…ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒƒƒ‚ƒ……ˆŠ‡……†‡ˆ‹ŒŽ‘’–˜›ž¢¥¦§§§¨ª­¯°±³´³²±°®¬ª¨£ž˜“Œˆ…†ˆŠŠŠ‹Ž’—™ ¢¥©¬¨¤ž™•’Œ‹‰‡„ƒƒƒ‚‚‚„ˆ‹ŽŽŠˆ‹ŽŒŠ‰‹Ž’”••”’‰‡ˆŠ‹Šˆ†ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚„†‡…„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ„„…‡‡†‡‰Š‰‰‰ŠŒŽ‘“–™œ ¢£¥¦§¥¥¦¨ª«¬®±´²°¯®¬ª©§£ž—‘Œ‡„…ˆŠ‹‹Œ”—™› £§ª§¢™—”ŒŒŠ‰‡†……………ˆ‹Œ‹Šˆ†ˆŠŒ‹‰ˆ‰Œ’”•––•’ŽŠˆ‰Š‰ˆˆ†„ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚„…„„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚„†‡ˆ‰‹‹Š‰ˆˆ‹Ž’—› £¤¤¥¦¦¥¥¥¦§¨©«¯±°¯®®¬ª©§¢œ–’‡„„‡ŠŒŽ’•—˜™›ž¡¦©§£Ÿ›™—“ŽŒŒ‹‰‡‡‡ˆŠŒŒ‹‰‰‡†‡ˆŠŠˆ‡‡‰’“•–—–“‹ˆ‰Šˆˆ‡‡‡†ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ„„ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ†ˆ‰‹Œ‹‰‡‡‹’–šœ ¤¦¦¦¦¤¤¥¦¦¦¦¦§©¬¯±±°¯¬ª©¦¡œ˜”‘‡„…‡ŠŽ’•——˜šœ ¥§§¥¢Ÿ›–‘Ž‹Š‰‰‹ŽŽŒŠŠ‰‡‡‡ˆŠ‰‡‡‡ŠŽ‘”–——–“‹Š‰ˆˆ‡‡ˆ‡…ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚ƒƒ‚‚‚‚‚ƒ„ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ†‰‹ŒŠ‰ˆˆ‹Ž“—›ž£§§§¦¦¥¤¥¨§¥¥¥¦©­°²²±°­«¨¥ ›˜•‘Œ‡„…ˆ‹Ž’“•–———šŸ¤¨§¥¤¡žœ—’ŽŽŽŽŒ‹‹ŽŒ‹‹Šˆˆˆˆˆ‰ˆˆ‰‰‹Ž‘“–———–“‘Ž‹Šˆˆ‰ˆˆˆ‰‡…‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ‚‚‚‚‚‚ƒ„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ…‡Š‹Šˆ‡‰Š‹“–šŸ£¦¦§¦§¦¥¦¦¥¥¤¤§«¯²²±±¯¬¨¦¤ž™•’ŽŠ†ƒ„ˆ‹Ž’••–••˜¢¥£¡ žœ›—“ŽŒŒŒ‹ŠŠ‹‹ŒŒŒŠ‰‰ˆˆ‰‰ˆŠ‹Š‹Ž‘”–••–•“‹ˆˆˆˆ‰‰ˆ‡†„ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ…‡ˆ‡†‡Š‘’•šŸ£¦§¦§¨§¥¦¦¦¦¦§ª®²´²¯°¯ª¥£¡œ—“ŒŠ†ƒ…‡ŠŒŽ’••”’’–›Ÿ¢¡Ÿ›š™—“ŽŒŠ‹Œ‰‡ˆ‡‰‹ŽŒ‰‰ˆ‰‰‰ŠŒŒ‹ŒŽ’”•””””’‰†‡‡ˆ‰ˆˆ†„ƒƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ„ƒ‚ƒƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ„…†‰Œ”•””–™ž¢¥¥¦¨ª§¥¥¦§©©ª¬¯±´²°®­¨£¡Ÿš•‹‰ˆ†…†‡‰Œ“•”’’”˜›žœ™—–•”“’‘ŒŠ‰ˆ††††ˆ‹Ž‰ˆ‡‡ˆ‰Š‹‹‹ŒŽ‘“••”“’Œ‡††‡ˆ‰ˆ‡……„ƒƒƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒƒ„‚‚ƒƒƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ…Š•˜˜˜˜™š ¤¥¦©ª¨¦¦¦§©ª¬­¯²µ²¯®«¦£ ™“Ž‰‡‡‡†…†‰‹Œ’”“’•˜šš˜–”““”””’‘Œ‰‡‡†……„ˆŒ’‹‰†‡‰ŠŠ‹‹‹‹’””“‘‹ˆ†„„†‰Šˆ‡…„ƒƒ„ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ…†„ƒƒ„ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚…‹’—š›žž ¡¢¤¥§¨¨¨©¨§¨©«®°²´µ±®«©¥¡š—“‡„„…„ƒ…‡ˆŠŒ‘‘‘“””••”“””–––•“ŽŠ‡‡‡…„„…‰‘Š‡‡ˆ‰‰‰ŠŠŠ‹ŽŽ‹ˆ‡†„‚‚„‡Š‰‡„ƒƒ…„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ†‡…ƒƒƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ†Ž”˜Ÿ¢£¤¤¤¥¥§¨¨©ª«©¨©«®²´µ··²­ª§£ œ˜–’‹†„„ƒ‚ƒ„…†ˆ‰ŒŽŽŽ‘‘‘’’’’“•–—–”‘Ž‹‰‡‡‡…„„†‰ŒŽ‘Œ‰‰ˆ‰‰ŠŠ‰ˆŠ‹ŽŒ‰†„„„ƒ‚‚ƒ†‰Šˆ†………ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ…„…‡ˆ†„ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ…‰•› £¦§¨¨©¨§¨ª«««ª©©«®±µ¶¸º¹´¯©¥¡žš—”‹‡††ƒƒ‚‚‚ƒ„†ˆ‹‹‹ŒŽŽŒŽ‘‘“““”•’ŽŒ‹‰ˆ‡†…„…‡‰ŠŽŽŒŒ‹Š‰ŠŠŠ‰‰‹ŽŒ‰…‚‚‚‚‚‚ƒ†‰Š‰ˆ‡…ƒ‚‚‚‚‚‚‚‚‚‚ƒƒƒ‚‚ƒ…††‰‹‹‰†„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ…‡Š‘—¢¥¨©ªª«ª©ª¬¬«ªª©©¬¯³¶¸º»ºµ¯©¤ œ™—”Œ‰ˆ‡…„ƒ‚‚‚‚ƒ‡ˆ‰Š‹Œ‹ŠŠ‹Ž’”ŒŒŠ‰ˆ‡ˆˆ‡‡‰‰‰ŒŽŒŠ‰‰ŠŠŠ‹ŒŽŽ‹‡„‚‚‚‚‚‚„†‡ˆ‡‡†„‚‚‚‚‚‚‚‚‚‚ƒ„„ƒƒƒ„…‡‰‹‹‰†„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚„†ˆˆŠ–œ¡£¤¥¦¦¦¦§¨©ª«ª©¦¦©­±´¸»½½¸³¬§ ›š™•‘ŽŒŠ‰ˆ‡…ƒ‚‚‚…††ˆ‰ŠŠŠ‹ŠŠŒŒŒ’ŽŒ‹Š‰ˆ‰ŠŠ‰‰‰‰Š‹Œ‹ŠŠŠŠˆ†‡ˆˆˆ‡‡‰Š†ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒƒ‚‚‚‚ƒ…ˆˆ‰Š‡…ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ‡ˆ‰ˆ‰Ž•›Ÿ ¡¢£££¤¥¦¨ªª©¨¥¤§¬°³¸º½¾¹´®¨¡žœ›—“‘‹‹‹ˆ„ƒ‚„………†ˆ‡‰Š‹Š‰‰‰‰Š‹‹Ž‘ŽŒ‹‹ˆˆŠŒŒ‹Š‰‰‰ŠŠŠ‰‡‡‡†„„†‡†„ƒƒ…†ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ…ˆˆ‰ŒŠˆ‡„ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ„‡‰‹‹Œ‘–›Ÿ Ÿ ¢£¤¥¥¦§¨©§¤¡¡¤ª­²µ¸»½¹µ°©£Ÿœ—””“ŽŽŽŠ‡……ƒƒƒ„†ˆ‰‰ˆ‰‡†………†‡‰Ž‘ŒŠˆ†‡ŠŒ‹Šˆ‡ˆ‰ˆˆ‡†……ƒ‚‚‚„…ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ…‡†‡‹Ž‹ŠŠ‡…„ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ…ŠŒŽ”–šžžžŸ ¢¤¤¦§§¨¨¤ žŸ£¨¬°³¶¹»¹¶°ª¤ ž›˜———•“‘ŒŠˆ†ƒƒ„„†‡ˆˆˆ‰ˆ†„„ƒ„…ˆ‹ŽŒŠ‡‡†ˆŠŒ‹Š‰‰‰ˆ‡††…„ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ………‡ŠŒŠˆ‰Š‰‡†„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ…‰Ž‘“”•˜ššš› ¢¤¦¦§¨¨¤ ŸŸ¢¦©«¯³¶¹·´¯ª¥¡›™™šš˜”’‹ˆ‡……„ƒƒƒ„„…‡‡†…†„„…†ˆ‰‡…„……†‰‹ŒŒ‹‹‰‡†‡††„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ„„„†‰†……†††…„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒƒ…†‰Œ‘’”––•“”–––™šž¢¥¦¥¦§§£ŸŸŸ ¡¤§«°´¶µ³¯«§¢žœ››œœ™–”‘Ž‹‰ˆ‡‡„‚‚‚‚‚ƒ„…†††„ƒ„…†…ƒ‚‚‚ƒ„ˆ‹ŒŒŒŒ‰†…‡‡‡…ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚„†„ƒ‚ƒ„„„ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ†‰ŠŒŽ’—˜™˜—”’“””•—™¡¤¦¦¦¦¤ žžŸ £¨­±³²±¯­©¦¢Ÿžœš™—”‘‹‡„‚‚‚‚‚‚‚ƒ†‰ˆ…‚‚‚„„ƒ‚‚‚‚‚ƒ…ˆ‰‰ŠŒŠ‡‡‡‡‡†…ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚†‹Ž‘”—š›š˜•””””•—™¡¤§¦¦¤ žœœœ›ž¡¥©­¯¯°¯®ª§£¡ žœ›™—”‘Ž‹†ƒ‚‚‚‚‚‚‚‚†Šˆ„‚‚ƒƒ‚‚‚‚‚‚‚‚ƒ……†‰‹‰ˆ†††††…ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ‡Œ“˜œŸžœ›š˜™™˜˜˜™› £¥¥£Ÿœšš›™™šœ¡¦¨ª¬­«©¦£¡¡Ÿœš˜•’‹Šˆ„‚‚‚‚‚‚‚‚‚†Š‡ƒ‚‚‚ƒƒ‚‚‚‚‚‚‚‚‚‚ƒ………ƒƒƒƒƒƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ…„„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚„ˆŒ–›ž¡ žœœžŸžœœœŸ¡£¢ œ›™˜™˜˜—˜™ž£¦¨©©¨¥£¡¡ ›™–“ŽŒ‰†……‚‚‚‚‚‚‚‚‚ƒ‡‰†ƒ‚‚‚ƒƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ††…ƒ‚‚ƒƒ„ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚„ˆ‹•›Ÿ¤£¡   ¢£¤¢ žž   žœš™—•••–———šŸ£¦¥¥¤¢¡  žš—”’ŽŒŠˆ†„„„‚‚‚‚‚‚‚‚ƒ…††„ƒ‚‚ƒ„„ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ‡†…ƒƒ…‡ˆˆ…ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚…ˆŠ”š¡¦¥¤¤£¤¦¨©¨¥¢Ÿ ¡ ž›˜™˜–“““”•––˜œ¡¤£¡  Ÿ žœ—“‘Œ‹‰†…ƒ„ƒ‚‚‚‚‚‚‚‚ƒ„……„„ƒ‚ƒ„„ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚„ˆ‡†……‡Š‹Œ‰†ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚„†‰”›¢¦¦¦¤¤§ª«¬ª¨¤¡¡¢ žš˜˜˜”‘‘‘’•™ž¡Ÿœœœœœš˜•“’Ž‰‡††…„ƒ‚‚‚‚‚‚‚‚ƒ„†„„ƒ‚‚ƒƒƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚…ˆ†…„„†ˆ‹‹‰…‚‚ƒƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ†Š‘–œ£¨¨¦¥¦¨«­¯®«¦¢¢¢¡Ÿ›˜–”’ŽŽŽ’•šœššš™˜––•”’‘ŽŠ‡‡††…ƒ‚‚‚‚‚‚‚‚‚„†…„„ƒ‚‚ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚…ˆ†„ƒ„†‰ŒŽŠ…ƒ„……„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ‡“˜ž£¨§¦¥¦¨ª®°¯¬¨§¥¢¡Ÿ›˜”’ŽŽŽ‘”˜š™ššš˜—–•••““Šˆ†………ƒ‚‚‚‚‚‚‚‚‚„…„„„„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚„‡†…†ˆŠ‹ŽŠ‡††ˆ‰ˆ…ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚…Š–™£§¦¥¥¦¨«®±¯­ª§¤¢¡Ÿœ˜”ŽŒŒ“•–˜˜—••”““’‘‘ŽŠˆ‡…„„ƒ‚‚‚‚‚‚‚‚‚‚ƒƒƒƒƒƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ…„†‡Š‹ŒŽ‹‰ˆ‰‹Œˆ…ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒˆ’—šž£§¦¥¥¦©«®¯®«¥¡ŸŸ›™—“ŒŠ‰‡‡†…‡‡ˆ‹ŽŒŠ‰ˆ†„„ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒƒ„†‰‰‹‘Ž‹ŠŠŠ‹‰†ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚„‰”˜œ £¤¦§¦§¨ª­®¬¨¢œœ›š˜–’Š†…„ƒ‚‚‚‚„…‡ˆ‰‰‰‰ˆ‰Š‡…ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ…†ˆˆ‰Ž‘ŒŽŽ‹‡„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ‡Œ’–™ ¡£¥¦¦¦¥¥¨ª§¤Ÿ›š™˜—•“‡„‚‚‚‚‚‚‚‚‚‚ƒ„„„ƒƒ……ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚„††Š’’‘ŒŠ†„ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ†‹•˜šœž ¢£¤¤£¢¢¤¥£¡œš—–•“’‘Ž‹‡ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ„‡Š””“’‘‘Šˆ…„ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚†‹”˜›žžŸ¡£££¢¡ŸŸ ¡Ÿš—”“‘ŽŒŠˆ„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ†ˆŒ‘”““’’’’‹ˆ†„ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚„‰Ž“˜›Ÿ¢£¤¥¥¥¤£¡ž›˜–“‘ŒŠ‰ˆ†„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ†‰Œ‘”“““”“‘Ž‰‡„ƒ„ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒˆ“˜œ ¤§¨§§¨¨¦£Ÿœ›˜”’Œ‰†„ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ…ˆ‹’‘’’ŽŽŒ‹‰‡†„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚†Œ“™ž¡¥¨ªª©ª«ª¦¢Ÿ›™•‘ŽŒŠ‰†ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ…ˆŠŽŽ‘“‘ŒŠ‡„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚„‰˜Ÿ£¥¨ª¬¬¬¬¬©¦¢Ÿœ™•“‘Ž‹ˆ†ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ…‡ŠŒŒŽ‘“’’’“’‘‘‘‰†„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚…‰–œ¡¤¦©««¬¬­ª¦£¡Ÿ™—•’Ž‰‡„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ„ˆ‹ŒŽ’““”•–•“““‹‡…„ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ‡‹•› ¤¦ª««¬®¯«¨¥¢Ÿœ™˜”‘‰†ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ‡ŠŒ‘’’”–™˜––•’Š‡…ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚„ˆŒ“˜¡¦ª­­®±³®©¦¢Ÿœ›™”‘ˆ„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ‡Š‘’”—š™˜—–“‘‰‡„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ‚ƒ„…‰Ž’–š ¥«®¯°²´¯«§¤¡žœ™•‘‹†ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ…ˆ‹Ž’“•˜š™——–“‹ˆ†„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ…‡‡‰‰ŠŒŽ’•™Ÿ¥¨«­°´¶²­©¥¢Ÿ›—‘Š…‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚„ˆŠŒ’”•˜š˜˜—•“Ž‹‰…ƒƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ…ˆŒŽ“”–™ž£§ª­±µ·²­§£¡ žœ—‘‹…‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ‡ˆŠ‘’“–˜–•••“‘‘‘ŽŠ‡†…„ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚„†‰‘“•––””•–—šŸ¥¨«­°´µ±¬¨¥£¡ž›–Š„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ†ˆ‰‘“–—•”””“““’Œ‰ˆ‡†„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚„†‰‘”—ššš™™™™šœ ¥¨«­°´¶³¯ª¦£¡œ—’‡ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ…ˆ‹Ž“”•“’“”””“’Š‡…„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒˆ‘•™š›››šš™š¢¦©¬°´µ³°«§¤Ÿ™”‹‡ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚„ˆ‹Ž‘“““’’“”““’’Ž‹ˆ…ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚„‰Ž•™›œœ››™˜˜› ¥©¬°³³±®¬©¢œ—“Ž‹‡„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚…ˆŠŒ‘’“’‘‘‘‘‘’‘Œ‹‡…ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚…ŠŽ”˜š›œœš˜——›¡§ª¬¯±±¯®«§ š•Š‡„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ…‡ˆ‹Ž‘“”“’’‘’‘’ŽŒŒ‰†„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ†Š”–™›œœœ™™——œ£©¬¬­¯¯­ª§¤Ÿ˜’Œˆ…ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ…‡‰‹’”•”•““’’’‘ŽŽ‹ˆ…ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ†‰Œ“–˜™˜—˜˜–—œ£¨ª«®¯®ª§¤ œ–ˆ„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ†ˆŠŒ’•——–•””“’‘ŽŒˆ„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ…†‰“•–””–––˜¤§ª«­®®©¤ œ—’Œ‡ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ…‡‰Œ’”–˜˜˜—•”’’“’’‘‹ˆ„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ…‰‘’‘‘’”–˜™ž£§«¬®¯®¨¢ž™”Š‡„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚„‡ŠŽ’””––—˜—•“’““““‘Š‡ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚„ˆŒŽŽŽ‘“–˜›ž¢§ª¬®®¬¥ œ™”‹‡ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ†Š’’“”“’’‘‘‘‘Ž‹ˆ…„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚„‰ŒŒŽŽ’•™žŸ£§ª¬­«¥ š•‹‡ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒƒƒƒƒƒ‚ƒƒ‡ŠŒŽ‹‡…ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ†ŠŠŠ‹ŒŽ’–šžž¢¥§ª¬«¦¡™”‹ˆ…„ƒƒƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚„†††…„ƒ„„…‰ŒŒŽŽŽ‹ŠŠ‹ŒŒŒŠˆ…ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚„†ˆ‡‡ˆ‹ŒŽ’—›žž ¡£¦ª©¥ œ˜•‘Šˆ††‡…ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ…ˆ‰ˆ†„„†‡ˆŠ‹ŒŽŽŒŠˆ†‡‡‰ŠŠˆ†„ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ‚‚‚‚‚‚‚‚‚‚ƒ„…†††ˆŠŒ”˜›žžžž¡¤¦¥£ ›—”’Ž‹ŠŠ‰ˆ†…ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ…ˆŠŠˆ††‡ˆ‰‹ŒŒ‹ˆ†……„„…‡…„ƒƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ…ƒ‚‚‚‚‚‚‚‚ƒƒƒƒ„…‡‰”–˜šœž £¢¡ ™•”‘ŽŒŠ‰‡†…ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ…ˆ‰Š‹ŠŠ‰‰Š‹ŒŽŽ‹‡…„ƒ‚‚ƒƒƒ‚ƒƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚†ˆ…ƒ‚‚‚‚‚ƒ„…„ƒƒƒ…†‰’–˜˜šœœœŸ¡ ž›˜–”’‘Œ‹Š‰ˆˆ‡…ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒƒƒƒ„†ˆŠ‹ŒŽŒŒ‘‘ŽŒ‡…ƒ‚‚‚‚‚‚‚ƒƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚„ˆŠˆ‡„ƒƒƒ…‡ˆˆ†„ƒ„…‡Š“˜™™›žž››œžžžš–”’‘‘ŒŠ‰ˆˆˆˆ‡„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ„„ƒ„†ˆ‹ŽŽŽ‘ŽŽ‘’‘‹‡„‚‚‚‚‚‚‚ƒƒƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒƒ‚‚‚‚‚‚‚ƒ„†ŠŒ‹‰†„„…ˆ‹‹‰‡…„…‡ˆŒ•™ššŸžžœœœŸœ˜•”’‹ˆ‡‡†††‡„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒƒƒ„‡‹ŽŽŒ‹‹‹‹ŒŽŒ‹‹ˆ†„ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ„‡ŠŒŽŒ‰†…„…ˆ‹‹‹Šˆ‡‡‡ŠŽ‘•™™šžœœŸ¡ž›˜—“‘‹ˆ‡†„„…†„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ„„ˆŒ’Œ‹Š‰‰‰ˆ‰ŠŠ‰‰‰Š‰ˆ†…ƒ‚ƒƒƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ„„†ŠŒŽŠ‡‡††ˆ‹ŒŒŒ‹‰‡ˆ‹•˜™š›œžžž¡¡Ÿ›™”‘Šˆ†„ƒƒ„†„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ„…„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ…†‡Š’ŽŒŠˆˆ‰ˆ†‡ˆ‰ˆˆˆ‰ˆ‡††„„„„ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚„†‡ŠŒ‘ŒŠˆ‡‡Š‹‰‰Š‹Œ“–˜™™šœŸŸ ¢¡ Ÿœ™”‘‹ˆ…ƒ‚‚ƒ„ƒƒƒƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ…†…ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚„†ˆ‰Š‘’‘ŽŒˆˆ‰‰‡††‡ˆ‡ˆ‰‰ˆˆˆ‡†‡‡†„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ‚‚‚‚‚‚‚ƒ„†‰‹ŒŽ‘“‘‹ŠŠŒŒŽ‹‹Œ‹Œ’•—™š›œŸ Ÿ Ÿœ›™–“’Ž‹‡„ƒƒ‚‚‚‚‚‚„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ„ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ…‡ˆ‰‹‘Š‰‰‰ˆ‡‡‡‰Š‹Œ‹‹Š‹‰ˆˆˆ‡‡…ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ†ˆŠ‘””’‘ŽŽŽŽŽ’”•—™š›œœœœ›š™—•”“‰†„„ƒ‚‚‚‚‚ƒ„ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ„†‡ˆ‹Ž‘ŒŠŠŠŠ‰‰‰Š‹ŒŽŒŒ‹Š‰ˆ‡‡„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚„‡Š’•••–”’‘‘’’’’‘’”••–™››œœœ›ššš™˜—–”‘Ž‹‡ƒ‚‚‚‚‚‚‚‚ƒ„„„ƒƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ…†††‡‰ŠŒ‹‹‹‹Œ‹‹ŒŽŽŽŽŒŒ‹‹Šˆˆ‡„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ†ŠŽ“•–˜˜˜—–•••––•••“’“•–—™›œ›™™š™—––•’Š…ƒ‚‚‚‚‚‚‚‚ƒ„……†„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚„†ˆ‡†ˆ‰‰‰ŒŒŒŒŒŒŒŽŒŒ‰ˆˆ‡…ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚„‰Ž’•——˜šš™˜—˜™™˜—•”“•———˜šœœ››œš˜˜—•”’‘‘Œ‡„„ƒƒ‚‚‚‚‚‚‚ƒƒƒƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚…ˆ††‡ˆ‡‡ŠŒŒŒ‹ŒŽŽ‘ŽŒ‹‹ŠŠˆ‡…ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ‡Œ“““•–——–––˜˜–––––——–––˜˜—˜šš™—–•“‘ŽŽŽŒˆ…„„„„‚‚‚‚‚‚‚ƒƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚„ƒƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒƒ‚‚ƒ†‡††††…†ˆŠŒŒŒ‹‘ŽŽŒ‹ŠŠˆˆ‡„ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ„ƒƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚…‰‘‘’”•••––——–—˜˜™™—•”•––••—˜˜–”’ŽŒŒŠˆ…„ƒ‚‚ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ…ƒƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒƒ„…‡‡………†ˆˆˆˆ‡ˆŠŒ’“‘Ž’‘Œ‹Š‰†„„ƒ‚‚ƒƒƒ„ƒƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ†‡‡…………„ƒ‚‚ƒƒƒƒ‚‚‚‚‚ƒ„†ŠŽ‘“–˜™—–•”–—™š—•“’”••””““”‘ŒŠ‰‰Š‹‡„ƒ‚‚‚‚ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ…„ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ„†‡†††††‡ˆˆˆ‡‡ˆŠ‘”•“‘ŽŽ‘””’‘‘ŒŠ‡……„ƒ‚„……………„ƒƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚…ˆŠŠ‰‰‰ˆ†„ƒ„…††„‚‚‚‚ƒƒ„†ŠŽ‘”—š›™–”“”—››—”’‘’’“”’Œ‹Šˆ††ˆ‰†…„ƒƒƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ„‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚„„„„…†‡‡‡ˆ‹‹‹Œ’•–•“‘‘‘“••”“‘Ž‹Š‰‰‡†……‡ˆ‡†‡‡††††…ƒƒ‚‚‚‚‚‚‚‚‚‚„‡ŠŠ‰‰ˆ†…„„……††…ƒ‚‚‚ƒ„††ˆŒ‘“”–šœ™–’‘’–™š˜•‘’’Œ‹ŠŠˆ…„„†‡†…„„ƒƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒƒ„††††ˆŽŽ“”—˜–”““”–—˜—•‘ŽŽ‹‰Š‹‰ˆ‡‡‰ŠŠŠ‹‹‰ˆ‰‰ˆ†„ƒ‚‚‚‚‚‚‚‚„†‰‹Š‰ˆ†„ƒƒ…†††…„ƒ‚ƒƒ„…‡ˆŠŽ‘’“”–™›š—’’•˜š˜•ŽŒŠ‰ˆ‡„ƒƒƒ…†„ƒƒƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ„…‡ˆŠ‘‘“””––•””–˜™šš™–’Œ‹‹‹‹Š‰ŠŠ‹ŒŽ‹Š‹Šˆ†„ƒ‚‚‚‚‚‚‚„†ˆŠŠˆ†„ƒƒƒ„…†††…ƒ‚ƒƒƒ…‡‰ŠŒ‘’’’“•—™š™–“’“•˜˜—”Ž‹‰ˆ†„0 \ No newline at end of file diff --git a/progs/demos/tessdemo.c b/progs/demos/tessdemo.c new file mode 100644 index 00000000000..26403eee0a2 --- /dev/null +++ b/progs/demos/tessdemo.c @@ -0,0 +1,524 @@ + +/* + * A demo of the GLU polygon tesselation functions written by Bogdan Sikorski. + * Updated for GLU 1.3 tessellation by Gareth Hughes + */ + +#include +#include +#include +#include + +#define MAX_POINTS 256 +#define MAX_CONTOURS 32 +#define MAX_TRIANGLES 256 + +#ifndef GLCALLBACK +#ifdef CALLBACK +#define GLCALLBACK CALLBACK +#else +#define GLCALLBACK +#endif +#endif + +#ifdef GLU_VERSION_1_2 + +typedef enum{ QUIT, TESSELATE, CLEAR } menu_entries; +typedef enum{ DEFINE, TESSELATED } mode_type; + +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 { + GLfloat p[MAX_POINTS][2]; + GLuint point_cnt; +} contours[MAX_CONTOURS]; + +static struct { + GLsizei no; + GLfloat p[3][2]; + GLclampf color[3][3]; +} triangles[MAX_TRIANGLES]; + + + +static void GLCALLBACK error_callback( GLenum err ) +{ + 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] ); + } +} + +static void GLCALLBACK begin_callback( GLenum mode ) +{ + /* Allow multiple triangles to be output inside the begin/end pair. */ + triangle_cnt = 0; + triangles[triangle_cnt].no = 0; +} + +static 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; + } +} + +static void GLCALLBACK end_callback() +{ + GLuint 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 ) +{ + GLsizei no; + GLfloat *p; + + 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; + } +} + +static void GLCALLBACK combine_callback( GLdouble coords[3], + GLdouble *vertex_data[4], + GLfloat weight[4], void **data ) +{ + GLfloat *vertex; + + 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 ) +{ + width = w; + height = h; +} + +typedef void (GLAPIENTRY *callback_t)(); + +static void tesse( void ) +{ + GLUtesselator *tobj; + GLdouble data[3]; + GLuint i, j, point_cnt; + + list_start = glGenLists( 2 ); + + tobj = gluNewTess(); + + if ( tobj != NULL ) { + gluTessNormal( tobj, 0.0, 0.0, 1.0 ); + gluTessCallback( tobj, GLU_TESS_BEGIN, (callback_t) glBegin ); + gluTessCallback( tobj, GLU_TESS_VERTEX, (callback_t) glVertex2fv ); + gluTessCallback( tobj, GLU_TESS_END, (callback_t) glEnd ); + gluTessCallback( tobj, GLU_TESS_ERROR, (callback_t) error_callback ); + gluTessCallback( tobj, GLU_TESS_COMBINE, (callback_t) 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] ); + data[2] = 0.0; + gluTessVertex( tobj, data, contours[j].p[i] ); + } + } + + gluEndPolygon( tobj ); + glEndList(); + + gluTessCallback( tobj, GLU_TESS_BEGIN, (callback_t) begin_callback ); + gluTessCallback( tobj, GLU_TESS_VERTEX, (callback_t) vertex_callback ); + gluTessCallback( tobj, GLU_TESS_END, (callback_t) end_callback ); + gluTessCallback( tobj, GLU_TESS_EDGE_FLAG, (callback_t) 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] ); + data[2] = 0.0; + gluTessVertex( tobj, data, contours[j].p[i] ); + } + } + + gluEndPolygon( tobj ); + glEndList(); + + gluDeleteTess( tobj ); + + glutMouseFunc( NULL ); + mode = TESSELATED; + } +} + +static void left_down( int x1, int y1 ) +{ + 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 ) { + glVertex2fv( contours[contour_cnt].p[point_cnt-1] ); + glVertex2fv( P ); + } else { + glVertex2fv( P ); + glVertex2fv( P ); + } + + glEnd(); + glFinish(); + + contours[contour_cnt].point_cnt++; +} + +static void middle_down( int x1, int y1 ) +{ + GLuint point_cnt; + (void) x1; + (void) y1; + + point_cnt = contours[contour_cnt].point_cnt; + + 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 ) +{ + x -= x%10; + y -= y%10; + + switch ( button ) { + case GLUT_LEFT_BUTTON: + if ( state == GLUT_DOWN ) { + left_down( x, y ); + } + break; + case GLUT_MIDDLE_BUTTON: + if ( state == GLUT_DOWN ) { + middle_down( x, y ); + } + break; + } +} + +static void display( void ) +{ + GLuint i,j; + GLsizei ii, jj; + GLuint point_cnt; + + glClear( GL_COLOR_BUFFER_BIT ); + + switch ( mode ) { + case DEFINE: + /* draw grid */ + glColor3f( 0.6, 0.5, 0.5 ); + + glBegin( GL_LINES ); + + for ( ii = 0 ; ii < width ; ii += 10 ) { + for ( jj = 0 ; jj < height ; jj += 10 ) { + glVertex2i( 0, jj ); + glVertex2i( width, jj ); + glVertex2i( ii, height ); + glVertex2i( ii, 0 ); + } + } + + glEnd(); + + 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 ) { + case 0: + break; + case 1: + glVertex2fv( contours[i].p[0] ); + glVertex2fv( contours[i].p[0] ); + break; + case 2: + glVertex2fv( contours[i].p[0] ); + glVertex2fv( contours[i].p[1] ); + break; + default: + --point_cnt; + 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 ) { + glVertex2fv( contours[i].p[0] ); + glVertex2fv( contours[i].p[j] ); + } + break; + } + + glEnd(); + } + + glFinish(); + break; + + case TESSELATED: + /* 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 ); +} + +static void clear( void ) +{ + contour_cnt = 0; + contours[0].point_cnt = 0; + triangle_cnt = 0; + + glutMouseFunc( mouse_clicked ); + + mode = DEFINE; + + glDeleteLists( list_start, 2 ); + list_start = 0; +} + +static void quit( void ) +{ + exit( 0 ); +} + +static void menu_selected( int entry ) +{ + switch ( entry ) { + case CLEAR: + clear(); + break; + case TESSELATE: + tesse(); + break; + case QUIT: + quit(); + break; + } + + glutPostRedisplay(); +} + +static void key_pressed( unsigned char key, int x, int y ) +{ + (void) x; + (void) y; + + switch ( key ) { + case 'c': + case 'C': + clear(); + break; + case 't': + case 'T': + tesse(); + break; + case 27: + case 'q': + case 'Q': + quit(); + break; + } + + glutPostRedisplay(); +} + +static void myinit( void ) +{ + /* 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 ); + + contour_cnt = 0; + mode = DEFINE; +} + +static void reshape( GLsizei w, GLsizei h ) +{ + 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 ); + glLoadIdentity(); + + set_screen_wh( w, h ); +} + +#endif + + +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" ); +} + + +int main( int argc, char **argv ) +{ + const char *version = (const char *) gluGetString( GLU_VERSION ); + printf( "GLU version string: %s\n", version ); + if ( strstr( version, "1.0" ) || strstr( version, "1.1" ) ) { + fprintf( stderr, "Sorry, this demo reqiures GLU 1.2 or later.\n" ); + exit( 1 ); + } + + usage(); + + glutInit( &argc, argv ); + glutInitDisplayMode( GLUT_SINGLE | GLUT_RGB ); + glutInitWindowPosition(0, 0); + glutInitWindowSize( 400, 400 ); + glutCreateWindow( argv[0] ); + + /* GH: Bit of a hack... + */ +#ifdef GLU_VERSION_1_2 + myinit(); + + glutDisplayFunc( display ); + glutReshapeFunc( reshape ); + + glutMainLoop(); +#endif + + return 0; +} diff --git a/progs/demos/texcyl.c b/progs/demos/texcyl.c new file mode 100644 index 00000000000..c04d5004e37 --- /dev/null +++ b/progs/demos/texcyl.c @@ -0,0 +1,288 @@ + +/* + * Textured cylinder demo: lighting, texturing, reflection mapping. + * + * Command line options: + * -info print GL implementation information + * + * + * Brian Paul May 1997 This program is in the public domain. + */ + +#include +#include +#include +#include +#include + +#include "readtex.h" + +#define TEXTURE_FILE "../images/reflect.rgb" + +#define LIT 1 +#define TEXTURED 2 +#define REFLECT 3 +#define ANIMATE 10 +#define POINT_FILTER 20 +#define LINEAR_FILTER 21 +#define QUIT 100 + +static GLuint CylinderObj = 0; +static GLboolean Animate = GL_TRUE; + +static GLfloat Xrot = 0.0, Yrot = 0.0, Zrot = 0.0; +static GLfloat DXrot = 50.0, DYrot = 125.0; + +/* performance info */ +static GLint T0 = 0; +static GLint Frames = 0; + + +static void Idle( void ) +{ + static double t0 = -1.; + double dt, t = glutGet(GLUT_ELAPSED_TIME) / 1000.0; + if (t0 < 0.0) + t0 = t; + dt = t - t0; + t0 = t; + + if (Animate) { + Xrot += DXrot * dt; + Yrot += DYrot * dt; + glutPostRedisplay(); + } +} + + +static void Display( void ) +{ + glClear( GL_COLOR_BUFFER_BIT ); + + glPushMatrix(); + glRotatef(Xrot, 1.0, 0.0, 0.0); + glRotatef(Yrot, 0.0, 1.0, 0.0); + glRotatef(Zrot, 0.0, 0.0, 1.0); + glScalef(5.0, 5.0, 5.0); + glCallList(CylinderObj); + + glPopMatrix(); + + glutSwapBuffers(); + + if (Animate) { + GLint t = glutGet(GLUT_ELAPSED_TIME); + Frames++; + if (t - T0 >= 5000) { + GLfloat seconds = (t - T0) / 1000.0; + GLfloat fps = Frames / seconds; + printf("%d frames in %g seconds = %g FPS\n", Frames, seconds, fps); + T0 = t; + Frames = 0; + } + } +} + + +static void Reshape( int width, int height ) +{ + glViewport( 0, 0, width, height ); + glMatrixMode( GL_PROJECTION ); + glLoadIdentity(); + glFrustum( -1.0, 1.0, -1.0, 1.0, 10.0, 100.0 ); + glMatrixMode( GL_MODELVIEW ); + glLoadIdentity(); + glTranslatef( 0.0, 0.0, -70.0 ); +} + + +static void SetMode(GLuint m) +{ + /* disable everything */ + glDisable(GL_LIGHTING); + glDisable(GL_TEXTURE_2D); + glDisable(GL_TEXTURE_GEN_S); + glDisable(GL_TEXTURE_GEN_T); + + /* enable what's needed */ + if (m==LIT) { + glEnable(GL_LIGHTING); + } + else if (m==TEXTURED) { + glEnable(GL_TEXTURE_2D); + } + else if (m==REFLECT) { + glEnable(GL_TEXTURE_2D); + glEnable(GL_TEXTURE_GEN_S); + glEnable(GL_TEXTURE_GEN_T); + } +} + + +static void ModeMenu(int entry) +{ + if (entry==ANIMATE) { + Animate = !Animate; + if (Animate) + glutIdleFunc(Idle); + else + glutIdleFunc(NULL); + } + else if (entry==POINT_FILTER) { + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + } + else if (entry==LINEAR_FILTER) { + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + } + else if (entry==QUIT) { + exit(0); + } + else { + SetMode(entry); + } + glutPostRedisplay(); +} + + +static void Key( unsigned char key, int x, int y ) +{ + (void) x; + (void) y; + switch (key) { + case ' ': + Animate = !Animate; + if (Animate) + glutIdleFunc(Idle); + else + glutIdleFunc(NULL); + break; + case 27: + exit(0); + break; + } + glutPostRedisplay(); +} + + +static void SpecialKey( int key, int x, int y ) +{ + float 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( int argc, char *argv[] ) +{ + GLUquadricObj *q = gluNewQuadric(); + CylinderObj = glGenLists(1); + glNewList(CylinderObj, GL_COMPILE); + + glTranslatef(0.0, 0.0, -1.0); + + /* cylinder */ + gluQuadricNormals(q, GL_SMOOTH); + gluQuadricTexture(q, GL_TRUE); + gluCylinder(q, 0.6, 0.6, 2.0, 24, 1); + + /* end cap */ + glTranslatef(0.0, 0.0, 2.0); + gluDisk(q, 0.0, 0.6, 24, 1); + + /* other end cap */ + glTranslatef(0.0, 0.0, -2.0); + gluQuadricOrientation(q, GLU_INSIDE); + gluDisk(q, 0.0, 0.6, 24, 1); + + glEndList(); + gluDeleteQuadric(q); + + /* lighting */ + glEnable(GL_LIGHTING); + { + GLfloat gray[4] = {0.2, 0.2, 0.2, 1.0}; + GLfloat white[4] = {1.0, 1.0, 1.0, 1.0}; + GLfloat teal[4] = { 0.0, 1.0, 0.8, 1.0 }; + glMaterialfv(GL_FRONT, GL_DIFFUSE, teal); + glLightfv(GL_LIGHT0, GL_AMBIENT, gray); + glLightfv(GL_LIGHT0, GL_DIFFUSE, white); + glEnable(GL_LIGHT0); + } + + /* fitering = nearest, initially */ + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + + 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); + glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); + + if (!LoadRGBMipmaps(TEXTURE_FILE, GL_RGB)) { + printf("Error: couldn't load texture image\n"); + exit(1); + } + + glEnable(GL_CULL_FACE); /* don't need Z testing for convex objects */ + + SetMode(LIT); + + 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)); + } +} + + +int main( int argc, char *argv[] ) +{ + glutInit( &argc, argv ); + glutInitWindowSize( 400, 400 ); + glutInitWindowPosition( 0, 0 ); + + glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE ); + + glutCreateWindow(argv[0] ); + + Init(argc, argv); + + glutReshapeFunc( Reshape ); + glutKeyboardFunc( Key ); + glutSpecialFunc( SpecialKey ); + glutDisplayFunc( Display ); + glutIdleFunc( Idle ); + + glutCreateMenu(ModeMenu); + glutAddMenuEntry("Lit", LIT); + glutAddMenuEntry("Textured", TEXTURED); + glutAddMenuEntry("Reflect", REFLECT); + glutAddMenuEntry("Point Filtered", POINT_FILTER); + glutAddMenuEntry("Linear Filtered", LINEAR_FILTER); + glutAddMenuEntry("Toggle Animation", ANIMATE); + glutAddMenuEntry("Quit", QUIT); + glutAttachMenu(GLUT_RIGHT_BUTTON); + + glutMainLoop(); + return 0; +} diff --git a/progs/demos/texdown.c b/progs/demos/texdown.c new file mode 100644 index 00000000000..79525a0395e --- /dev/null +++ b/progs/demos/texdown.c @@ -0,0 +1,403 @@ + +/* + * 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 +#include +#include +#include + + +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; + + +struct FormatRec { + GLenum Format; + GLenum Type; + GLenum IntFormat; + GLint TexelSize; +}; + + +static const struct FormatRec FormatTable[] = { + /* Format Type IntFormat TexelSize */ + { GL_BGRA, GL_UNSIGNED_BYTE, GL_RGBA, 4 }, + { 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 }, + { GL_LUMINANCE, GL_UNSIGNED_BYTE, GL_LUMINANCE, 1 }, + { GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, GL_LUMINANCE_ALPHA, 2 }, + { GL_ALPHA, GL_UNSIGNED_BYTE, GL_ALPHA, 1 }, +}; +static GLint Format; + +#define NUM_FORMATS (sizeof(FormatTable)/sizeof(FormatTable[0])) + +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"; + case GL_BGRA: + return "GL_BGRA"; + case GL_LUMINANCE: + return "GL_LUMINANCE"; + case GL_LUMINANCE_ALPHA: + return "GL_LUMINANCE_ALPHA"; + case GL_ALPHA: + return "GL_ALPHA"; + 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); + } + + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glEnable(GL_TEXTURE_2D); + + 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); + } + + /* draw a tiny polygon to force texture into texram */ + glBegin(GL_TRIANGLES); + glTexCoord2f(0, 0); glVertex2f(1, 1); + glTexCoord2f(1, 0); glVertex2f(3, 1); + glTexCoord2f(0.5, 1); glVertex2f(2, 3); + glEnd(); + + t1 = glutGet(GLUT_ELAPSED_TIME) * 0.001; + time = t1 - t0; + count++; + } while (time < 3.0); + + glDisable(GL_TEXTURE_2D); + + 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 '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; +} diff --git a/progs/demos/texenv.c b/progs/demos/texenv.c new file mode 100644 index 00000000000..590867b4945 --- /dev/null +++ b/progs/demos/texenv.c @@ -0,0 +1,815 @@ + +/* 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 + */ + +#include +#include +#include +#include + +#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_TRUE; +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, GL_RGBA, "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 = 0; +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; + + while ( (error = glGetError()) != GL_NO_ERROR ) { + fprintf( stderr, "Error: %s\n", (char *) gluErrorString( error ) ); + } +} + +static void drawString( const char *string, GLfloat x, GLfloat y, + const GLfloat color[4] ) +{ + glColor4fv( color ); + glRasterPos2f( x, y ); + + while ( *string ) { + glutBitmapCharacter( GLUT_BITMAP_TIMES_ROMAN_10, *string ); + string++; + } +} + +static void drawStringOutline( const char *string, GLfloat x, GLfloat y, + const GLfloat color[4], + const 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 = 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, + const 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; + /* Note: format=GL_INTENSITY for glTexImage is not legal */ + textureFormat = GL_LUMINANCE; + 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, const GLfloat lightCheck[4], + const 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 const char *lookupFormat( GLint format ) +{ + switch ( format ) { + case GL_RGBA: + return "GL_RGBA"; + case GL_RGB: + return "GL_RGB"; + case GL_ALPHA: + return "GL_ALPHA"; + case GL_LUMINANCE: + return "GL_LUMINANCE"; + case GL_LUMINANCE_ALPHA: + return "GL_LUMINANCE_ALPHA"; + case GL_INTENSITY: + return "GL_INTENSITY"; + case GL_COLOR_INDEX: + return "GL_COLOR_INDEX"; + case GL_BGRA: + return "GL_BGRA"; + case GL_BGR: + return "GL_BGR"; + default: + return "unknown format"; + } +} + +static void drawSample( int x, int y, int w, int h, + const struct formatInfo *format, + const 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_NEAREST ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST ); + + 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 ); + } + else { + glShadeModel( GL_FLAT ); + glColor4f(1, 1, 1, 1); + } + if ( drawTextured ) { + glEnable( GL_TEXTURE_2D ); + } + + /* + * if (drawSmooth) then draw quad which goes from purple at the + * bottom (100% alpha) to green at the top (50% alpha). + */ + glBegin( GL_QUADS ); + if ( drawSmooth ) glColor4f( 1.0, 0.0, 1.0, 1.0 ); + glTexCoord2f( 0.0, 0.0 ); + glVertex2f( -0.8, -0.8 ); + + if ( drawSmooth ) glColor4f( 1.0, 0.0, 1.0, 1.0 ); + glTexCoord2f( 1.0, 0.0 ); + glVertex2f( 0.8, -0.8 ); + + if ( drawSmooth ) glColor4f( 0.0, 1.0, 0.0, 0.5 ); + glTexCoord2f( 1.0, 1.0 ); + glVertex2f( 0.8, 0.8 ); + + if ( drawSmooth ) glColor4f( 0.0, 1.0, 0.0, 0.5 ); + glTexCoord2f( 0.0, 1.0 ); + glVertex2f( -0.8, 0.8 ); + glEnd(); + + glDisable( GL_BLEND ); + glShadeModel( GL_FLAT ); + glDisable( GL_TEXTURE_2D ); + + if ( envMode->mode == GL_DECAL && + (format->baseFormat == GL_ALPHA || + format->baseFormat == GL_LUMINANCE || + format->baseFormat == GL_LUMINANCE_ALPHA || + format->baseFormat == GL_INTENSITY)) { + /* undefined format/mode combination */ + begin2D( w, h ); + drawStringOutline( "UNDEFINED MODE", 15, h / 2, + labelLevelColor0, labelLevelColor1 ); + end2D(); + } + else if ( displayLevelInfo ) { + GLint width, height, border, format; + 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_INTERNAL_FORMAT, &format ); + 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, "internal format:" ); + drawStringOutline( buf, 15, h / 2, labelLevelColor0, labelLevelColor1 ); + + sprintf( buf, " %s", lookupFormat( format ) ); + drawStringOutline( buf, 15, h / 2 - 10, labelLevelColor0, labelLevelColor1 ); + + sprintf( buf, "sizes:" ); + drawStringOutline( buf, 15, h / 2 - 20, labelLevelColor0, labelLevelColor1 ); + + sprintf( buf, " %d / %d / %d / %d / %d / %d", + redSize, greenSize, blueSize, alphaSize, + luminanceSize, intensitySize ); + drawStringOutline( buf, 15, h / 2 - 30, 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" ); + fprintf( stderr, " up/down - select row\n" ); + fprintf( stderr, " left/right - change row's internal format\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 ); + glutInitWindowPosition( 0, 0 ); + 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; +} diff --git a/progs/demos/texobj.c b/progs/demos/texobj.c new file mode 100644 index 00000000000..40bce6e5695 --- /dev/null +++ b/progs/demos/texobj.c @@ -0,0 +1,284 @@ + +/* + * Example of using the 1.1 texture object functions. + * Also, this demo utilizes Mesa's fast texture map path. + * + * Brian Paul June 1996 This file is in the public domain. + */ + +#include +#include +#include +#include +#include +#include "GL/glut.h" + +static GLuint Window = 0; + +static GLuint TexObj[2]; +static GLfloat Angle = 0.0f; +static GLboolean UseObj = GL_FALSE; + + +#if defined(GL_VERSION_1_1) || defined(GL_VERSION_1_2) +# define TEXTURE_OBJECT 1 +#elif defined(GL_EXT_texture_object) +# define TEXTURE_OBJECT 1 +# define glBindTexture(A,B) glBindTextureEXT(A,B) +# define glGenTextures(A,B) glGenTexturesEXT(A,B) +# define glDeleteTextures(A,B) glDeleteTexturesEXT(A,B) +#endif + + + + +static void draw( void ) +{ + glClear( GL_COLOR_BUFFER_BIT ); + + glColor3f( 1.0, 1.0, 1.0 ); + + /* draw first polygon */ + glPushMatrix(); + glTranslatef( -1.0, 0.0, 0.0 ); + glRotatef( Angle, 0.0, 0.0, 1.0 ); + if (UseObj) { +#ifdef TEXTURE_OBJECT + glBindTexture( GL_TEXTURE_2D, TexObj[0] ); +#endif + } + else { + glCallList( TexObj[0] ); + } + glBegin( GL_POLYGON ); + glTexCoord2f( 0.0, 0.0 ); glVertex2f( -1.0, -1.0 ); + glTexCoord2f( 1.0, 0.0 ); glVertex2f( 1.0, -1.0 ); + glTexCoord2f( 1.0, 1.0 ); glVertex2f( 1.0, 1.0 ); + glTexCoord2f( 0.0, 1.0 ); glVertex2f( -1.0, 1.0 ); + glEnd(); + glPopMatrix(); + + /* draw second polygon */ + glPushMatrix(); + glTranslatef( 1.0, 0.0, 0.0 ); + glRotatef( Angle-90.0, 0.0, 1.0, 0.0 ); + if (UseObj) { +#ifdef TEXTURE_OBJECT + glBindTexture( GL_TEXTURE_2D, TexObj[1] ); +#endif + } + else { + glCallList( TexObj[1] ); + } + glBegin( GL_POLYGON ); + glTexCoord2f( 0.0, 0.0 ); glVertex2f( -1.0, -1.0 ); + glTexCoord2f( 1.0, 0.0 ); glVertex2f( 1.0, -1.0 ); + glTexCoord2f( 1.0, 1.0 ); glVertex2f( 1.0, 1.0 ); + glTexCoord2f( 0.0, 1.0 ); glVertex2f( -1.0, 1.0 ); + glEnd(); + glPopMatrix(); + + glutSwapBuffers(); +} + + + +static void idle( void ) +{ + static double t0 = -1.; + double dt, t = glutGet(GLUT_ELAPSED_TIME) / 1000.0; + if (t0 < 0.0) + t0 = t; + dt = t - t0; + t0 = t; + Angle += 120.0*dt; + glutPostRedisplay(); +} + + + +/* change view Angle, exit upon ESC */ +static void key(unsigned char k, int x, int y) +{ + (void) x; + (void) y; + switch (k) { + case 27: +#ifdef TEXTURE_OBJECT + glDeleteTextures( 2, TexObj ); +#endif + glutDestroyWindow(Window); + exit(0); + } +} + + + +/* new window size or exposure */ +static void reshape( int width, int height ) +{ + glViewport(0, 0, (GLint)width, (GLint)height); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + /* glOrtho( -3.0, 3.0, -3.0, 3.0, -10.0, 10.0 );*/ + 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 ) +{ + static int width=8, height=8; + static GLubyte tex1[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, 0, 0, + 0, 0, 0, 1, 1, 0, 0, 0, + 0, 0, 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 1, 0, 0, 0, + 0, 0, 0, 1, 1, 1, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0 }; + + static GLubyte tex2[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 2, 2, 0, 0, 0, + 0, 0, 2, 0, 0, 2, 0, 0, + 0, 0, 0, 0, 0, 2, 0, 0, + 0, 0, 0, 0, 2, 0, 0, 0, + 0, 0, 0, 2, 0, 0, 0, 0, + 0, 0, 2, 2, 2, 2, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0 }; + + GLubyte tex[64][3]; + GLint i, j; + + + glDisable( GL_DITHER ); + + /* Setup texturing */ + glEnable( GL_TEXTURE_2D ); + glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL ); + glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST ); + + + /* generate texture object IDs */ + if (UseObj) { +#ifdef TEXTURE_OBJECT + glGenTextures( 2, TexObj ); +#endif + } + else { + TexObj[0] = glGenLists(2); + TexObj[1] = TexObj[0]+1; + } + + /* setup first texture object */ + if (UseObj) { +#ifdef TEXTURE_OBJECT + glBindTexture( GL_TEXTURE_2D, TexObj[0] ); + assert(glIsTexture(TexObj[0])); +#endif + } + else { + glNewList( TexObj[0], GL_COMPILE ); + } + /* red on white */ + for (i=0;i +#include +#include +#include +#include + + +static float MinPeriod = 2.0; /* 2 seconds */ +static float Width = 400.0; +static float Height = 400.0; +static int Loops = 1; +static int Size = 50; +static int Texture = 0; + + + +static void Idle( void ) +{ + glutPostRedisplay(); +} + + +static void Display( void ) +{ + float x, y; + float xStep; + float yStep; + double t0, t1; + double triRate; + double pixelRate; + int triCount; + int i; + float red[3] = { 1.0, 0.0, 0.0 }; + float blue[3] = { 0.0, 0.0, 1.0 }; + + xStep = yStep = sqrt( 2.0 * Size ); + + glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); + + triCount = 0; + t0 = glutGet(GLUT_ELAPSED_TIME) * 0.001; + if (Texture) { + float uStep = xStep / Width; + float vStep = yStep / Height; + float u, v; + for (i=0; i +#include +#include +#include + +#ifdef WIN32 +#include +#endif + +#include +#include "readtex.h" +#include "tunneldat.h" + +#ifdef XMESA +#include "GL/xmesa.h" +static int fullscreen = 1; +#endif + +static int WIDTH = 640; +static int HEIGHT = 480; + +static GLint T0 = 0; +static GLint Frames = 0; +static GLint NiceFog = 1; + +#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 = 30.; +static float alpha = 90.0; +static float beta = 90.0; + +static int fog = 1; +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_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_LINEAR); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); +} + +static void +drawobjs(const int *l, const 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 void +calcposobs(void) +{ + static double t0 = -1.; + double dt, t = glutGet(GLUT_ELAPSED_TIME) / 1000.0; + if (t0 < 0.0) + t0 = t; + dt = t - t0; + t0 = t; + + 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); + + if (dir[0] < 1.0e-5 && dir[0] > -1.0e-5) + dir[0] = 0; + if (dir[1] < 1.0e-5 && dir[1] > -1.0e-5) + dir[1] = 0; + if (dir[2] < 1.0e-5 && dir[2] > -1.0e-5) + dir[2] = 0; + + obs[0] += v * dir[0] * dt; + obs[1] += v * dir[1] * dt; + obs[2] += v * dir[2] * dt; +} + +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 += 5.; + break; + case 'z': + v -= 5.; + 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; + case 'n': + NiceFog = !NiceFog; + printf("NiceFog %d\n", NiceFog); + break; + } + glutPostRedisplay(); +} + +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 - 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, "m - Toggle strips"); + glRasterPos2i(60, 270); + printstring(GLUT_BITMAP_TIMES_ROMAN_24, "b - Toggle 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 - 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 +draw(void) +{ + static char frbuf[80] = ""; + int i; + float base, offset; + + if (NiceFog) + glHint(GL_FOG_HINT, GL_NICEST); + else + glHint(GL_FOG_HINT, GL_DONT_CARE); + + 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(); + + 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(); + + Frames++; + { + GLint t = glutGet(GLUT_ELAPSED_TIME); + if (t - T0 >= 2000) { + GLfloat seconds = (t - T0) / 1000.0; + GLfloat fps = Frames / seconds; + sprintf(frbuf, "Frame rate: %f", fps); + T0 = t; + Frames = 0; + } + } +} + +static void +idle(void) +{ + glutPostRedisplay(); +} + + + +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(idle); + + glEnable(GL_BLEND); + /*glBlendFunc(GL_SRC_ALPHA_SATURATE,GL_ONE); */ + /*glEnable(GL_POLYGON_SMOOTH); */ + + glutMainLoop(); + + return 0; +} diff --git a/progs/demos/tunnel2.c b/progs/demos/tunnel2.c new file mode 100644 index 00000000000..75a199af5d3 --- /dev/null +++ b/progs/demos/tunnel2.c @@ -0,0 +1,605 @@ +/* + * 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 +#include +#include +#include + +#ifdef WIN32 +#include +#endif + +#include +#include "readtex.h" +#include "tunneldat.h" + +#ifdef FX +#endif + +#ifdef XMESA +#include "GL/xmesa.h" +static int fullscreen = 1; +#endif + +#ifdef FX +GLint fxMesaSelectCurrentBoard(int); +#endif + +static int WIDTHC0 = 640; +static int HEIGHTC0 = 480; + +static int WIDTHC1 = 640; +static int HEIGHTC1 = 480; + +static GLint T0 = 0; +static GLint Frames = 0; + +#define NUMBLOC 5 + +#ifndef M_PI +#define M_PI 3.1415926535 +#endif + +static float obs[3] = { 1000.0, 0.0, 2.0 }; +static float dir[3]; +static float v = 30.; +static float alpha = 90.0; +static float beta = 90.0; + +static int fog = 1; +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_LINEAR); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); +} + +static void +drawobjs(const int *l, const 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 void +calcposobs(void) +{ + static double t0 = -1.; + double dt, t = glutGet(GLUT_ELAPSED_TIME) / 1000.0; + if (t0 < 0.0) + t0 = t; + dt = t - t0; + t0 = t; + + 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); + + if (dir[0] < 1.0e-5 && dir[0] > -1.0e-5) + dir[0] = 0; + if (dir[1] < 1.0e-5 && dir[1] > -1.0e-5) + dir[1] = 0; + if (dir[2] < 1.0e-5 && dir[2] > -1.0e-5) + dir[2] = 0; + + obs[0] += v * dir[0] * dt; + obs[1] += v * dir[1] * dt; + obs[2] += v * dir[2] * dt; +} + +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 += 5.; + break; + case 'z': + v -= 5.; + 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 - 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, "m - Toggle strips"); + glRasterPos2i(60, 270); + printstring(GLUT_BITMAP_TIMES_ROMAN_24, "b - Toggle 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 - 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 +draw(void) +{ + static char frbuf[80] = ""; + int i; + float 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(); + + 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); + + Frames++; + { + GLint t = glutGet(GLUT_ELAPSED_TIME); + if (t - T0 >= 2000) { + GLfloat seconds = (t - T0) / 1000.0; + GLfloat fps = Frames / seconds; + sprintf(frbuf, "Frame rate: %f", fps); + T0 = t; + Frames = 0; + } + } +} + +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"); + + glutInitWindowPosition(0, 0); + glutInitWindowSize(WIDTHC0, HEIGHTC0); + glutInit(&ac, av); + + glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE); + +#ifdef FX + if (fxMesaSelectCurrentBoard(0) < 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) < 0) { + 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; +} diff --git a/progs/demos/tunneldat.h b/progs/demos/tunneldat.h new file mode 100644 index 00000000000..af1e52e1f17 --- /dev/null +++ b/progs/demos/tunneldat.h @@ -0,0 +1,395 @@ +/* Object: skin_13 */ + +#if defined(_MSC_VER) && defined(_WIN32) +#pragma warning( disable : 4305 ) /* 'initializing' : truncation from 'const double' to 'float' */ +#endif + +static const 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 +}; + +static const 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 */ + +static const int striplength_skin_12[] = { + 12, 12, 12, 12, 12, 0 +}; + +static const 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 */ + +static const int striplength_skin_11[] = { + 12, 12, 12, 12, 12, 0 +}; + +static const 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 */ + +static const int striplength_skin_9[] = { + 18, 0 +}; + +static const 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 +}; diff --git a/progs/demos/winpos.c b/progs/demos/winpos.c new file mode 100644 index 00000000000..2ee1df69fbc --- /dev/null +++ b/progs/demos/winpos.c @@ -0,0 +1,118 @@ + +/* + * Example of how to use the GL_MESA_window_pos extension. + * Brian Paul This file is in the public domain. + */ + +#include +#include +#include +#include +#ifdef _WIN32 +#include +#endif +#define GL_GLEXT_PROTOTYPES +#include "GL/glut.h" + +#include "readtex.h" + +#define IMAGE_FILE "../images/girl.rgb" + + +#ifndef M_PI +# define M_PI 3.14159265 +#endif + + + +static GLubyte *Image; +static int ImgWidth, ImgHeight; +static GLenum ImgFormat; + +typedef void (APIENTRY * PFNWINDOWPOSFUNC)(GLfloat x, GLfloat y); +static PFNWINDOWPOSFUNC WindowPosFunc; + +static void draw( void ) +{ + GLfloat angle; + + glClear( GL_COLOR_BUFFER_BIT ); + + for (angle = -45.0; angle <= 135.0; angle += 10.0) { + GLfloat x = 50.0 + 200.0 * cos( angle * M_PI / 180.0 ); + GLfloat y = 50.0 + 200.0 * sin( angle * M_PI / 180.0 ); + + /* Don't need to worry about the modelview or projection matrices!!! */ + (*WindowPosFunc)( x, y ); + + glDrawPixels( ImgWidth, ImgHeight, ImgFormat, GL_UNSIGNED_BYTE, Image ); + } + glFinish(); +} + + +static void key( unsigned char key, int x, int y ) +{ + (void) x; + (void) y; + switch (key) { + case 27: + exit(0); + } +} + + +/* new window size or exposure */ +static void reshape( int width, int height ) +{ + glViewport(0, 0, (GLint)width, (GLint)height); +} + + +static void init( void ) +{ +#ifdef GL_ARB_window_pos + if (glutExtensionSupported("GL_ARB_window_pos")) { + printf("Using GL_ARB_window_pos\n"); + WindowPosFunc = &glWindowPos2fARB; + } + else +#elif defined(GL_ARB_window_pos) + if (glutExtensionSupported("GL_MESA_window_pos")) { + printf("Using GL_MESA_window_pos\n"); + WindowPosFunc = &glWindowPos2fMESA; + } + else +#endif + { + printf("Sorry, GL_ARB/MESA_window_pos extension not available.\n"); + exit(1); + } + + Image = LoadRGBImage( IMAGE_FILE, &ImgWidth, &ImgHeight, &ImgFormat ); + if (!Image) { + printf("Couldn't read %s\n", IMAGE_FILE); + exit(0); + } + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); +} + + +int main( int argc, char *argv[] ) +{ + glutInitWindowPosition(0, 0); + glutInitWindowSize(500, 500); + glutInitDisplayMode( GLUT_RGB ); + + if (glutCreateWindow("winpos") <= 0) { + exit(0); + } + + init(); + + glutReshapeFunc( reshape ); + glutKeyboardFunc( key ); + glutDisplayFunc( draw ); + glutMainLoop(); + return 0; +} diff --git a/progs/egl/Makefile b/progs/egl/Makefile new file mode 100644 index 00000000000..41cadf97d2c --- /dev/null +++ b/progs/egl/Makefile @@ -0,0 +1,65 @@ +# progs/egl/Makefile + +TOP = ../.. +include $(TOP)/configs/current + + +INCLUDE_DIRS = -I$(TOP)/include + +HEADERS = $(TOP)/include/GLES/egl.h + +PROGRAMS = \ + demo1 \ + demo2 \ + demo3 \ + eglinfo \ + eglgears + + +.c.o: + $(CC) -c $(INCLUDE_DIRS) $(CFLAGS) $< -o $@ + + + +default: $(PROGRAMS) + + +demo1: demo1.o $(LIB_DIR)/libEGL.so + $(CC) $(CFLAGS) demo1.o -L$(LIB_DIR) -lEGL $(LIBDRM_LIB) -o $@ + +demo1.o: demo1.c $(HEADERS) + $(CC) -c $(CFLAGS) -I$(TOP)/include demo1.c + + +demo2: demo2.o $(LIB_DIR)/libEGL.so + $(CC) $(CFLAGS) demo2.o -L$(LIB_DIR) -lEGL $(LIBDRM_LIB) $(APP_LIB_DEPS) -o $@ + +demo2.o: demo2.c $(HEADERS) + $(CC) -c $(CFLAGS) -I$(TOP)/include demo2.c + + +demo3: demo3.o $(LIB_DIR)/libEGL.so + $(CC) $(CFLAGS) demo3.o -L$(LIB_DIR) -lEGL $(LIBDRM_LIB) $(APP_LIB_DEPS) -o $@ + +demo3.o: demo3.c $(HEADERS) + $(CC) -c $(CFLAGS) -I$(TOP)/include demo3.c + + +eglinfo: eglinfo.o $(LIB_DIR)/libEGL.so + $(CC) $(CFLAGS) eglinfo.o -L$(LIB_DIR) -lEGL $(LIBDRM_LIB) -o $@ + +eglinfo.o: eglinfo.c $(HEADERS) + $(CC) -c $(CFLAGS) -I$(TOP)/include eglinfo.c + + +eglgears: eglgears.o $(LIB_DIR)/libEGL.so + $(CC) $(CFLAGS) eglgears.o -L$(LIB_DIR) -lEGL $(LIBDRM_LIB) $(APP_LIB_DEPS) -o $@ + +eglgears.o: eglgears.c $(HEADERS) + $(CC) -c $(CFLAGS) -I$(TOP)/include eglgears.c + + +clean: + rm -f *.o *~ + rm -f *.so + rm -f $(PROGRAMS) diff --git a/progs/egl/demo1.c b/progs/egl/demo1.c new file mode 100644 index 00000000000..9ef17e38b7d --- /dev/null +++ b/progs/egl/demo1.c @@ -0,0 +1,145 @@ +/* + * Exercise EGL API functions + */ + +#include +#include +#include +#include +#include + + +/** + * Test EGL_MESA_screen_surface functions + */ +static void +TestScreens(EGLDisplay dpy) +{ +#define MAX 8 + EGLScreenMESA screens[MAX]; + EGLint numScreens; + EGLint i; + + eglGetScreensMESA(dpy, screens, MAX, &numScreens); + printf("Found %d screens\n", numScreens); + for (i = 0; i < numScreens; i++) { + printf(" Screen %d handle: %d\n", i, (int) screens[i]); + } +} + +/** + * Print table of all available configurations. + */ +static void +PrintConfigs(EGLDisplay d) +{ + EGLConfig *configs; + EGLint numConfigs, i; + + eglGetConfigs(d, NULL, 0, &numConfigs); + configs = malloc(sizeof(*configs) *numConfigs); + eglGetConfigs(d, configs, numConfigs, &numConfigs); + + printf("Configurations:\n"); + printf(" bf lv d st colorbuffer dp st supported \n"); + printf(" id sz l b ro r g b a th cl surfaces \n"); + printf("----------------------------------------------\n"); + for (i = 0; i < numConfigs; i++) { + EGLint id, size, level; + EGLint red, green, blue, alpha; + EGLint depth, stencil; + EGLint surfaces; + EGLint doubleBuf = 1, stereo = 0; + char surfString[100] = ""; + + eglGetConfigAttrib(d, configs[i], EGL_CONFIG_ID, &id); + eglGetConfigAttrib(d, configs[i], EGL_BUFFER_SIZE, &size); + eglGetConfigAttrib(d, configs[i], EGL_LEVEL, &level); + + eglGetConfigAttrib(d, configs[i], EGL_RED_SIZE, &red); + eglGetConfigAttrib(d, configs[i], EGL_GREEN_SIZE, &green); + eglGetConfigAttrib(d, configs[i], EGL_BLUE_SIZE, &blue); + eglGetConfigAttrib(d, configs[i], EGL_ALPHA_SIZE, &alpha); + eglGetConfigAttrib(d, configs[i], EGL_DEPTH_SIZE, &depth); + eglGetConfigAttrib(d, configs[i], EGL_STENCIL_SIZE, &stencil); + eglGetConfigAttrib(d, configs[i], EGL_SURFACE_TYPE, &surfaces); + + if (surfaces & EGL_WINDOW_BIT) + strcat(surfString, "win,"); + if (surfaces & EGL_PBUFFER_BIT) + strcat(surfString, "pb,"); + if (surfaces & EGL_PIXMAP_BIT) + strcat(surfString, "pix,"); + if (strlen(surfString) > 0) + surfString[strlen(surfString) - 1] = 0; + + printf("0x%02x %2d %2d %c %c %2d %2d %2d %2d %2d %2d %-12s\n", + id, size, level, + doubleBuf ? 'y' : '.', + stereo ? 'y' : '.', + red, green, blue, alpha, + depth, stencil, surfString); + } + free(configs); +} + + + +int +main(int argc, char *argv[]) +{ + int maj, min; + EGLContext ctx; + EGLSurface pbuffer; + EGLConfig configs[10]; + EGLBoolean b; + const EGLint pbufAttribs[] = { + EGL_WIDTH, 500, + EGL_HEIGHT, 500, + EGL_NONE + }; + + /* + EGLDisplay d = eglGetDisplay(EGL_DEFAULT_DISPLAY); + */ + EGLDisplay d = eglGetDisplay("!fb_dri"); + assert(d); + + if (!eglInitialize(d, &maj, &min)) { + printf("demo: eglInitialize failed\n"); + exit(1); + } + + printf("EGL version = %d.%d\n", maj, min); + printf("EGL_VENDOR = %s\n", eglQueryString(d, EGL_VENDOR)); + + PrintConfigs(d); + + ctx = eglCreateContext(d, configs[0], EGL_NO_CONTEXT, NULL); + if (ctx == EGL_NO_CONTEXT) { + printf("failed to create context\n"); + return 0; + } + + pbuffer = eglCreatePbufferSurface(d, configs[0], pbufAttribs); + if (pbuffer == EGL_NO_SURFACE) { + printf("failed to create pbuffer\n"); + return 0; + } + + b = eglMakeCurrent(d, pbuffer, pbuffer, ctx); + if (!b) { + printf("make current failed\n"); + return 0; + } + + b = eglMakeCurrent(d, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); + + TestScreens(d); + + eglDestroySurface(d, pbuffer); + eglDestroyContext(d, ctx); + eglTerminate(d); + + return 0; +} diff --git a/progs/egl/demo2.c b/progs/egl/demo2.c new file mode 100644 index 00000000000..17bbca61587 --- /dev/null +++ b/progs/egl/demo2.c @@ -0,0 +1,190 @@ +/* + * Exercise EGL API functions + */ + +#include +#include +#include +#include + +#include + +/*#define FRONTBUFFER*/ + +static void _subset_Rectf(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2) +{ + glBegin( GL_QUADS ); + glVertex2f( x1, y1 ); + glVertex2f( x2, y1 ); + glVertex2f( x2, y2 ); + glVertex2f( x1, y2 ); + glEnd(); +} + + +static void redraw(EGLDisplay dpy, EGLSurface surf, int rot) +{ + printf("Redraw event\n"); + +#ifdef FRONTBUFFER + glDrawBuffer( GL_FRONT ); +#else + glDrawBuffer( GL_BACK ); +#endif + + glClearColor( rand()/(float)RAND_MAX, + rand()/(float)RAND_MAX, + rand()/(float)RAND_MAX, + 1); + + glClear( GL_COLOR_BUFFER_BIT ); + + glColor3f( rand()/(float)RAND_MAX, + rand()/(float)RAND_MAX, + rand()/(float)RAND_MAX ); + glPushMatrix(); + glRotatef(rot, 0, 0, 1); + glScalef(.5, .5, .5); + _subset_Rectf( -1, -1, 1, 1 ); + glPopMatrix(); + +#ifdef FRONTBUFFER + glFlush(); +#else + eglSwapBuffers( dpy, surf ); +#endif + glFinish(); +} + + +/** + * Test EGL_MESA_screen_surface functions + */ +static void +TestScreens(EGLDisplay dpy) +{ +#define MAX 8 + EGLScreenMESA screens[MAX]; + EGLint numScreens; + EGLint i; + + eglGetScreensMESA(dpy, screens, MAX, &numScreens); + printf("Found %d screens\n", numScreens); + for (i = 0; i < numScreens; i++) { + printf(" Screen %d handle: %d\n", i, (int) screens[i]); + } +} + + +int +main(int argc, char *argv[]) +{ + int maj, min; + EGLContext ctx; + EGLSurface pbuffer, screen_surf; + EGLConfig configs[10]; + EGLint numConfigs, i; + EGLBoolean b; + const EGLint pbufAttribs[] = { + EGL_WIDTH, 500, + EGL_HEIGHT, 500, + EGL_NONE + }; + const EGLint screenAttribs[] = { + EGL_WIDTH, 1024, + EGL_HEIGHT, 768, + EGL_NONE + }; + EGLModeMESA mode; + EGLScreenMESA screen; + EGLint count; + + /* + EGLDisplay d = eglGetDisplay(EGL_DEFAULT_DISPLAY); + */ + EGLDisplay d = eglGetDisplay("!fb_dri"); + assert(d); + + if (!eglInitialize(d, &maj, &min)) { + printf("demo: eglInitialize failed\n"); + exit(1); + } + + printf("EGL version = %d.%d\n", maj, min); + printf("EGL_VENDOR = %s\n", eglQueryString(d, EGL_VENDOR)); + + eglGetConfigs(d, configs, 10, &numConfigs); + printf("Got %d EGL configs:\n", numConfigs); + for (i = 0; i < numConfigs; i++) { + EGLint id, red, depth; + eglGetConfigAttrib(d, configs[i], EGL_CONFIG_ID, &id); + eglGetConfigAttrib(d, configs[i], EGL_RED_SIZE, &red); + eglGetConfigAttrib(d, configs[i], EGL_DEPTH_SIZE, &depth); + printf("%2d: Red Size = %d Depth Size = %d\n", id, red, depth); + } + + eglGetScreensMESA(d, &screen, 1, &count); + eglGetModesMESA(d, screen, &mode, 1, &count); + + ctx = eglCreateContext(d, configs[0], EGL_NO_CONTEXT, NULL); + if (ctx == EGL_NO_CONTEXT) { + printf("failed to create context\n"); + return 0; + } + + pbuffer = eglCreatePbufferSurface(d, configs[0], pbufAttribs); + if (pbuffer == EGL_NO_SURFACE) { + printf("failed to create pbuffer\n"); + return 0; + } + + b = eglMakeCurrent(d, pbuffer, pbuffer, ctx); + if (!b) { + printf("make current failed\n"); + return 0; + } + + b = eglMakeCurrent(d, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); + + screen_surf = eglCreateScreenSurfaceMESA(d, configs[0], screenAttribs); + if (screen_surf == EGL_NO_SURFACE) { + printf("failed to create screen surface\n"); + return 0; + } + + eglShowScreenSurfaceMESA(d, screen, screen_surf, mode); + + b = eglMakeCurrent(d, screen_surf, screen_surf, ctx); + if (!b) { + printf("make current failed\n"); + return 0; + } + + glViewport(0, 0, 1024, 768); + glDrawBuffer( GL_FRONT ); + + glClearColor( 0, + 1.0, + 0, + 1); + + glClear( GL_COLOR_BUFFER_BIT ); + + + TestScreens(d); + + glShadeModel( GL_FLAT ); + + for (i = 0; i < 6; i++) { + redraw(d, screen_surf, i*10 ); + + printf("sleep(1)\n"); + sleep(1); + } + + eglDestroySurface(d, pbuffer); + eglDestroyContext(d, ctx); + eglTerminate(d); + + return 0; +} diff --git a/progs/egl/demo3.c b/progs/egl/demo3.c new file mode 100644 index 00000000000..9edf7c952b3 --- /dev/null +++ b/progs/egl/demo3.c @@ -0,0 +1,636 @@ +/* + * Exercise EGL API functions + */ + +#include +#include +#include +#include +#include + + + +#define PIXEL_CENTER(x) ((long)(x) + 0.5) + +#define GAP 10 +#define ROWS 3 +#define COLS 4 + +#define OPENGL_WIDTH 48 +#define OPENGL_HEIGHT 13 + + +GLenum rgb, doubleBuffer, windType; +GLint windW, windH; + +GLenum mode1, mode2; +GLint boxW, boxH; +GLubyte OpenGL_bits[] = { + 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, + 0x7f, 0xfb, 0xff, 0xff, 0xff, 0x01, + 0x7f, 0xfb, 0xff, 0xff, 0xff, 0x01, + 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, + 0x3e, 0x8f, 0xb7, 0xf9, 0xfc, 0x01, + 0x63, 0xdb, 0xb0, 0x8d, 0x0d, 0x00, + 0x63, 0xdb, 0xb7, 0x8d, 0x0d, 0x00, + 0x63, 0xdb, 0xb6, 0x8d, 0x0d, 0x00, + 0x63, 0x8f, 0xf3, 0xcc, 0x0d, 0x00, + 0x63, 0x00, 0x00, 0x0c, 0x4c, 0x0a, + 0x63, 0x00, 0x00, 0x0c, 0x4c, 0x0e, + 0x63, 0x00, 0x00, 0x8c, 0xed, 0x0e, + 0x3e, 0x00, 0x00, 0xf8, 0x0c, 0x00, +}; + + +static void Init(void) +{ + + mode1 = GL_TRUE; + mode2 = GL_TRUE; +} + +static void Reshape(int width, int height) +{ + + windW = (GLint)width; + windH = (GLint)height; +} + +#if 0 +static void RotateColorMask(void) +{ + static GLint rotation = 0; + + rotation = (rotation + 1) & 0x3; + switch (rotation) { + case 0: + glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); + glIndexMask( 0xff ); + break; + case 1: + glColorMask(GL_FALSE, GL_TRUE, GL_TRUE, GL_TRUE); + glIndexMask(0xFE); + break; + case 2: + glColorMask(GL_TRUE, GL_FALSE, GL_TRUE, GL_TRUE); + glIndexMask(0xFD); + break; + case 3: + glColorMask(GL_TRUE, GL_TRUE, GL_FALSE, GL_TRUE); + glIndexMask(0xFB); + break; + } +} +#endif + +static void Viewport(GLint row, GLint column) +{ + GLint x, y; + + boxW = (windW - (COLS + 1) * GAP) / COLS; + boxH = (windH - (ROWS + 1) * GAP) / ROWS; + + x = GAP + column * (boxW + GAP); + y = GAP + row * (boxH + GAP); + + glViewport(x, y, boxW, boxH); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-boxW/2, boxW/2, -boxH/2, boxH/2, 0.0, 1.0); + glMatrixMode(GL_MODELVIEW); + + glEnable(GL_SCISSOR_TEST); + glScissor(x, y, boxW, boxH); +} + +enum { + COLOR_BLACK = 0, + COLOR_RED, + COLOR_GREEN, + COLOR_YELLOW, + COLOR_BLUE, + COLOR_MAGENTA, + COLOR_CYAN, + COLOR_WHITE +}; + +static float RGBMap[9][3] = { + {0, 0, 0}, + {1, 0, 0}, + {0, 1, 0}, + {1, 1, 0}, + {0, 0, 1}, + {1, 0, 1}, + {0, 1, 1}, + {1, 1, 1}, + {0.5, 0.5, 0.5} +}; + +static void SetColor(int c) +{ + glColor3fv(RGBMap[c]); +} + +static void Point(void) +{ + GLint i; + + glBegin(GL_POINTS); + SetColor(COLOR_WHITE); + glVertex2i(0, 0); + for (i = 1; i < 8; i++) { + GLint j = i * 2; + SetColor(COLOR_BLACK+i); + glVertex2i(-j, -j); + glVertex2i(-j, 0); + glVertex2i(-j, j); + glVertex2i(0, j); + glVertex2i(j, j); + glVertex2i(j, 0); + glVertex2i(j, -j); + glVertex2i(0, -j); + } + glEnd(); +} + +static void Lines(void) +{ + GLint i; + + glPushMatrix(); + + glTranslatef(-12, 0, 0); + for (i = 1; i < 8; i++) { + SetColor(COLOR_BLACK+i); + glBegin(GL_LINES); + glVertex2i(-boxW/4, -boxH/4); + glVertex2i(boxW/4, boxH/4); + glEnd(); + glTranslatef(4, 0, 0); + } + + glPopMatrix(); + + glBegin(GL_LINES); + glVertex2i(0, 0); + glEnd(); +} + +static void LineStrip(void) +{ + + glBegin(GL_LINE_STRIP); + SetColor(COLOR_RED); + glVertex2f(PIXEL_CENTER(-boxW/4), PIXEL_CENTER(-boxH/4)); + SetColor(COLOR_GREEN); + glVertex2f(PIXEL_CENTER(-boxW/4), PIXEL_CENTER(boxH/4)); + SetColor(COLOR_BLUE); + glVertex2f(PIXEL_CENTER(boxW/4), PIXEL_CENTER(boxH/4)); + SetColor(COLOR_WHITE); + glVertex2f(PIXEL_CENTER(boxW/4), PIXEL_CENTER(-boxH/4)); + glEnd(); + + glBegin(GL_LINE_STRIP); + glVertex2i(0, 0); + glEnd(); +} + +static void LineLoop(void) +{ + + glBegin(GL_LINE_LOOP); + SetColor(COLOR_RED); + glVertex2f(PIXEL_CENTER(-boxW/4), PIXEL_CENTER(-boxH/4)); + SetColor(COLOR_GREEN); + glVertex2f(PIXEL_CENTER(-boxW/4), PIXEL_CENTER(boxH/4)); + SetColor(COLOR_BLUE); + glVertex2f(PIXEL_CENTER(boxW/4), PIXEL_CENTER(boxH/4)); + SetColor(COLOR_WHITE); + glVertex2f(PIXEL_CENTER(boxW/4), PIXEL_CENTER(-boxH/4)); + glEnd(); + + glEnable(GL_LOGIC_OP); + glLogicOp(GL_XOR); + + glEnable(GL_BLEND); + glBlendFunc(GL_ONE, GL_ONE); + + SetColor(COLOR_MAGENTA); + glBegin(GL_LINE_LOOP); + glVertex2f(PIXEL_CENTER(-boxW/8), PIXEL_CENTER(-boxH/8)); + glVertex2f(PIXEL_CENTER(-boxW/8), PIXEL_CENTER(boxH/8)); + glEnd(); + glBegin(GL_LINE_LOOP); + glVertex2f(PIXEL_CENTER(-boxW/8), PIXEL_CENTER(boxH/8+5)); + glVertex2f(PIXEL_CENTER(boxW/8), PIXEL_CENTER(boxH/8+5)); + glEnd(); + glDisable(GL_LOGIC_OP); + glDisable(GL_BLEND); + + SetColor(COLOR_GREEN); + glBegin(GL_POINTS); + glVertex2i(0, 0); + glEnd(); + + glBegin(GL_LINE_LOOP); + glVertex2i(0, 0); + glEnd(); +} + +static void Bitmap(void) +{ + + glBegin(GL_LINES); + SetColor(COLOR_GREEN); + glVertex2i(-boxW/2, 0); + glVertex2i(boxW/2, 0); + glVertex2i(0, -boxH/2); + glVertex2i(0, boxH/2); + SetColor(COLOR_RED); + glVertex2i(0, -3); + glVertex2i(0, -3+OPENGL_HEIGHT); + SetColor(COLOR_BLUE); + glVertex2i(0, -3); + glVertex2i(OPENGL_WIDTH, -3); + glEnd(); + + SetColor(COLOR_GREEN); + + glPixelStorei(GL_UNPACK_LSB_FIRST, GL_TRUE); + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + + glRasterPos2i(0, 0); + glBitmap(OPENGL_WIDTH, OPENGL_HEIGHT, 0, 3, 0.0, 0.0, OpenGL_bits); +} + +static void Triangles(void) +{ + + glBegin(GL_TRIANGLES); + SetColor(COLOR_GREEN); + glVertex2i(-boxW/4, -boxH/4); + SetColor(COLOR_RED); + glVertex2i(-boxW/8, -boxH/16); + SetColor(COLOR_BLUE); + glVertex2i(boxW/8, -boxH/16); + + SetColor(COLOR_GREEN); + glVertex2i(-boxW/4, boxH/4); + SetColor(COLOR_RED); + glVertex2i(-boxW/8, boxH/16); + SetColor(COLOR_BLUE); + glVertex2i(boxW/8, boxH/16); + glEnd(); + + glBegin(GL_TRIANGLES); + glVertex2i(0, 0); + glVertex2i(-100, 100); + glEnd(); +} + +static void TriangleStrip(void) +{ + + glBegin(GL_TRIANGLE_STRIP); + SetColor(COLOR_GREEN); + glVertex2i(-boxW/4, -boxH/4); + SetColor(COLOR_RED); + glVertex2i(-boxW/4, boxH/4); + SetColor(COLOR_BLUE); + glVertex2i(0, -boxH/4); + SetColor(COLOR_WHITE); + glVertex2i(0, boxH/4); + SetColor(COLOR_CYAN); + glVertex2i(boxW/4, -boxH/4); + SetColor(COLOR_YELLOW); + glVertex2i(boxW/4, boxH/4); + glEnd(); + + glBegin(GL_TRIANGLE_STRIP); + glVertex2i(0, 0); + glVertex2i(-100, 100); + glEnd(); +} + +static void TriangleFan(void) +{ + GLint vx[8][2]; + GLint x0, y0, x1, y1, x2, y2, x3, y3; + GLint i; + + y0 = -boxH/4; + y1 = y0 + boxH/2/3; + y2 = y1 + boxH/2/3; + y3 = boxH/4; + x0 = -boxW/4; + x1 = x0 + boxW/2/3; + x2 = x1 + boxW/2/3; + x3 = boxW/4; + + vx[0][0] = x0; vx[0][1] = y1; + vx[1][0] = x0; vx[1][1] = y2; + vx[2][0] = x1; vx[2][1] = y3; + vx[3][0] = x2; vx[3][1] = y3; + vx[4][0] = x3; vx[4][1] = y2; + vx[5][0] = x3; vx[5][1] = y1; + vx[6][0] = x2; vx[6][1] = y0; + vx[7][0] = x1; vx[7][1] = y0; + + glBegin(GL_TRIANGLE_FAN); + SetColor(COLOR_WHITE); + glVertex2i(0, 0); + for (i = 0; i < 8; i++) { + SetColor(COLOR_WHITE-i); + glVertex2iv(vx[i]); + } + glEnd(); + + glBegin(GL_TRIANGLE_FAN); + glVertex2i(0, 0); + glVertex2i(-100, 100); + glEnd(); +} + +static void Rect(void) +{ + + SetColor(COLOR_GREEN); + glRecti(-boxW/4, -boxH/4, boxW/4, boxH/4); +} + +static void PolygonFunc(void) +{ + GLint vx[8][2]; + GLint x0, y0, x1, y1, x2, y2, x3, y3; + GLint i; + + y0 = -boxH/4; + y1 = y0 + boxH/2/3; + y2 = y1 + boxH/2/3; + y3 = boxH/4; + x0 = -boxW/4; + x1 = x0 + boxW/2/3; + x2 = x1 + boxW/2/3; + x3 = boxW/4; + + vx[0][0] = x0; vx[0][1] = y1; + vx[1][0] = x0; vx[1][1] = y2; + vx[2][0] = x1; vx[2][1] = y3; + vx[3][0] = x2; vx[3][1] = y3; + vx[4][0] = x3; vx[4][1] = y2; + vx[5][0] = x3; vx[5][1] = y1; + vx[6][0] = x2; vx[6][1] = y0; + vx[7][0] = x1; vx[7][1] = y0; + + glBegin(GL_POLYGON); + for (i = 0; i < 8; i++) { + SetColor(COLOR_WHITE-i); + glVertex2iv(vx[i]); + } + glEnd(); + + glBegin(GL_POLYGON); + glVertex2i(0, 0); + glVertex2i(100, 100); + glEnd(); +} + +static void Quads(void) +{ + + glBegin(GL_QUADS); + SetColor(COLOR_GREEN); + glVertex2i(-boxW/4, -boxH/4); + SetColor(COLOR_RED); + glVertex2i(-boxW/8, -boxH/16); + SetColor(COLOR_BLUE); + glVertex2i(boxW/8, -boxH/16); + SetColor(COLOR_WHITE); + glVertex2i(boxW/4, -boxH/4); + + SetColor(COLOR_GREEN); + glVertex2i(-boxW/4, boxH/4); + SetColor(COLOR_RED); + glVertex2i(-boxW/8, boxH/16); + SetColor(COLOR_BLUE); + glVertex2i(boxW/8, boxH/16); + SetColor(COLOR_WHITE); + glVertex2i(boxW/4, boxH/4); + glEnd(); + + glBegin(GL_QUADS); + glVertex2i(0, 0); + glVertex2i(100, 100); + glVertex2i(-100, 100); + glEnd(); +} + +static void QuadStrip(void) +{ + + glBegin(GL_QUAD_STRIP); + SetColor(COLOR_GREEN); + glVertex2i(-boxW/4, -boxH/4); + SetColor(COLOR_RED); + glVertex2i(-boxW/4, boxH/4); + SetColor(COLOR_BLUE); + glVertex2i(0, -boxH/4); + SetColor(COLOR_WHITE); + glVertex2i(0, boxH/4); + SetColor(COLOR_CYAN); + glVertex2i(boxW/4, -boxH/4); + SetColor(COLOR_YELLOW); + glVertex2i(boxW/4, boxH/4); + glEnd(); + + glBegin(GL_QUAD_STRIP); + glVertex2i(0, 0); + glVertex2i(100, 100); + glVertex2i(-100, 100); + glEnd(); +} + +static void Draw(EGLDisplay dpy, EGLSurface surf) +{ + + glViewport(0, 0, windW, windH); + glDisable(GL_SCISSOR_TEST); + + glPushAttrib(GL_COLOR_BUFFER_BIT); + + glColorMask(1, 1, 1, 1); + glIndexMask(~0); + + glClearColor(0.0, 0.0, 0.0, 0.0); + glClear(GL_COLOR_BUFFER_BIT); + + glPopAttrib(); + + if (mode1) { + glShadeModel(GL_SMOOTH); + } else { + glShadeModel(GL_FLAT); + } + + if (mode2) { + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); + } else { + glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); + } + + Viewport(0, 0); Point(); + Viewport(0, 1); Lines(); + Viewport(0, 2); LineStrip(); + Viewport(0, 3); LineLoop(); + + Viewport(1, 0); Bitmap(); + + Viewport(1, 1); TriangleFan(); + Viewport(1, 2); Triangles(); + Viewport(1, 3); TriangleStrip(); + + Viewport(2, 0); Rect(); + Viewport(2, 1); PolygonFunc(); + Viewport(2, 2); Quads(); + Viewport(2, 3); QuadStrip(); + + glFlush(); + + if (doubleBuffer) { + eglSwapBuffers(dpy, surf); + } +} + +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=0; y--) { + for (x=0; xpFB, 1024, 768); + + eglDestroySurface(d, screen_surf); + eglDestroyContext(d, ctx); + eglTerminate(d); + + return 0; +} diff --git a/progs/egl/eglgears.c b/progs/egl/eglgears.c new file mode 100644 index 00000000000..9feee20d889 --- /dev/null +++ b/progs/egl/eglgears.c @@ -0,0 +1,475 @@ +/* + * Copyright (C) 1999-2001 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 port of the infamous "glxgears" demo to straight EGL + * Port by Dane Rushton 10 July 2005 + * + * No command line options. + * Program runs for 5 seconds then exits, outputing framerate to console + */ + +#include +#include +#include +#include +#include +#include +#include + +#define MAX_CONFIGS 10 +#define MAX_MODES 100 + +#define BENCHMARK + +#ifdef BENCHMARK + +/* XXX this probably isn't very portable */ + +#include +#include + +/* return current time (in seconds) */ +static double +current_time(void) +{ + struct timeval tv; +#ifdef __VMS + (void) gettimeofday(&tv, NULL ); +#else + struct timezone tz; + (void) gettimeofday(&tv, &tz); +#endif + return (double) tv.tv_sec + tv.tv_usec / 1000000.0; +} + +#else /*BENCHMARK*/ + +/* dummy */ +static double +current_time(void) +{ + /* update this function for other platforms! */ + static double t = 0.0; + static int warn = 1; + if (warn) { + fprintf(stderr, "Warning: current_time() not implemented!!\n"); + warn = 0; + } + return t += 1.0; +} + +#endif /*BENCHMARK*/ + + +#ifndef M_PI +#define M_PI 3.14159265 +#endif + + +static GLfloat view_rotx = 20.0, view_roty = 30.0, view_rotz = 0.0; +static GLint gear1, gear2, gear3; +static GLfloat angle = 0.0; + +#if 0 +static GLfloat eyesep = 5.0; /* Eye separation. */ +static GLfloat fix_point = 40.0; /* Fixation point distance. */ +static GLfloat left, right, asp; /* Stereo frustum params. */ +#endif + + +/* + * + * Draw a gear wheel. You'll probably want to call this function when + * building a display list since we do a lot of trig here. + * + * Input: inner_radius - radius of hole at center + * outer_radius - radius at center of teeth + * width - width of gear + * teeth - number of teeth + * tooth_depth - depth of tooth + */ +static void +gear(GLfloat inner_radius, GLfloat outer_radius, GLfloat width, + GLint teeth, GLfloat tooth_depth) +{ + GLint i; + GLfloat r0, r1, r2; + GLfloat angle, da; + GLfloat u, v, len; + + r0 = inner_radius; + r1 = outer_radius - tooth_depth / 2.0; + r2 = outer_radius + tooth_depth / 2.0; + + da = 2.0 * M_PI / teeth / 4.0; + + glShadeModel(GL_FLAT); + + glNormal3f(0.0, 0.0, 1.0); + + /* draw front face */ + glBegin(GL_QUAD_STRIP); + for (i = 0; i <= teeth; i++) { + angle = i * 2.0 * M_PI / teeth; + glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5); + glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5); + if (i < teeth) { + glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5); + glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), + width * 0.5); + } + } + glEnd(); + + /* draw front sides of teeth */ + glBegin(GL_QUADS); + da = 2.0 * M_PI / teeth / 4.0; + for (i = 0; i < teeth; i++) { + angle = i * 2.0 * M_PI / teeth; + + glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5); + glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), width * 0.5); + glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), + width * 0.5); + glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), + width * 0.5); + } + glEnd(); + + glNormal3f(0.0, 0.0, -1.0); + + /* draw back face */ + glBegin(GL_QUAD_STRIP); + for (i = 0; i <= teeth; i++) { + angle = i * 2.0 * M_PI / teeth; + glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5); + glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5); + if (i < teeth) { + glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), + -width * 0.5); + glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5); + } + } + glEnd(); + + /* draw back sides of teeth */ + glBegin(GL_QUADS); + da = 2.0 * M_PI / teeth / 4.0; + for (i = 0; i < teeth; i++) { + angle = i * 2.0 * M_PI / teeth; + + glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), + -width * 0.5); + glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), + -width * 0.5); + glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), -width * 0.5); + glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5); + } + glEnd(); + + /* draw outward faces of teeth */ + glBegin(GL_QUAD_STRIP); + for (i = 0; i < teeth; i++) { + angle = i * 2.0 * M_PI / teeth; + + glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5); + glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5); + u = r2 * cos(angle + da) - r1 * cos(angle); + v = r2 * sin(angle + da) - r1 * sin(angle); + len = sqrt(u * u + v * v); + u /= len; + v /= len; + glNormal3f(v, -u, 0.0); + glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), width * 0.5); + glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), -width * 0.5); + glNormal3f(cos(angle), sin(angle), 0.0); + glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), + width * 0.5); + glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), + -width * 0.5); + u = r1 * cos(angle + 3 * da) - r2 * cos(angle + 2 * da); + v = r1 * sin(angle + 3 * da) - r2 * sin(angle + 2 * da); + glNormal3f(v, -u, 0.0); + glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), + width * 0.5); + glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), + -width * 0.5); + glNormal3f(cos(angle), sin(angle), 0.0); + } + + glVertex3f(r1 * cos(0), r1 * sin(0), width * 0.5); + glVertex3f(r1 * cos(0), r1 * sin(0), -width * 0.5); + + glEnd(); + + glShadeModel(GL_SMOOTH); + + /* draw inside radius cylinder */ + glBegin(GL_QUAD_STRIP); + for (i = 0; i <= teeth; i++) { + angle = i * 2.0 * M_PI / teeth; + glNormal3f(-cos(angle), -sin(angle), 0.0); + glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5); + glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5); + } + glEnd(); +} + + +static void +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); + + 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, 4.2, 0.0); + glRotatef(-2.0 * angle - 25.0, 0.0, 0.0, 1.0); + glCallList(gear3); + glPopMatrix(); + + glPopMatrix(); +} + + +/* new window size or exposure */ +static void +reshape(int width, int height) +{ + glViewport(0, 0, (GLint) width, (GLint) height); + + GLfloat h = (GLfloat) height / (GLfloat) width; + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glFrustum(-1.0, 1.0, -h, h, 5.0, 60.0); + + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTranslatef(0.0, 0.0, -40.0); +} + + + +static void +init(void) +{ + 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); + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + glEnable(GL_DEPTH_TEST); + + /* make the gears */ + gear1 = glGenLists(1); + glNewList(gear1, GL_COMPILE); + glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, red); + gear(1.0, 4.0, 1.0, 20, 0.7); + glEndList(); + + gear2 = glGenLists(1); + glNewList(gear2, GL_COMPILE); + glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, green); + gear(0.5, 2.0, 2.0, 10, 0.7); + glEndList(); + + gear3 = glGenLists(1); + glNewList(gear3, GL_COMPILE); + glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, blue); + gear(1.3, 2.0, 0.5, 10, 0.7); + glEndList(); + + glEnable(GL_NORMALIZE); +} + + + + +static void run_gears(EGLDisplay dpy, EGLSurface surf, int ttr) +{ + double st = current_time(); + double ct = st; + int frames = 0; + while (ct - st < ttr) + { + double tt = current_time(); + double dt = tt - ct; + ct = tt; + + /* advance rotation for next frame */ + angle += 70.0 * dt; /* 70 degrees per second */ + if (angle > 3600.0) + angle -= 3600.0; + + draw(); + + eglSwapBuffers(dpy, surf); + + + frames++; + } + + GLfloat seconds = ct - st; + GLfloat fps = frames / seconds; + printf("%d frames in %3.1f seconds = %6.3f FPS\n", frames, seconds, fps); + +} + + +int +main(int argc, char *argv[]) +{ + int maj, min; + EGLContext ctx; + EGLSurface screen_surf; + EGLConfig configs[MAX_CONFIGS]; + EGLint numConfigs, i; + EGLBoolean b; + EGLDisplay d; + EGLint screenAttribs[10]; + EGLModeMESA mode[MAX_MODES]; + EGLScreenMESA screen; + EGLint count, chosenMode; + GLboolean printInfo = GL_FALSE; + EGLint width = 0, height = 0; + + /* parse cmd line args */ + for (i = 1; i < argc; i++) + { + if (strcmp(argv[i], "-info") == 0) + { + printInfo = GL_TRUE; + } + else + printf("Warning: unknown parameter: %s\n", argv[i]); + } + + /* DBR : Create EGL context/surface etc */ + d = eglGetDisplay(":0"); + assert(d); + + if (!eglInitialize(d, &maj, &min)) { + printf("eglgears: eglInitialize failed\n"); + exit(1); + } + + printf("eglgears: EGL version = %d.%d\n", maj, min); + printf("eglgears: EGL_VENDOR = %s\n", eglQueryString(d, EGL_VENDOR)); + + /* XXX use ChooseConfig */ + eglGetConfigs(d, configs, MAX_CONFIGS, &numConfigs); + eglGetScreensMESA(d, &screen, 1, &count); + + if (!eglGetModesMESA(d, screen, mode, MAX_MODES, &count) || count == 0) { + printf("eglgears: eglGetModesMESA failed!\n"); + return 0; + } + + /* Print list of modes, and find the one to use */ + printf("eglgears: Found %d modes:\n", count); + for (i = 0; i < count; i++) { + EGLint w, h; + eglGetModeAttribMESA(d, mode[i], EGL_WIDTH, &w); + eglGetModeAttribMESA(d, mode[i], EGL_HEIGHT, &h); + printf("%3d: %d x %d\n", i, w, h); + if (w > width && h > height && w <= 1280 && h <= 1024) { + width = w; + height = h; + chosenMode = i; + } + } + printf("eglgears: Using screen mode/size %d: %d x %d\n", chosenMode, width, height); + + ctx = eglCreateContext(d, configs[0], EGL_NO_CONTEXT, NULL); + if (ctx == EGL_NO_CONTEXT) { + printf("eglgears: failed to create context\n"); + return 0; + } + + /* build up screenAttribs array */ + i = 0; + screenAttribs[i++] = EGL_WIDTH; + screenAttribs[i++] = width; + screenAttribs[i++] = EGL_HEIGHT; + screenAttribs[i++] = height; + screenAttribs[i++] = EGL_NONE; + + screen_surf = eglCreateScreenSurfaceMESA(d, configs[0], screenAttribs); + if (screen_surf == EGL_NO_SURFACE) { + printf("eglgears: failed to create screen surface\n"); + return 0; + } + + b = eglShowScreenSurfaceMESA(d, screen, screen_surf, mode[chosenMode]); + if (!b) { + printf("eglgears: show surface failed\n"); + return 0; + } + + b = eglMakeCurrent(d, screen_surf, screen_surf, ctx); + if (!b) { + printf("eglgears: make current failed\n"); + return 0; + } + + if (printInfo) + { + 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)); + } + + init(); + reshape(width, height); + + glDrawBuffer( GL_BACK ); + + run_gears(d, screen_surf, 5.0); + + eglDestroySurface(d, screen_surf); + eglDestroyContext(d, ctx); + eglTerminate(d); + + return 0; +} diff --git a/progs/egl/eglinfo.c b/progs/egl/eglinfo.c new file mode 100644 index 00000000000..f9c24754457 --- /dev/null +++ b/progs/egl/eglinfo.c @@ -0,0 +1,166 @@ +/* + * eglinfo - like glxinfo but for EGL + * + * Brian Paul + * 11 March 2005 + * + * Copyright (C) 2005 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 +#include +#include +#include +#include + +#define MAX_CONFIGS 1000 +#define MAX_MODES 1000 +#define MAX_SCREENS 10 + + +/** + * Print table of all available configurations. + */ +static void +PrintConfigs(EGLDisplay d) +{ + EGLConfig configs[MAX_CONFIGS]; + EGLint numConfigs, i; + + eglGetConfigs(d, configs, MAX_CONFIGS, &numConfigs); + + printf("Configurations:\n"); + printf(" bf lv d st colorbuffer dp st supported\n"); + printf(" id sz l b ro r g b a th cl surfaces \n"); + printf("---------------------------------------------------\n"); + for (i = 0; i < numConfigs; i++) { + EGLint id, size, level; + EGLint red, green, blue, alpha; + EGLint depth, stencil; + EGLint surfaces; + EGLint doubleBuf = 1, stereo = 0; + char surfString[100] = ""; + + eglGetConfigAttrib(d, configs[i], EGL_CONFIG_ID, &id); + eglGetConfigAttrib(d, configs[i], EGL_BUFFER_SIZE, &size); + eglGetConfigAttrib(d, configs[i], EGL_LEVEL, &level); + + eglGetConfigAttrib(d, configs[i], EGL_RED_SIZE, &red); + eglGetConfigAttrib(d, configs[i], EGL_GREEN_SIZE, &green); + eglGetConfigAttrib(d, configs[i], EGL_BLUE_SIZE, &blue); + eglGetConfigAttrib(d, configs[i], EGL_ALPHA_SIZE, &alpha); + eglGetConfigAttrib(d, configs[i], EGL_DEPTH_SIZE, &depth); + eglGetConfigAttrib(d, configs[i], EGL_STENCIL_SIZE, &stencil); + eglGetConfigAttrib(d, configs[i], EGL_SURFACE_TYPE, &surfaces); + + if (surfaces & EGL_WINDOW_BIT) + strcat(surfString, "win,"); + if (surfaces & EGL_PBUFFER_BIT) + strcat(surfString, "pb,"); + if (surfaces & EGL_PIXMAP_BIT) + strcat(surfString, "pix,"); +#ifdef EGL_MESA_screen_surface + if (surfaces & EGL_SCREEN_BIT_MESA) + strcat(surfString, "scrn,"); +#endif + if (strlen(surfString) > 0) + surfString[strlen(surfString) - 1] = 0; + + printf("0x%02x %2d %2d %c %c %2d %2d %2d %2d %2d %2d %-12s\n", + id, size, level, + doubleBuf ? 'y' : '.', + stereo ? 'y' : '.', + red, green, blue, alpha, + depth, stencil, surfString); + } +} + + +/** + * Print table of all available configurations. + */ +static void +PrintModes(EGLDisplay d) +{ +#ifdef EGL_MESA_screen_surface + const char *extensions = eglQueryString(d, EGL_EXTENSIONS); + if (strstr(extensions, "EGL_MESA_screen_surface")) { + EGLScreenMESA screens[MAX_SCREENS]; + EGLint numScreens = 1, scrn; + EGLModeMESA modes[MAX_MODES]; + + eglGetScreensMESA(d, screens, MAX_SCREENS, &numScreens); + printf("Number of Screens: %d\n\n", numScreens); + + for (scrn = 0; scrn < numScreens; scrn++) { + EGLint numModes, i; + + eglGetModesMESA(d, screens[scrn], modes, MAX_MODES, &numModes); + + printf("Screen %d Modes:\n", scrn); + printf(" id width height refresh name\n"); + printf("-----------------------------------------\n"); + for (i = 0; i < numModes; i++) { + EGLint id, w, h, r; + const char *str; + eglGetModeAttribMESA(d, modes[i], EGL_MODE_ID_MESA, &id); + eglGetModeAttribMESA(d, modes[i], EGL_WIDTH, &w); + eglGetModeAttribMESA(d, modes[i], EGL_HEIGHT, &h); + eglGetModeAttribMESA(d, modes[i], EGL_REFRESH_RATE_MESA, &r); + str = eglQueryModeStringMESA(d, modes[i]); + printf("0x%02x %5d %5d %.3f %s\n", id, w, h, r / 1000.0, str); + } + } + } +#endif +} + + + +int +main(int argc, char *argv[]) +{ + int maj, min; + /*EGLDisplay d = eglGetDisplay(EGL_DEFAULT_DISPLAY);*/ + EGLDisplay d = eglGetDisplay(":0"); + + if (!eglInitialize(d, &maj, &min)) { + printf("eglinfo: eglInitialize failed\n"); + exit(1); + } + + printf("EGL API version: %d.%d\n", maj, min); + printf("EGL vendor string: %s\n", eglQueryString(d, EGL_VENDOR)); + printf("EGL version string: %s\n", eglQueryString(d, EGL_VERSION)); + printf("EGL extensions string:\n"); + printf(" %s\n", eglQueryString(d, EGL_EXTENSIONS)); + printf("\n"); + + PrintConfigs(d); + + printf("\n"); + + PrintModes(d); + + eglTerminate(d); + + return 0; +} diff --git a/progs/fbdev/Makefile b/progs/fbdev/Makefile new file mode 100644 index 00000000000..0a0c77906f7 --- /dev/null +++ b/progs/fbdev/Makefile @@ -0,0 +1,53 @@ +# Makefile for miniglx demo programs + +TOP = ../.. + +include $(TOP)/configs/current + + +SOURCES = glfbdevtest.c + +OBJECTS = $(SOURCES:.c=.o) + +PROGS = $(SOURCES:%.c=%) + +INCLUDES = \ + -I. \ + -I$(TOP)/include + + +##### RULES ##### + +.SUFFIXES: +.SUFFIXES: .c + +.c: + $(CC) $(INCLUDES) $(CFLAGS) $< $(APP_LIB_DEPS) -o $@ + +.c.o: + $(CC) -c $(INCLUDES) $(CFLAGS) $< -o $@ + +.S.o: + $(CC) -c $(INCLUDES) $(CFLAGS) $< -o $@ + + +##### TARGETS ##### + +default: depend $(PROGS) + +clean: + rm -f $(PROGS) + rm -f *.o + + +depend: $(SOURCES) + touch depend + $(MKDEP) $(MKDEP_OPTIONS) $(INCLUDES) $(SOURCES) > /dev/null + + +# Emacs tags +tags: + etags `find . -name \*.[ch]` `find ../include` + + +include depend diff --git a/progs/fbdev/glfbdevtest.c b/progs/fbdev/glfbdevtest.c new file mode 100644 index 00000000000..a461c55e2f8 --- /dev/null +++ b/progs/fbdev/glfbdevtest.c @@ -0,0 +1,524 @@ +/* + * Test the GLFBDev interface. Only tested with radeonfb driver!!!! + * + * Written by Brian Paul + */ + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define DEFAULT_DEPTH 8 + +static struct fb_fix_screeninfo FixedInfo; +static struct fb_var_screeninfo VarInfo, OrigVarInfo; +static int DesiredDepth = 0; +static int OriginalVT = -1; +static int ConsoleFD = -1; +static int FrameBufferFD = -1; +static caddr_t FrameBuffer = (caddr_t) -1; +static caddr_t MMIOAddress = (caddr_t) -1; + + +static void +print_fixed_info(const struct fb_fix_screeninfo *fixed, const char *s) +{ + static const char *visuals[] = { + "MONO01", "MONO10", "TRUECOLOR", "PSEUDOCOLOR", + "DIRECTCOLOR", "STATIC_PSEUDOCOLOR" + }; + + printf("%s info -----------------------\n", s); + printf("id = %16s\n", fixed->id); + printf("smem_start = 0x%lx\n", fixed->smem_start); + printf("smem_len = %d (0x%x)\n", fixed->smem_len, fixed->smem_len); + printf("type = 0x%x\n", fixed->type); + printf("type_aux = 0x%x\n", fixed->type_aux); + printf("visual = 0x%x (%s)\n", fixed->visual, visuals[fixed->visual]); + printf("xpanstep = %d\n", fixed->xpanstep); + printf("ypanstep = %d\n", fixed->ypanstep); + printf("ywrapstep = %d\n", fixed->ywrapstep); + printf("line_length = %d\n", fixed->line_length); + printf("mmio_start = 0x%lx\n", fixed->mmio_start); + printf("mmio_len = %d (0x%x)\n", fixed->mmio_len, fixed->mmio_len); + printf("accel = 0x%x\n", fixed->accel); +} + + +static void +print_var_info(const struct fb_var_screeninfo *var, const char *s) +{ + printf("%s info -----------------------\n", s); + printf("xres = %d\n", var->xres); + printf("yres = %d\n", var->yres); + printf("xres_virtual = %d\n", var->xres_virtual); + printf("yres_virtual = %d\n", var->yres_virtual); + printf("xoffset = %d\n", var->xoffset); + printf("yoffset = %d\n", var->yoffset); + printf("bits_per_pixel = %d\n", var->bits_per_pixel); + printf("grayscale = %d\n", var->grayscale); + + printf("red.offset = %d length = %d msb_right = %d\n", + var->red.offset, var->red.length, var->red.msb_right); + printf("green.offset = %d length = %d msb_right = %d\n", + var->green.offset, var->green.length, var->green.msb_right); + printf("blue.offset = %d length = %d msb_right = %d\n", + var->blue.offset, var->blue.length, var->blue.msb_right); + printf("transp.offset = %d length = %d msb_right = %d\n", + var->transp.offset, var->transp.length, var->transp.msb_right); + + printf("nonstd = %d\n", var->nonstd); + printf("activate = %d\n", var->activate); + printf("height = %d mm\n", var->height); + printf("width = %d mm\n", var->width); + printf("accel_flags = 0x%x\n", var->accel_flags); + printf("pixclock = %d\n", var->pixclock); + printf("left_margin = %d\n", var->left_margin); + printf("right_margin = %d\n", var->right_margin); + printf("upper_margin = %d\n", var->upper_margin); + printf("lower_margin = %d\n", var->lower_margin); + printf("hsync_len = %d\n", var->hsync_len); + printf("vsync_len = %d\n", var->vsync_len); + printf("sync = %d\n", var->sync); + printf("vmode = %d\n", var->vmode); +} + + +static void +signal_handler(int signumber) +{ + signal(signumber, SIG_IGN); /* prevent recursion! */ + fprintf(stderr, "error: got signal %d (exiting)\n", signumber); + exit(1); +} + + +static void +initialize_fbdev( void ) +{ + char ttystr[1000]; + int fd, vtnumber, ttyfd; + int sz; + + (void) sz; + + if (geteuid()) { + fprintf(stderr, "error: you need to be root\n"); + exit(1); + } + +#if 1 + /* open the framebuffer device */ + FrameBufferFD = open("/dev/fb0", O_RDWR); + if (FrameBufferFD < 0) { + fprintf(stderr, "Error opening /dev/fb0: %s\n", strerror(errno)); + exit(1); + } +#endif + + /* open /dev/tty0 and get the vt number */ + if ((fd = open("/dev/tty0", O_WRONLY, 0)) < 0) { + fprintf(stderr, "error opening /dev/tty0\n"); + exit(1); + } + if (ioctl(fd, VT_OPENQRY, &vtnumber) < 0 || vtnumber < 0) { + fprintf(stderr, "error: couldn't get a free vt\n"); + exit(1); + } + close(fd); + + /* open the console tty */ + sprintf(ttystr, "/dev/tty%d", vtnumber); /* /dev/tty1-64 */ + ConsoleFD = open(ttystr, O_RDWR | O_NDELAY, 0); + if (ConsoleFD < 0) { + fprintf(stderr, "error couldn't open console fd\n"); + exit(1); + } + + /* save current vt number */ + { + struct vt_stat vts; + if (ioctl(ConsoleFD, VT_GETSTATE, &vts) == 0) + OriginalVT = vts.v_active; + } + + /* disconnect from controlling tty */ + ttyfd = open("/dev/tty", O_RDWR); + if (ttyfd >= 0) { + ioctl(ttyfd, TIOCNOTTY, 0); + close(ttyfd); + } + + /* some magic to restore the vt when we exit */ + { + struct vt_mode vt; + if (ioctl(ConsoleFD, VT_ACTIVATE, vtnumber) != 0) + printf("ioctl VT_ACTIVATE: %s\n", strerror(errno)); + if (ioctl(ConsoleFD, VT_WAITACTIVE, vtnumber) != 0) + printf("ioctl VT_WAITACTIVE: %s\n", strerror(errno)); + + if (ioctl(ConsoleFD, VT_GETMODE, &vt) < 0) { + fprintf(stderr, "error: ioctl VT_GETMODE: %s\n", strerror(errno)); + exit(1); + } + + vt.mode = VT_PROCESS; + vt.relsig = SIGUSR1; + vt.acqsig = SIGUSR1; + if (ioctl(ConsoleFD, VT_SETMODE, &vt) < 0) { + fprintf(stderr, "error: ioctl(VT_SETMODE) failed: %s\n", + strerror(errno)); + exit(1); + } + } + + /* go into graphics mode */ + if (ioctl(ConsoleFD, KDSETMODE, KD_GRAPHICS) < 0) { + fprintf(stderr, "error: ioctl(KDSETMODE, KD_GRAPHICS) failed: %s\n", + strerror(errno)); + exit(1); + } + + +#if 0 + /* open the framebuffer device */ + FrameBufferFD = open("/dev/fb0", O_RDWR); + if (FrameBufferFD < 0) { + fprintf(stderr, "Error opening /dev/fb0: %s\n", strerror(errno)); + exit(1); + } +#endif + + /* Get the fixed screen info */ + if (ioctl(FrameBufferFD, FBIOGET_FSCREENINFO, &FixedInfo)) { + fprintf(stderr, "error: ioctl(FBIOGET_FSCREENINFO) failed: %s\n", + strerror(errno)); + exit(1); + } + + print_fixed_info(&FixedInfo, "Fixed"); + + + /* get the variable screen info */ + if (ioctl(FrameBufferFD, FBIOGET_VSCREENINFO, &OrigVarInfo)) { + fprintf(stderr, "error: ioctl(FBIOGET_VSCREENINFO) failed: %s\n", + strerror(errno)); + exit(1); + } + + print_var_info(&OrigVarInfo, "Orig Var"); + + /* operate on a copy */ + VarInfo = OrigVarInfo; + + /* set the depth, resolution, etc */ + DesiredDepth = 32; + if (DesiredDepth) + VarInfo.bits_per_pixel = DesiredDepth; + + if (VarInfo.bits_per_pixel == 16) { + VarInfo.red.offset = 11; + VarInfo.green.offset = 5; + VarInfo.blue.offset = 0; + VarInfo.red.length = 5; + VarInfo.green.length = 6; + VarInfo.blue.length = 5; + VarInfo.transp.offset = 0; + VarInfo.transp.length = 0; + } + else if (VarInfo.bits_per_pixel == 32) { + VarInfo.red.offset = 16; + VarInfo.green.offset = 8; + VarInfo.blue.offset = 0; + VarInfo.transp.offset = 24; + VarInfo.red.length = 8; + VarInfo.green.length = 8; + VarInfo.blue.length = 8; + VarInfo.transp.length = 8; + } + /* timing values taken from /etc/fb.modes (1280x1024 @ 75Hz) */ + VarInfo.xres_virtual = VarInfo.xres = 1280; + VarInfo.yres_virtual = VarInfo.yres = 1024; + VarInfo.pixclock = 7408; + VarInfo.left_margin = 248; + VarInfo.right_margin = 16; + VarInfo.upper_margin = 38; + VarInfo.lower_margin = 1; + VarInfo.hsync_len = 144; + VarInfo.vsync_len = 3; + + VarInfo.xoffset = 0; + VarInfo.yoffset = 0; + VarInfo.nonstd = 0; + VarInfo.vmode &= ~FB_VMODE_YWRAP; /* turn off scrolling */ + + /* set new variable screen info */ + if (ioctl(FrameBufferFD, FBIOPUT_VSCREENINFO, &VarInfo)) { + fprintf(stderr, "ioctl(FBIOPUT_VSCREENINFO failed): %s\n", + strerror(errno)); + exit(1); + } + + print_var_info(&VarInfo, "New Var"); + + if (FixedInfo.visual != FB_VISUAL_TRUECOLOR && + FixedInfo.visual != FB_VISUAL_DIRECTCOLOR) { + fprintf(stderr, "non-TRUE/DIRECT-COLOR visuals (0x%x) not supported by this demo.\n", FixedInfo.visual); + exit(1); + } + + /* initialize colormap */ + if (FixedInfo.visual == FB_VISUAL_DIRECTCOLOR) { + struct fb_cmap cmap; + unsigned short red[256], green[256], blue[256]; + int i; + + /* we're assuming 256 entries here */ + printf("initializing directcolor colormap\n"); + cmap.start = 0; + cmap.len = 256; + cmap.red = red; + cmap.green = green; + cmap.blue = blue; + cmap.transp = NULL; + for (i = 0; i < cmap.len; i++) { + red[i] = green[i] = blue[i] = (i << 8) | i; + } + if (ioctl(FrameBufferFD, FBIOPUTCMAP, (void *) &cmap) < 0) { + fprintf(stderr, "ioctl(FBIOPUTCMAP) failed [%d]\n", i); + } + } + + /* + * fbdev says the frame buffer is at offset zero, and the mmio region + * is immediately after. + */ + + /* mmap the framebuffer into our address space */ + FrameBuffer = (caddr_t) mmap(0, /* start */ + FixedInfo.smem_len, /* bytes */ + PROT_READ | PROT_WRITE, /* prot */ + MAP_SHARED, /* flags */ + FrameBufferFD, /* fd */ + 0 /* offset */); + if (FrameBuffer == (caddr_t) - 1) { + fprintf(stderr, "error: unable to mmap framebuffer: %s\n", + strerror(errno)); + exit(1); + } + printf("FrameBuffer = %p\n", FrameBuffer); + +#if 1 + /* mmap the MMIO region into our address space */ + MMIOAddress = (caddr_t) mmap(0, /* start */ + FixedInfo.mmio_len, /* bytes */ + PROT_READ | PROT_WRITE, /* prot */ + MAP_SHARED, /* flags */ + FrameBufferFD, /* fd */ + FixedInfo.smem_len /* offset */); + if (MMIOAddress == (caddr_t) - 1) { + fprintf(stderr, "error: unable to mmap mmio region: %s\n", + strerror(errno)); + } + printf("MMIOAddress = %p\n", MMIOAddress); + + /* try out some simple MMIO register reads */ + if (1) + { + typedef unsigned int CARD32; + typedef unsigned char CARD8; +#define RADEON_CONFIG_MEMSIZE 0x00f8 +#define RADEON_MEM_SDRAM_MODE_REG 0x0158 +#define MMIO_IN32(base, offset) \ + *(volatile CARD32 *)(void *)(((CARD8*)(base)) + (offset)) +#define INREG(addr) MMIO_IN32(MMIOAddress, addr) + int sz, type; + const char *typeStr[] = {"SDR", "DDR", "64-bit SDR"}; + sz = INREG(RADEON_CONFIG_MEMSIZE); + type = INREG(RADEON_MEM_SDRAM_MODE_REG); + printf("RADEON_CONFIG_MEMSIZE = %d (%d MB)\n", sz, sz / 1024 / 1024); + printf("RADEON_MEM_SDRAM_MODE_REG >> 30 = %d (%s)\n", + type >> 30, typeStr[type>>30]); + } +#endif + +} + + +static void +shutdown_fbdev( void ) +{ + struct vt_mode VT; + + printf("cleaning up...\n"); + /* restore original variable screen info */ + if (ioctl(FrameBufferFD, FBIOPUT_VSCREENINFO, &OrigVarInfo)) { + fprintf(stderr, "ioctl(FBIOPUT_VSCREENINFO failed): %s\n", + strerror(errno)); + exit(1); + } + + munmap(MMIOAddress, FixedInfo.mmio_len); + munmap(FrameBuffer, FixedInfo.smem_len); + close(FrameBufferFD); + + /* restore text mode */ + ioctl(ConsoleFD, KDSETMODE, KD_TEXT); + + /* set vt */ + if (ioctl(ConsoleFD, VT_GETMODE, &VT) != -1) { + VT.mode = VT_AUTO; + ioctl(ConsoleFD, VT_SETMODE, &VT); + } + + /* restore original vt */ + if (OriginalVT >= 0) { + ioctl(ConsoleFD, VT_ACTIVATE, OriginalVT); + OriginalVT = -1; + } + + close(ConsoleFD); +} + + +/* Borrowed from GLUT */ +static void +doughnut(GLfloat r, GLfloat R, GLint nsides, GLint rings) +{ + int i, j; + GLfloat theta, phi, theta1; + GLfloat cosTheta, sinTheta; + GLfloat cosTheta1, sinTheta1; + GLfloat ringDelta, sideDelta; + + ringDelta = 2.0 * M_PI / rings; + sideDelta = 2.0 * M_PI / nsides; + + theta = 0.0; + cosTheta = 1.0; + sinTheta = 0.0; + for (i = rings - 1; i >= 0; i--) { + theta1 = theta + ringDelta; + cosTheta1 = cos(theta1); + sinTheta1 = sin(theta1); + glBegin(GL_QUAD_STRIP); + phi = 0.0; + for (j = nsides; j >= 0; j--) { + GLfloat cosPhi, sinPhi, dist; + + phi += sideDelta; + cosPhi = cos(phi); + sinPhi = sin(phi); + dist = R + r * cosPhi; + + glNormal3f(cosTheta1 * cosPhi, -sinTheta1 * cosPhi, sinPhi); + glVertex3f(cosTheta1 * dist, -sinTheta1 * dist, r * sinPhi); + glNormal3f(cosTheta * cosPhi, -sinTheta * cosPhi, sinPhi); + glVertex3f(cosTheta * dist, -sinTheta * dist, r * sinPhi); + } + glEnd(); + theta = theta1; + cosTheta = cosTheta1; + sinTheta = sinTheta1; + } +} + + +static void +gltest( void ) +{ + static const int attribs[] = { + GLFBDEV_DOUBLE_BUFFER, + GLFBDEV_DEPTH_SIZE, 16, + GLFBDEV_NONE + }; + GLFBDevContextPtr ctx; + GLFBDevBufferPtr buf; + GLFBDevVisualPtr vis; + int bytes, r, g, b, a; + float ang; + + printf("GLFBDEV_VENDOR = %s\n", glFBDevGetString(GLFBDEV_VENDOR)); + printf("GLFBDEV_VERSION = %s\n", glFBDevGetString(GLFBDEV_VERSION)); + + /* framebuffer size */ + bytes = VarInfo.xres_virtual * VarInfo.yres_virtual * VarInfo.bits_per_pixel / 8; + + vis = glFBDevCreateVisual( &FixedInfo, &VarInfo, attribs ); + assert(vis); + + buf = glFBDevCreateBuffer( &FixedInfo, &VarInfo, vis, FrameBuffer, NULL, bytes ); + assert(buf); + + ctx = glFBDevCreateContext( vis, NULL ); + assert(buf); + + b = glFBDevMakeCurrent( ctx, buf, buf ); + assert(b); + + /*printf("GL_EXTENSIONS: %s\n", glGetString(GL_EXTENSIONS));*/ + glGetIntegerv(GL_RED_BITS, &r); + glGetIntegerv(GL_GREEN_BITS, &g); + glGetIntegerv(GL_BLUE_BITS, &b); + glGetIntegerv(GL_ALPHA_BITS, &a); + printf("RED_BITS=%d GREEN_BITS=%d BLUE_BITS=%d ALPHA_BITS=%d\n", + r, g, b, a); + + glClearColor(0.5, 0.5, 1.0, 0); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glFrustum(-1, 1, -1, 1, 2, 30); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTranslatef(0, 0, -15); + glViewport(0, 0, VarInfo.xres_virtual, VarInfo.yres_virtual); + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + glEnable(GL_DEPTH_TEST); + + for (ang = 0; ang <= 180; ang += 15) { + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glPushMatrix(); + glRotatef(ang, 1, 0, 0); + doughnut(1, 3, 40, 20); + glPopMatrix(); + glFBDevSwapBuffers(buf); + } + + /* clean up */ + b = glFBDevMakeCurrent( NULL, NULL, NULL); + assert(b); + + glFBDevDestroyContext(ctx); + glFBDevDestroyBuffer(buf); + glFBDevDestroyVisual(vis); +} + + +int +main( int argc, char *argv[] ) +{ + signal(SIGUSR1, signal_handler); /* exit if someone tries a vt switch */ + signal(SIGSEGV, signal_handler); /* catch segfaults */ + + initialize_fbdev(); + gltest(); + shutdown_fbdev(); + + return 0; +} diff --git a/progs/fp/Makefile b/progs/fp/Makefile new file mode 100644 index 00000000000..d461ebcc608 --- /dev/null +++ b/progs/fp/Makefile @@ -0,0 +1,127 @@ +# progs/tests/Makefile + + +# These programs aren't intended to be included with the normal distro. +# They're not too interesting but they're good for testing. + +TOP = ../.. +include $(TOP)/configs/current + + +LIBS = $(APP_LIB_DEPS) + +SOURCES = \ + tri-abs.c \ + tri-add.c \ + tri-cmp.c \ + tri-cos.c \ + tri-dp3.c \ + tri-dp4.c \ + tri-dph.c \ + tri-dst.c \ + tri-ex2.c \ + tri-flr.c \ + tri-frc.c \ + tri-kil.c \ + tri-lg2.c \ + tri-lit.c \ + tri-lrp.c \ + tri-mad.c \ + tri-max.c \ + tri-min.c \ + tri-mov.c \ + tri-mul.c \ + tri-pow.c \ + tri-param.c \ + tri-rcp.c \ + tri-rsq.c \ + tri-scs.c \ + tri-sge.c \ + tri-sge2.c \ + tri-sin.c \ + tri-slt.c \ + tri-sub.c \ + tri-swz.c \ + tri-swz2.c \ + tri-tex.c \ + tri-xpd.c \ + tri-position.c \ + tri-depth.c \ + tri-depth2.c \ + tri-depthwrite.c \ + tri-depthwrite2.c \ + +NOTDONE=\ + tri-txb.c \ + tri-txp.c \ + tri-depthwrite.c \ + tri-fogoption.c + + +PROGS = $(SOURCES:%.c=%) + +INCLUDES = -I. -I$(TOP)/include -I../samples + +UTIL_FILES = readtex.h readtex.c + + +##### RULES ##### + +.SUFFIXES: +.SUFFIXES: .c + +.c: + $(CC) $(INCLUDES) $(CFLAGS) $< $(LIBS) -o $@ + +.c.o: + $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ + +.S.o: + $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ + + +##### TARGETS ##### + +default: $(UTIL_FILES) $(PROGS) + +clean: + rm -f $(PROGS) + rm -f *.o + rm -f getproclist.h + + +# auto code generation +getprocaddress: getprocaddress.c getproclist.h + +getproclist.h: $(TOP)/src/mesa/glapi/gl_API.xml getprocaddress.c getprocaddress.py + python getprocaddress.py > getproclist.h + + +texrect: texrect.o readtex.o + $(CC) texrect.o readtex.o $(LIBS) -o $@ + +texrect.o: texrect.c readtex.h + $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ + +invert: invert.o readtex.o + $(CC) invert.o readtex.o $(LIBS) -o $@ + +invert.o: invert.c readtex.h + $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ + +readtex.o: readtex.c + $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ + + +readtex.h: $(TOP)/progs/util/readtex.h + ln -s $(TOP)/progs/util/readtex.h . + +readtex.c: $(TOP)/progs/util/readtex.c + ln -s $(TOP)/progs/util/readtex.c . + + + + +# Emacs tags +tags: + etags `find . -name \*.[ch]` `find ../include` diff --git a/progs/fp/tri-abs.c b/progs/fp/tri-abs.c new file mode 100644 index 00000000000..44aa2cfa3ad --- /dev/null +++ b/progs/fp/tri-abs.c @@ -0,0 +1,107 @@ + +#include +#include +#include +#define GL_GLEXT_PROTOTYPES +#include + + + +static void Init( void ) +{ + static const char *modulate2D = + "!!ARBfp1.0\n" + "TEMP R0;\n" + "SUB R0, {0.5}.x, fragment.color; \n" + "ABS result.color, R0; \n" + "END" + ; + GLuint modulateProg; + + if (!glutExtensionSupported("GL_ARB_fragment_program")) { + printf("Error: GL_ARB_fragment_program not supported!\n"); + exit(1); + } + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + /* Setup the fragment program */ + glGenProgramsARB(1, &modulateProg); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(modulate2D), (const GLubyte *)modulate2D); + + printf("glGetError = 0x%x\n", (int) glGetError()); + printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + + glEnable(GL_FRAGMENT_PROGRAM_ARB); + + glClearColor(.3, .3, .3, 0); +} + +static void Reshape(int width, int height) +{ + + glViewport(0, 0, (GLint)width, (GLint)height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0); + glMatrixMode(GL_MODELVIEW); +} + +static void Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,1); + glVertex3f( 0.9, -0.9, -30.0); + glColor3f(1,0,0); + glVertex3f( 0.9, 0.9, -30.0); + glColor3f(0,1,0); + glVertex3f(-0.9, 0.0, -30.0); + glEnd(); + + glFlush(); + +} + + + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB; + type |= GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/fp/tri-add.c b/progs/fp/tri-add.c new file mode 100644 index 00000000000..b086126c867 --- /dev/null +++ b/progs/fp/tri-add.c @@ -0,0 +1,110 @@ + +#include +#include +#include +#define GL_GLEXT_PROTOTYPES +#include + + + +static void Init( void ) +{ + static const char *modulate2D = + "!!ARBfp1.0\n" + "TEMP R0;\n" + "ADD R0, fragment.color, fragment.color; \n" + "ADD result.color, R0, R0; \n" + "END" + ; + GLuint modulateProg; + + if (!glutExtensionSupported("GL_ARB_fragment_program")) { + printf("Error: GL_ARB_fragment_program not supported!\n"); + exit(1); + } + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + /* Setup the fragment program */ + glGenProgramsARB(1, &modulateProg); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(modulate2D), (const GLubyte *)modulate2D); + + printf("glGetError = 0x%x\n", (int) glGetError()); + printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + + glEnable(GL_FRAGMENT_PROGRAM_ARB); + + glClearColor(.3, .3, .3, 0); +} + +static void Reshape(int width, int height) +{ + + glViewport(0, 0, (GLint)width, (GLint)height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0); + glMatrixMode(GL_MODELVIEW); +} + +static void Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,1); + glVertex3f( 0.9, -0.9, -30.0); + glColor3f(1,0,0); + glVertex3f( 0.9, 0.9, -30.0); + glColor3f(0,1,0); + glVertex3f(-0.9, 0.0, -30.0); + glEnd(); + + glFlush(); + + +} + + + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB; + type |= GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/fp/tri-cmp.c b/progs/fp/tri-cmp.c new file mode 100644 index 00000000000..968b67f3d91 --- /dev/null +++ b/progs/fp/tri-cmp.c @@ -0,0 +1,110 @@ + +#include +#include +#include +#define GL_GLEXT_PROTOTYPES +#include + + + +static void Init( void ) +{ + static const char *modulate2D = + "!!ARBfp1.0\n" + "TEMP R0;\n" + "SUB R0, {0.5}.x, fragment.color; \n" + "CMP result.color, R0, fragment.color, {0.0}.x; \n" + "END" + ; + GLuint modulateProg; + + if (!glutExtensionSupported("GL_ARB_fragment_program")) { + printf("Error: GL_ARB_fragment_program not supported!\n"); + exit(1); + } + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + /* Setup the fragment program */ + glGenProgramsARB(1, &modulateProg); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(modulate2D), (const GLubyte *)modulate2D); + + printf("glGetError = 0x%x\n", (int) glGetError()); + printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + + glEnable(GL_FRAGMENT_PROGRAM_ARB); + + glClearColor(.3, .3, .3, 0); +} + +static void Reshape(int width, int height) +{ + + glViewport(0, 0, (GLint)width, (GLint)height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0); + glMatrixMode(GL_MODELVIEW); +} + +static void Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,1); + glVertex3f( 0.9, -0.9, -30.0); + glColor3f(1,0,0); + glVertex3f( 0.9, 0.9, -30.0); + glColor3f(0,1,0); + glVertex3f(-0.9, 0.0, -30.0); + glEnd(); + + glFlush(); + + +} + + + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB; + type |= GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/fp/tri-cos.c b/progs/fp/tri-cos.c new file mode 100644 index 00000000000..7ea24532189 --- /dev/null +++ b/progs/fp/tri-cos.c @@ -0,0 +1,113 @@ + +#include +#include +#include +#define GL_GLEXT_PROTOTYPES +#include +#include "GL/gl.h" + + + +static void Init( void ) +{ + static const char *modulate2D = + "!!ARBfp1.0\n" + "TEMP R0; \n" + "MUL R0, fragment.color, {3.14}.x; \n" + "COS result.color.x, R0.x; \n" + "COS result.color.y, R0.y; \n" + "COS result.color.z, R0.z; \n" + "END" + ; + GLuint modulateProg; + + if (!glutExtensionSupported("GL_ARB_fragment_program")) { + printf("Error: GL_ARB_fragment_program not supported!\n"); + exit(1); + } + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + /* Setup the fragment program */ + glGenProgramsARB(1, &modulateProg); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(modulate2D), (const GLubyte *)modulate2D); + + printf("glGetError = 0x%x\n", (int) glGetError()); + printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + + glEnable(GL_FRAGMENT_PROGRAM_ARB); + + glClearColor(.3, .3, .3, 0); +} + +static void Reshape(int width, int height) +{ + + glViewport(0, 0, (GLint)width, (GLint)height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0); + glMatrixMode(GL_MODELVIEW); +} + +static void Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,1); + glVertex3f( 0.9, -0.9, -30.0); + glColor3f(1,0,0); + glVertex3f( 0.9, 0.9, -30.0); + glColor3f(0,1,0); + glVertex3f(-0.9, 0.0, -30.0); + glEnd(); + + glFlush(); + + +} + + + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB; + type |= GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/fp/tri-depth.c b/progs/fp/tri-depth.c new file mode 100644 index 00000000000..a1f0579c8e1 --- /dev/null +++ b/progs/fp/tri-depth.c @@ -0,0 +1,111 @@ + +#include +#include +#include +#define GL_GLEXT_PROTOTYPES +#include +#include "GL/gl.h" + + + +static void Init( void ) +{ + /* scale of 10.0 gives me a visible result on nv hardware. + */ + static const char *modulate2D = + "!!ARBfp1.0\n" + "MUL result.color, fragment.position.z, {10.0}.x; \n" + "END" + ; + GLuint modulateProg; + + if (!glutExtensionSupported("GL_ARB_fragment_program")) { + printf("Error: GL_ARB_fragment_program not supported!\n"); + exit(1); + } + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + /* Setup the fragment program */ + glGenProgramsARB(1, &modulateProg); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(modulate2D), (const GLubyte *)modulate2D); + + printf("glGetError = 0x%x\n", (int) glGetError()); + printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + + glEnable(GL_FRAGMENT_PROGRAM_ARB); + + glClearColor(.3, .3, .3, 0); +} + +static void Reshape(int width, int height) +{ + + glViewport(0, 0, (GLint)width, (GLint)height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0); + glMatrixMode(GL_MODELVIEW); +} + +static void Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,1); + glVertex3f( 0.9, -0.9, -40.0); + glColor3f(1,0,0); + glVertex3f( 0.9, 0.9, -40.0); + glColor3f(0,1,0); + glVertex3f(-0.9, 0.0, -25.0); + glEnd(); + + glFlush(); + + +} + + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + + + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB; + type |= GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/fp/tri-depth2.c b/progs/fp/tri-depth2.c new file mode 100644 index 00000000000..f3096282833 --- /dev/null +++ b/progs/fp/tri-depth2.c @@ -0,0 +1,116 @@ + +#include +#include +#include +#define GL_GLEXT_PROTOTYPES +#include +#include "GL/gl.h" + + + +static void Init( void ) +{ + /* scale of 10.0 gives me a visible result on nv hardware. + */ + static const char *modulate2D = + "!!ARBfp1.0\n" + "TEMP R0;\n" + "MUL R0, fragment.position.z, {10.0}.x;\n" + "MOV result.color, R0; \n" + "END" + ; + GLuint modulateProg; + + if (!glutExtensionSupported("GL_ARB_fragment_program")) { + printf("Error: GL_ARB_fragment_program not supported!\n"); + exit(1); + } + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + /* Setup the fragment program */ + glGenProgramsARB(1, &modulateProg); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(modulate2D), (const GLubyte *)modulate2D); + + printf("glGetError = 0x%x\n", (int) glGetError()); + printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + + glEnable(GL_FRAGMENT_PROGRAM_ARB); + + glClearColor(.3, .3, .3, 0); +} + +static void Reshape(int width, int height) +{ + + glViewport(0, 0, (GLint)width, (GLint)height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0); + glMatrixMode(GL_MODELVIEW); +} + +static void Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); + glEnable(GL_DEPTH_TEST); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,1); + glVertex3f( 0.9, -0.9, -30.0); + glVertex3f( 0.9, 0.9, -30.0); + glVertex3f(-0.9, 0.0, -30.0); + glColor3f(0,1,0); + glVertex3f(-0.9, -0.9, -40.0); + glVertex3f(-0.9, 0.9, -40.0); + glVertex3f( 0.9, 0.0, -25.0); + glEnd(); + + glFlush(); + + +} + + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + + + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB | GLUT_DEPTH; + type |= GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/fp/tri-depthwrite.c b/progs/fp/tri-depthwrite.c new file mode 100644 index 00000000000..fedeec4577d --- /dev/null +++ b/progs/fp/tri-depthwrite.c @@ -0,0 +1,107 @@ + +#include +#include +#include +#define GL_GLEXT_PROTOTYPES +#include + + +static void Init(void) +{ + static const char *modulate2D = + "!!ARBfp1.0\n" + "MUL result.depth.z, fragment.color.z, {.1}.x; \n" + "MOV result.color.xy, fragment.color; \n" + "END" + ; + GLuint modulateProg; + + if (!glutExtensionSupported("GL_ARB_fragment_program")) { + printf("Error: GL_ARB_fragment_program not supported!\n"); + exit(1); + } + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + /* Setup the fragment program */ + glGenProgramsARB(1, &modulateProg); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(modulate2D), (const GLubyte *)modulate2D); + + printf("glGetError = 0x%x\n", (int) glGetError()); + printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + + glEnable(GL_FRAGMENT_PROGRAM_ARB); + + glClearColor(.3, .3, .3, 0); +} + +static void Reshape(int width, int height) +{ + + glViewport(0, 0, (GLint)width, (GLint)height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0); + glMatrixMode(GL_MODELVIEW); +} + +static void Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); + glEnable(GL_DEPTH_TEST); + + + glBegin(GL_TRIANGLES); + glColor4f(.8,0,.5,0); + glVertex3f( 0.9, -0.9, -30.0); + glVertex3f( 0.9, 0.9, -30.0); + glVertex3f(-0.9, 0.0, -30.0); + + glColor4f(0,.8,.7,0); + glVertex3f(-0.9, -0.9, -40.0); + glColor4f(0,.8,.7,0); + glVertex3f(-0.9, 0.9, -40.0); + glColor4f(0,.8,.3,0); + glVertex3f( 0.9, 0.0, -40.0); + glEnd(); + + glFlush(); +} + + +int main(int argc, char **argv) +{ + glutInit(&argc, argv); + + glutInitWindowPosition(0, 0); glutInitWindowSize( 300, 300); + + glutInitDisplayMode(GLUT_DEPTH | GLUT_RGB | GLUT_SINGLE); + + if (glutCreateWindow("Depth Test") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/fp/tri-depthwrite2.c b/progs/fp/tri-depthwrite2.c new file mode 100644 index 00000000000..5547092ec9b --- /dev/null +++ b/progs/fp/tri-depthwrite2.c @@ -0,0 +1,107 @@ + +#include +#include +#include +#define GL_GLEXT_PROTOTYPES +#include + + +static void Init(void) +{ + static const char *modulate2D = + "!!ARBfp1.0\n" + "MUL result.depth.z, fragment.color.z, {.1}.x; \n" + "MOV result.color, fragment.color.z; \n" + "END" + ; + GLuint modulateProg; + + if (!glutExtensionSupported("GL_ARB_fragment_program")) { + printf("Error: GL_ARB_fragment_program not supported!\n"); + exit(1); + } + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + /* Setup the fragment program */ + glGenProgramsARB(1, &modulateProg); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(modulate2D), (const GLubyte *)modulate2D); + + printf("glGetError = 0x%x\n", (int) glGetError()); + printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + + glEnable(GL_FRAGMENT_PROGRAM_ARB); + + glClearColor(.3, .3, .3, 0); +} + +static void Reshape(int width, int height) +{ + + glViewport(0, 0, (GLint)width, (GLint)height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0); + glMatrixMode(GL_MODELVIEW); +} + +static void Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); + glEnable(GL_DEPTH_TEST); + + + glBegin(GL_TRIANGLES); + glColor4f(.8,0,.5,0); + glVertex3f( 0.9, -0.9, -30.0); + glVertex3f( 0.9, 0.9, -30.0); + glVertex3f(-0.9, 0.0, -30.0); + + glColor4f(0,.8,.7,0); + glVertex3f(-0.9, -0.9, -40.0); + glColor4f(0,.8,.7,0); + glVertex3f(-0.9, 0.9, -40.0); + glColor4f(0,.8,.3,0); + glVertex3f( 0.9, 0.0, -40.0); + glEnd(); + + glFlush(); +} + + +int main(int argc, char **argv) +{ + glutInit(&argc, argv); + + glutInitWindowPosition(0, 0); glutInitWindowSize( 300, 300); + + glutInitDisplayMode(GLUT_DEPTH | GLUT_RGB | GLUT_SINGLE); + + if (glutCreateWindow("Depth Test") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/fp/tri-dp3.c b/progs/fp/tri-dp3.c new file mode 100644 index 00000000000..0e18de2dc46 --- /dev/null +++ b/progs/fp/tri-dp3.c @@ -0,0 +1,109 @@ + +#include +#include +#include +#define GL_GLEXT_PROTOTYPES +#include + + + +static void Init( void ) +{ + static const char *modulate2D = + "!!ARBfp1.0\n" + "TEMP R0;\n" + "DP3 result.color, fragment.color, fragment.color; \n" + "END" + ; + GLuint modulateProg; + + if (!glutExtensionSupported("GL_ARB_fragment_program")) { + printf("Error: GL_ARB_fragment_program not supported!\n"); + exit(1); + } + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + /* Setup the fragment program */ + glGenProgramsARB(1, &modulateProg); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(modulate2D), (const GLubyte *)modulate2D); + + printf("glGetError = 0x%x\n", (int) glGetError()); + printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + + glEnable(GL_FRAGMENT_PROGRAM_ARB); + + glClearColor(.3, .3, .3, 0); +} + +static void Reshape(int width, int height) +{ + + glViewport(0, 0, (GLint)width, (GLint)height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0); + glMatrixMode(GL_MODELVIEW); +} + +static void Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,1); + glVertex3f( 0.9, -0.9, -30.0); + glColor3f(1,0,0); + glVertex3f( 0.9, 0.9, -30.0); + glColor3f(0,1,0); + glVertex3f(-0.9, 0.0, -30.0); + glEnd(); + + glFlush(); + + +} + + + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB; + type |= GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/fp/tri-dp4.c b/progs/fp/tri-dp4.c new file mode 100644 index 00000000000..400bbf4da2d --- /dev/null +++ b/progs/fp/tri-dp4.c @@ -0,0 +1,109 @@ + +#include +#include +#include +#define GL_GLEXT_PROTOTYPES +#include + + + +static void Init( void ) +{ + static const char *modulate2D = + "!!ARBfp1.0\n" + "TEMP R0;\n" + "DP4 result.color, fragment.color.xxxx, fragment.color; \n" + "END" + ; + GLuint modulateProg; + + if (!glutExtensionSupported("GL_ARB_fragment_program")) { + printf("Error: GL_ARB_fragment_program not supported!\n"); + exit(1); + } + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + /* Setup the fragment program */ + glGenProgramsARB(1, &modulateProg); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(modulate2D), (const GLubyte *)modulate2D); + + printf("glGetError = 0x%x\n", (int) glGetError()); + printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + + glEnable(GL_FRAGMENT_PROGRAM_ARB); + + glClearColor(.3, .3, .3, 0); +} + +static void Reshape(int width, int height) +{ + + glViewport(0, 0, (GLint)width, (GLint)height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0); + glMatrixMode(GL_MODELVIEW); +} + +static void Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,1); + glVertex3f( 0.9, -0.9, -30.0); + glColor3f(1,0,0); + glVertex3f( 0.9, 0.9, -30.0); + glColor3f(0,1,0); + glVertex3f(-0.9, 0.0, -30.0); + glEnd(); + + glFlush(); + + +} + + + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB; + type |= GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/fp/tri-dph.c b/progs/fp/tri-dph.c new file mode 100644 index 00000000000..958073c4131 --- /dev/null +++ b/progs/fp/tri-dph.c @@ -0,0 +1,109 @@ + +#include +#include +#include +#define GL_GLEXT_PROTOTYPES +#include + + + +static void Init( void ) +{ + static const char *modulate2D = + "!!ARBfp1.0\n" + "TEMP R0;\n" + "DPH result.color, fragment.color, fragment.color.xyzx; \n" + "END" + ; + GLuint modulateProg; + + if (!glutExtensionSupported("GL_ARB_fragment_program")) { + printf("Error: GL_ARB_fragment_program not supported!\n"); + exit(1); + } + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + /* Setup the fragment program */ + glGenProgramsARB(1, &modulateProg); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(modulate2D), (const GLubyte *)modulate2D); + + printf("glGetError = 0x%x\n", (int) glGetError()); + printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + + glEnable(GL_FRAGMENT_PROGRAM_ARB); + + glClearColor(.3, .3, .3, 0); +} + +static void Reshape(int width, int height) +{ + + glViewport(0, 0, (GLint)width, (GLint)height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0); + glMatrixMode(GL_MODELVIEW); +} + +static void Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,1); + glVertex3f( 0.9, -0.9, -30.0); + glColor3f(1,0,0); + glVertex3f( 0.9, 0.9, -30.0); + glColor3f(0,1,0); + glVertex3f(-0.9, 0.0, -30.0); + glEnd(); + + glFlush(); + + +} + + + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB; + type |= GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/fp/tri-dst.c b/progs/fp/tri-dst.c new file mode 100644 index 00000000000..3d85e85643c --- /dev/null +++ b/progs/fp/tri-dst.c @@ -0,0 +1,109 @@ + +#include +#include +#include +#define GL_GLEXT_PROTOTYPES +#include +#include "GL/gl.h" + + + +static void Init( void ) +{ + static const char *modulate2D = + "!!ARBfp1.0\n" + "DST result.color, fragment.color, fragment.color; \n" + "END" + ; + GLuint modulateProg; + + if (!glutExtensionSupported("GL_ARB_fragment_program")) { + printf("Error: GL_ARB_fragment_program not supported!\n"); + exit(1); + } + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + /* Setup the fragment program */ + glGenProgramsARB(1, &modulateProg); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(modulate2D), (const GLubyte *)modulate2D); + + printf("glGetError = 0x%x\n", (int) glGetError()); + printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + + glEnable(GL_FRAGMENT_PROGRAM_ARB); + + glClearColor(.3, .3, .3, 0); +} + +static void Reshape(int width, int height) +{ + + glViewport(0, 0, (GLint)width, (GLint)height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0); + glMatrixMode(GL_MODELVIEW); +} + +static void Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,1); + glVertex3f( 0.9, -0.9, -30.0); + glColor3f(1,0,0); + glVertex3f( 0.9, 0.9, -30.0); + glColor3f(0,1,0); + glVertex3f(-0.9, 0.0, -30.0); + glEnd(); + + glFlush(); + + +} + + + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB; + type |= GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/fp/tri-ex2.c b/progs/fp/tri-ex2.c new file mode 100644 index 00000000000..f09b1d78469 --- /dev/null +++ b/progs/fp/tri-ex2.c @@ -0,0 +1,110 @@ + +#include +#include +#include +#define GL_GLEXT_PROTOTYPES +#include + + + +static void Init( void ) +{ + static const char *modulate2D = + "!!ARBfp1.0\n" + "TEMP R0;\n" + "EX2 R0, fragment.color.x; \n" + "SUB result.color, R0, {1.0}.x; \n" + "END" + ; + GLuint modulateProg; + + if (!glutExtensionSupported("GL_ARB_fragment_program")) { + printf("Error: GL_ARB_fragment_program not supported!\n"); + exit(1); + } + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + /* Setup the fragment program */ + glGenProgramsARB(1, &modulateProg); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(modulate2D), (const GLubyte *)modulate2D); + + printf("glGetError = 0x%x\n", (int) glGetError()); + printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + + glEnable(GL_FRAGMENT_PROGRAM_ARB); + + glClearColor(.3, .3, .3, 0); +} + +static void Reshape(int width, int height) +{ + + glViewport(0, 0, (GLint)width, (GLint)height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0); + glMatrixMode(GL_MODELVIEW); +} + +static void Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,1); + glVertex3f( 0.9, -0.9, -30.0); + glColor3f(1,0,0); + glVertex3f( 0.9, 0.9, -30.0); + glColor3f(0,1,0); + glVertex3f(-0.9, 0.0, -30.0); + glEnd(); + + glFlush(); + + +} + + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + + + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB; + type |= GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/fp/tri-flr.c b/progs/fp/tri-flr.c new file mode 100644 index 00000000000..059f6b67541 --- /dev/null +++ b/progs/fp/tri-flr.c @@ -0,0 +1,110 @@ + +#include +#include +#include +#define GL_GLEXT_PROTOTYPES +#include + + + +static void Init( void ) +{ + static const char *modulate2D = + "!!ARBfp1.0\n" + "TEMP R0;\n" + "ADD R0, fragment.color, {0.5}.x; \n" + "FLR result.color, R0; \n" + "END" + ; + GLuint modulateProg; + + if (!glutExtensionSupported("GL_ARB_fragment_program")) { + printf("Error: GL_ARB_fragment_program not supported!\n"); + exit(1); + } + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + /* Setup the fragment program */ + glGenProgramsARB(1, &modulateProg); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(modulate2D), (const GLubyte *)modulate2D); + + printf("glGetError = 0x%x\n", (int) glGetError()); + printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + + glEnable(GL_FRAGMENT_PROGRAM_ARB); + + glClearColor(.3, .3, .3, 0); +} + +static void Reshape(int width, int height) +{ + + glViewport(0, 0, (GLint)width, (GLint)height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0); + glMatrixMode(GL_MODELVIEW); +} + +static void Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,1); + glVertex3f( 0.9, -0.9, -30.0); + glColor3f(1,0,0); + glVertex3f( 0.9, 0.9, -30.0); + glColor3f(0,1,0); + glVertex3f(-0.9, 0.0, -30.0); + glEnd(); + + glFlush(); + + +} + + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + + + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB; + type |= GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/fp/tri-fp.c b/progs/fp/tri-fp.c new file mode 100644 index 00000000000..4148a8def34 --- /dev/null +++ b/progs/fp/tri-fp.c @@ -0,0 +1,109 @@ + +#include +#include +#include +#define GL_GLEXT_PROTOTYPES +#include +#include "GL/gl.h" + + + +static void Init( void ) +{ + static const char *modulate2D = + "!!ARBfp1.0\n" + "SLT result.color, {0.5}.x, fragment.color; \n" + "END" + ; + GLuint modulateProg; + + if (!glutExtensionSupported("GL_ARB_fragment_program")) { + printf("Error: GL_ARB_fragment_program not supported!\n"); + exit(1); + } + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + /* Setup the fragment program */ + glGenProgramsARB(1, &modulateProg); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(modulate2D), (const GLubyte *)modulate2D); + + printf("glGetError = 0x%x\n", (int) glGetError()); + printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + + glEnable(GL_FRAGMENT_PROGRAM_ARB); + + glClearColor(.3, .3, .3, 0); +} + +static void Reshape(int width, int height) +{ + + glViewport(0, 0, (GLint)width, (GLint)height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0); + glMatrixMode(GL_MODELVIEW); +} + +static void Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,1); + glVertex3f( 0.9, -0.9, -30.0); + glColor3f(1,0,0); + glVertex3f( 0.9, 0.9, -30.0); + glColor3f(0,1,0); + glVertex3f(-0.9, 0.0, -30.0); + glEnd(); + + glFlush(); + + +} + + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + + + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB; + type |= GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/fp/tri-frc.c b/progs/fp/tri-frc.c new file mode 100644 index 00000000000..8d60c9dc201 --- /dev/null +++ b/progs/fp/tri-frc.c @@ -0,0 +1,111 @@ + +#include +#include +#include +#define GL_GLEXT_PROTOTYPES +#include +#include "GL/gl.h" + + + +static void Init( void ) +{ + static const char *modulate2D = + "!!ARBfp1.0\n" + "TEMP R0; \n" + "MUL R0, fragment.color, {3.0}.x; \n" + "FRC result.color, R0; \n" + "END" + ; + GLuint modulateProg; + + if (!glutExtensionSupported("GL_ARB_fragment_program")) { + printf("Error: GL_ARB_fragment_program not supported!\n"); + exit(1); + } + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + /* Setup the fragment program */ + glGenProgramsARB(1, &modulateProg); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(modulate2D), (const GLubyte *)modulate2D); + + printf("glGetError = 0x%x\n", (int) glGetError()); + printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + + glEnable(GL_FRAGMENT_PROGRAM_ARB); + + glClearColor(.3, .3, .3, 0); +} + +static void Reshape(int width, int height) +{ + + glViewport(0, 0, (GLint)width, (GLint)height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0); + glMatrixMode(GL_MODELVIEW); +} + +static void Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,1); + glVertex3f( 0.9, -0.9, -30.0); + glColor3f(1,0,0); + glVertex3f( 0.9, 0.9, -30.0); + glColor3f(0,1,0); + glVertex3f(-0.9, 0.0, -30.0); + glEnd(); + + glFlush(); + + +} + + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + + + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB; + type |= GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/fp/tri-inv.c b/progs/fp/tri-inv.c new file mode 100644 index 00000000000..e9023323862 --- /dev/null +++ b/progs/fp/tri-inv.c @@ -0,0 +1,109 @@ + +#include +#include +#include +#define GL_GLEXT_PROTOTYPES +#include + + + +static void Init( void ) +{ + static const char *modulate2D = + "!!ARBfp1.0\n" + "TEMP R0;\n" + "INV result.color, fragment.color; \n" + "END" + ; + GLuint modulateProg; + + if (!glutExtensionSupported("GL_ARB_fragment_program")) { + printf("Error: GL_ARB_fragment_program not supported!\n"); + exit(1); + } + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + /* Setup the fragment program */ + glGenProgramsARB(1, &modulateProg); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(modulate2D), (const GLubyte *)modulate2D); + + printf("glGetError = 0x%x\n", (int) glGetError()); + printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + + glEnable(GL_FRAGMENT_PROGRAM_ARB); + + glClearColor(.3, .3, .3, 0); +} + +static void Reshape(int width, int height) +{ + + glViewport(0, 0, (GLint)width, (GLint)height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0); + glMatrixMode(GL_MODELVIEW); +} + +static void Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,1); + glVertex3f( 0.9, -0.9, -30.0); + glColor3f(1,0,0); + glVertex3f( 0.9, 0.9, -30.0); + glColor3f(0,1,0); + glVertex3f(-0.9, 0.0, -30.0); + glEnd(); + + glFlush(); + + +} + + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + + + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB; + type |= GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/fp/tri-kil.c b/progs/fp/tri-kil.c new file mode 100644 index 00000000000..47dbd049644 --- /dev/null +++ b/progs/fp/tri-kil.c @@ -0,0 +1,111 @@ + +#include +#include +#include +#define GL_GLEXT_PROTOTYPES +#include + + + +static void Init( void ) +{ + static const char *modulate2D = + "!!ARBfp1.0\n" + "TEMP R0;\n" + "SUB R0, fragment.color, {0.5,0,0,0}; \n" + "KIL R0;" + "MOV result.color, R0;" + "END" + ; + GLuint modulateProg; + + if (!glutExtensionSupported("GL_ARB_fragment_program")) { + printf("Error: GL_ARB_fragment_program not supported!\n"); + exit(1); + } + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + /* Setup the fragment program */ + glGenProgramsARB(1, &modulateProg); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(modulate2D), (const GLubyte *)modulate2D); + + printf("glGetError = 0x%x\n", (int) glGetError()); + printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + + glEnable(GL_FRAGMENT_PROGRAM_ARB); + + glClearColor(.3, .3, .3, 0); +} + +static void Reshape(int width, int height) +{ + + glViewport(0, 0, (GLint)width, (GLint)height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0); + glMatrixMode(GL_MODELVIEW); +} + +static void Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,1); + glVertex3f( 0.9, -0.9, -30.0); + glColor3f(1,0,0); + glVertex3f( 0.9, 0.9, -30.0); + glColor3f(0,1,0); + glVertex3f(-0.9, 0.0, -30.0); + glEnd(); + + glFlush(); + + +} + + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + + + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB; + type |= GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/fp/tri-lg2.c b/progs/fp/tri-lg2.c new file mode 100644 index 00000000000..c7eec469741 --- /dev/null +++ b/progs/fp/tri-lg2.c @@ -0,0 +1,110 @@ + +#include +#include +#include +#define GL_GLEXT_PROTOTYPES +#include + + + +static void Init( void ) +{ + static const char *modulate2D = + "!!ARBfp1.0\n" + "TEMP R0;\n" + "MUL R0, fragment.color, {4.0}.x; \n" + "LG2 result.color, R0.x; \n" + "END" + ; + GLuint modulateProg; + + if (!glutExtensionSupported("GL_ARB_fragment_program")) { + printf("Error: GL_ARB_fragment_program not supported!\n"); + exit(1); + } + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + /* Setup the fragment program */ + glGenProgramsARB(1, &modulateProg); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(modulate2D), (const GLubyte *)modulate2D); + + printf("glGetError = 0x%x\n", (int) glGetError()); + printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + + glEnable(GL_FRAGMENT_PROGRAM_ARB); + + glClearColor(.3, .3, .3, 0); +} + +static void Reshape(int width, int height) +{ + + glViewport(0, 0, (GLint)width, (GLint)height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0); + glMatrixMode(GL_MODELVIEW); +} + +static void Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,1); + glVertex3f( 0.9, -0.9, -30.0); + glColor3f(1,0,0); + glVertex3f( 0.9, 0.9, -30.0); + glColor3f(0,1,0); + glVertex3f(-0.9, 0.0, -30.0); + glEnd(); + + glFlush(); + + +} + + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + + + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB; + type |= GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/fp/tri-lit.c b/progs/fp/tri-lit.c new file mode 100644 index 00000000000..21e3b6f2169 --- /dev/null +++ b/progs/fp/tri-lit.c @@ -0,0 +1,111 @@ + +#include +#include +#include +#define GL_GLEXT_PROTOTYPES +#include +#include "GL/gl.h" + + + +static void Init( void ) +{ + static const char *modulate2D = + "!!ARBfp1.0\n" + "TEMP R0;\n" + "SUB R0, {0.5}.x, fragment.color; \n" + "LIT result.color, R0; \n" + "END" + ; + GLuint modulateProg; + + if (!glutExtensionSupported("GL_ARB_fragment_program")) { + printf("Error: GL_ARB_fragment_program not supported!\n"); + exit(1); + } + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + /* Setup the fragment program */ + glGenProgramsARB(1, &modulateProg); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(modulate2D), (const GLubyte *)modulate2D); + + printf("glGetError = 0x%x\n", (int) glGetError()); + printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + + glEnable(GL_FRAGMENT_PROGRAM_ARB); + + glClearColor(.3, .3, .3, 0); +} + +static void Reshape(int width, int height) +{ + + glViewport(0, 0, (GLint)width, (GLint)height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0); + glMatrixMode(GL_MODELVIEW); +} + +static void Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,1); + glVertex3f( 0.9, -0.9, -30.0); + glColor3f(1,0,0); + glVertex3f( 0.9, 0.9, -30.0); + glColor3f(0,1,0); + glVertex3f(-0.9, 0.0, -30.0); + glEnd(); + + glFlush(); + + +} + + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + + + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB; + type |= GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/fp/tri-lrp.c b/progs/fp/tri-lrp.c new file mode 100644 index 00000000000..a5659eed60d --- /dev/null +++ b/progs/fp/tri-lrp.c @@ -0,0 +1,109 @@ + +#include +#include +#include +#define GL_GLEXT_PROTOTYPES +#include + + + +static void Init( void ) +{ + static const char *modulate2D = + "!!ARBfp1.0\n" + "TEMP R0, R1;\n" + "LRP result.color, fragment.color.z, {1,0,0,1}, {0,1,0,1}; \n" + "END" + ; + GLuint modulateProg; + + if (!glutExtensionSupported("GL_ARB_fragment_program")) { + printf("Error: GL_ARB_fragment_program not supported!\n"); + exit(1); + } + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + /* Setup the fragment program */ + glGenProgramsARB(1, &modulateProg); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(modulate2D), (const GLubyte *)modulate2D); + + printf("glGetError = 0x%x\n", (int) glGetError()); + printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + + glEnable(GL_FRAGMENT_PROGRAM_ARB); + + glClearColor(.3, .3, .3, 0); +} + +static void Reshape(int width, int height) +{ + + glViewport(0, 0, (GLint)width, (GLint)height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0); + glMatrixMode(GL_MODELVIEW); +} + +static void Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,1); + glVertex3f( 0.9, -0.9, -30.0); + glColor3f(1,0,0); + glVertex3f( 0.9, 0.9, -30.0); + glColor3f(0,1,0); + glVertex3f(-0.9, 0.0, -30.0); + glEnd(); + + glFlush(); + + +} + + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + + + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB; + type |= GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/fp/tri-mad.c b/progs/fp/tri-mad.c new file mode 100644 index 00000000000..b46d139fb3c --- /dev/null +++ b/progs/fp/tri-mad.c @@ -0,0 +1,109 @@ + +#include +#include +#include +#define GL_GLEXT_PROTOTYPES +#include + + + +static void Init( void ) +{ + static const char *modulate2D = + "!!ARBfp1.0\n" + "TEMP R0, R1;\n" + "MAD result.color, fragment.color.z, {1,0,0,1}, fragment.color; \n" + "END" + ; + GLuint modulateProg; + + if (!glutExtensionSupported("GL_ARB_fragment_program")) { + printf("Error: GL_ARB_fragment_program not supported!\n"); + exit(1); + } + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + /* Setup the fragment program */ + glGenProgramsARB(1, &modulateProg); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(modulate2D), (const GLubyte *)modulate2D); + + printf("glGetError = 0x%x\n", (int) glGetError()); + printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + + glEnable(GL_FRAGMENT_PROGRAM_ARB); + + glClearColor(.3, .3, .3, 0); +} + +static void Reshape(int width, int height) +{ + + glViewport(0, 0, (GLint)width, (GLint)height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0); + glMatrixMode(GL_MODELVIEW); +} + +static void Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,1); + glVertex3f( 0.9, -0.9, -30.0); + glColor3f(1,0,0); + glVertex3f( 0.9, 0.9, -30.0); + glColor3f(0,1,0); + glVertex3f(-0.9, 0.0, -30.0); + glEnd(); + + glFlush(); + + +} + + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + + + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB; + type |= GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/fp/tri-max.c b/progs/fp/tri-max.c new file mode 100644 index 00000000000..481a0679165 --- /dev/null +++ b/progs/fp/tri-max.c @@ -0,0 +1,109 @@ + +#include +#include +#include +#define GL_GLEXT_PROTOTYPES +#include +#include "GL/gl.h" + + + +static void Init( void ) +{ + static const char *modulate2D = + "!!ARBfp1.0\n" + "MAX result.color, {0.5}.x, fragment.color; \n" + "END" + ; + GLuint modulateProg; + + if (!glutExtensionSupported("GL_ARB_fragment_program")) { + printf("Error: GL_ARB_fragment_program not supported!\n"); + exit(1); + } + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + /* Setup the fragment program */ + glGenProgramsARB(1, &modulateProg); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(modulate2D), (const GLubyte *)modulate2D); + + printf("glGetError = 0x%x\n", (int) glGetError()); + printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + + glEnable(GL_FRAGMENT_PROGRAM_ARB); + + glClearColor(.3, .3, .3, 0); +} + +static void Reshape(int width, int height) +{ + + glViewport(0, 0, (GLint)width, (GLint)height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0); + glMatrixMode(GL_MODELVIEW); +} + +static void Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,1); + glVertex3f( 0.9, -0.9, -30.0); + glColor3f(1,0,0); + glVertex3f( 0.9, 0.9, -30.0); + glColor3f(0,1,0); + glVertex3f(-0.9, 0.0, -30.0); + glEnd(); + + glFlush(); + + +} + + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + + + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB; + type |= GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/fp/tri-min.c b/progs/fp/tri-min.c new file mode 100644 index 00000000000..7bb722f85ff --- /dev/null +++ b/progs/fp/tri-min.c @@ -0,0 +1,109 @@ + +#include +#include +#include +#define GL_GLEXT_PROTOTYPES +#include +#include "GL/gl.h" + + + +static void Init( void ) +{ + static const char *modulate2D = + "!!ARBfp1.0\n" + "MIN result.color, {0.5}.x, fragment.color; \n" + "END" + ; + GLuint modulateProg; + + if (!glutExtensionSupported("GL_ARB_fragment_program")) { + printf("Error: GL_ARB_fragment_program not supported!\n"); + exit(1); + } + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + /* Setup the fragment program */ + glGenProgramsARB(1, &modulateProg); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(modulate2D), (const GLubyte *)modulate2D); + + printf("glGetError = 0x%x\n", (int) glGetError()); + printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + + glEnable(GL_FRAGMENT_PROGRAM_ARB); + + glClearColor(.3, .3, .3, 0); +} + +static void Reshape(int width, int height) +{ + + glViewport(0, 0, (GLint)width, (GLint)height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0); + glMatrixMode(GL_MODELVIEW); +} + +static void Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,1); + glVertex3f( 0.9, -0.9, -30.0); + glColor3f(1,0,0); + glVertex3f( 0.9, 0.9, -30.0); + glColor3f(0,1,0); + glVertex3f(-0.9, 0.0, -30.0); + glEnd(); + + glFlush(); + + +} + + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + + + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB; + type |= GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/fp/tri-mov.c b/progs/fp/tri-mov.c new file mode 100644 index 00000000000..40b5b66f5cc --- /dev/null +++ b/progs/fp/tri-mov.c @@ -0,0 +1,102 @@ + +#include +#include +#include +#define GL_GLEXT_PROTOTYPES +#include +#include "GL/gl.h" + +static void Init( void ) +{ + static const char *modulate2D = + "!!ARBfp1.0\n" + "MOV result.color, fragment.color; \n" + "END" + ; + GLuint modulateProg; + + if (!glutExtensionSupported("GL_ARB_fragment_program")) { + printf("Error: GL_ARB_fragment_program not supported!\n"); + exit(1); + } + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + /* Setup the fragment program */ + glGenProgramsARB(1, &modulateProg); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(modulate2D), (const GLubyte *)modulate2D); + + printf("glGetError = 0x%x\n", (int) glGetError()); + printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + + glEnable(GL_FRAGMENT_PROGRAM_ARB); + + glClearColor(.3, .3, .3, 0); +} + +static void Reshape(int width, int height) +{ + + glViewport(0, 0, (GLint)width, (GLint)height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0); + glMatrixMode(GL_MODELVIEW); +} + +static void Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,1); + glVertex3f( 0.9, -0.9, -30.0); + glColor3f(1,0,0); + glVertex3f( 0.9, 0.9, -30.0); + glColor3f(0,1,0); + glVertex3f(-0.9, 0.0, -30.0); + glEnd(); + + glFlush(); +} + + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB | GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/fp/tri-mul.c b/progs/fp/tri-mul.c new file mode 100644 index 00000000000..61dd3e0458c --- /dev/null +++ b/progs/fp/tri-mul.c @@ -0,0 +1,109 @@ + +#include +#include +#include +#define GL_GLEXT_PROTOTYPES +#include +#include "GL/gl.h" + + + +static void Init( void ) +{ + static const char *modulate2D = + "!!ARBfp1.0\n" + "MUL result.color, fragment.color, fragment.color; \n" + "END" + ; + GLuint modulateProg; + + if (!glutExtensionSupported("GL_ARB_fragment_program")) { + printf("Error: GL_ARB_fragment_program not supported!\n"); + exit(1); + } + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + /* Setup the fragment program */ + glGenProgramsARB(1, &modulateProg); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(modulate2D), (const GLubyte *)modulate2D); + + printf("glGetError = 0x%x\n", (int) glGetError()); + printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + + glEnable(GL_FRAGMENT_PROGRAM_ARB); + + glClearColor(.3, .3, .3, 0); +} + +static void Reshape(int width, int height) +{ + + glViewport(0, 0, (GLint)width, (GLint)height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0); + glMatrixMode(GL_MODELVIEW); +} + +static void Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,1); + glVertex3f( 0.9, -0.9, -30.0); + glColor3f(1,0,0); + glVertex3f( 0.9, 0.9, -30.0); + glColor3f(0,1,0); + glVertex3f(-0.9, 0.0, -30.0); + glEnd(); + + glFlush(); + + +} + + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + + + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB; + type |= GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/fp/tri-param.c b/progs/fp/tri-param.c new file mode 100644 index 00000000000..f3e55af3f1b --- /dev/null +++ b/progs/fp/tri-param.c @@ -0,0 +1,114 @@ + +#include +#include +#include +#define GL_GLEXT_PROTOTYPES +#include +#include "GL/gl.h" + +static void Init( void ) +{ + static const char *modulate2D = + "!!ARBfp1.0\n" + "MOV result.color, program.local[32]; \n" + "END" + ; + GLuint modulateProg; + + if (!glutExtensionSupported("GL_ARB_fragment_program")) { + printf("Error: GL_ARB_fragment_program not supported!\n"); + exit(1); + } + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + /* Setup the fragment program */ + glGenProgramsARB(1, &modulateProg); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(modulate2D), (const GLubyte *)modulate2D); + + printf("glGetError = 0x%x\n", (int) glGetError()); + printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + + glEnable(GL_FRAGMENT_PROGRAM_ARB); + + glClearColor(.3, .3, .3, 0); +} + +static void Reshape(int width, int height) +{ + + glViewport(0, 0, (GLint)width, (GLint)height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0); + glMatrixMode(GL_MODELVIEW); +} + +static void Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + glProgramLocalParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, 32, 0.25, .5, 0.25, 1); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,1); + glVertex3f( 0.9, -0.9, -30.0); + glColor3f(1,0,0); + glVertex3f( 0.9, 0.0, -30.0); + glColor3f(0,1,0); + glVertex3f(-0.9, 0.0, -30.0); + glEnd(); + + glProgramLocalParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, 32, 0.25, 0, 0.25, 1); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,1); + glVertex3f( 0.9, 0.0, -30.0); + glColor3f(1,0,0); + glVertex3f( 0.9, 0.9, -30.0); + glColor3f(0,1,0); + glVertex3f(-0.9, 0.0, -30.0); + glEnd(); + + glFlush(); +} + + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB | GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/fp/tri-position.c b/progs/fp/tri-position.c new file mode 100644 index 00000000000..18e8182a684 --- /dev/null +++ b/progs/fp/tri-position.c @@ -0,0 +1,109 @@ + +#include +#include +#include +#define GL_GLEXT_PROTOTYPES +#include +#include "GL/gl.h" + + + +static void Init( void ) +{ + static const char *modulate2D = + "!!ARBfp1.0\n" + "MUL result.color, fragment.position, {.005}.x; \n" + "END" + ; + GLuint modulateProg; + + if (!glutExtensionSupported("GL_ARB_fragment_program")) { + printf("Error: GL_ARB_fragment_program not supported!\n"); + exit(1); + } + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + /* Setup the fragment program */ + glGenProgramsARB(1, &modulateProg); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(modulate2D), (const GLubyte *)modulate2D); + + printf("glGetError = 0x%x\n", (int) glGetError()); + printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + + glEnable(GL_FRAGMENT_PROGRAM_ARB); + + glClearColor(.3, .3, .3, 0); +} + +static void Reshape(int width, int height) +{ + + glViewport(0, 0, (GLint)width, (GLint)height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0); + glMatrixMode(GL_MODELVIEW); +} + +static void Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,1); + glVertex3f( 0.9, -0.9, -30.0); + glColor3f(1,0,0); + glVertex3f( 0.9, 0.9, -30.0); + glColor3f(0,1,0); + glVertex3f(-0.9, 0.0, -30.0); + glEnd(); + + glFlush(); + + +} + + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + + + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB; + type |= GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/fp/tri-pow.c b/progs/fp/tri-pow.c new file mode 100644 index 00000000000..ef91e43e997 --- /dev/null +++ b/progs/fp/tri-pow.c @@ -0,0 +1,109 @@ + +#include +#include +#include +#define GL_GLEXT_PROTOTYPES +#include + + + +static void Init( void ) +{ + static const char *modulate2D = + "!!ARBfp1.0\n" + "TEMP R0;\n" + "POW result.color, fragment.color.x, fragment.color.y; \n" + "END" + ; + GLuint modulateProg; + + if (!glutExtensionSupported("GL_ARB_fragment_program")) { + printf("Error: GL_ARB_fragment_program not supported!\n"); + exit(1); + } + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + /* Setup the fragment program */ + glGenProgramsARB(1, &modulateProg); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(modulate2D), (const GLubyte *)modulate2D); + + printf("glGetError = 0x%x\n", (int) glGetError()); + printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + + glEnable(GL_FRAGMENT_PROGRAM_ARB); + + glClearColor(.3, .3, .3, 0); +} + +static void Reshape(int width, int height) +{ + + glViewport(0, 0, (GLint)width, (GLint)height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0); + glMatrixMode(GL_MODELVIEW); +} + +static void Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,1); + glVertex3f( 0.9, -0.9, -30.0); + glColor3f(1,0,0); + glVertex3f( 0.9, 0.9, -30.0); + glColor3f(0,1,0); + glVertex3f(-0.9, 0.0, -30.0); + glEnd(); + + glFlush(); + + +} + + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + + + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB; + type |= GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/fp/tri-rcp.c b/progs/fp/tri-rcp.c new file mode 100644 index 00000000000..e2a27049343 --- /dev/null +++ b/progs/fp/tri-rcp.c @@ -0,0 +1,110 @@ + +#include +#include +#include +#define GL_GLEXT_PROTOTYPES +#include + + + +static void Init( void ) +{ + static const char *modulate2D = + "!!ARBfp1.0\n" + "TEMP R0;\n" + "ADD R0, fragment.color.x, fragment.color.x; \n" + "RCP result.color, R0.x; \n" + "END" + ; + GLuint modulateProg; + + if (!glutExtensionSupported("GL_ARB_fragment_program")) { + printf("Error: GL_ARB_fragment_program not supported!\n"); + exit(1); + } + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + /* Setup the fragment program */ + glGenProgramsARB(1, &modulateProg); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(modulate2D), (const GLubyte *)modulate2D); + + printf("glGetError = 0x%x\n", (int) glGetError()); + printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + + glEnable(GL_FRAGMENT_PROGRAM_ARB); + + glClearColor(.3, .3, .3, 0); +} + +static void Reshape(int width, int height) +{ + + glViewport(0, 0, (GLint)width, (GLint)height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0); + glMatrixMode(GL_MODELVIEW); +} + +static void Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,1); + glVertex3f( 0.9, -0.9, -30.0); + glColor3f(1,0,0); + glVertex3f( 0.9, 0.9, -30.0); + glColor3f(0,1,0); + glVertex3f(-0.9, 0.0, -30.0); + glEnd(); + + glFlush(); + + +} + + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + + + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB; + type |= GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/fp/tri-rsq.c b/progs/fp/tri-rsq.c new file mode 100644 index 00000000000..c5b2c1b32e8 --- /dev/null +++ b/progs/fp/tri-rsq.c @@ -0,0 +1,110 @@ + +#include +#include +#include +#define GL_GLEXT_PROTOTYPES +#include + + + +static void Init( void ) +{ + static const char *modulate2D = + "!!ARBfp1.0\n" + "TEMP R0;\n" + "MUL R0, fragment.color, {3.0}.x; \n" + "RSQ result.color, R0.x; \n" + "END" + ; + GLuint modulateProg; + + if (!glutExtensionSupported("GL_ARB_fragment_program")) { + printf("Error: GL_ARB_fragment_program not supported!\n"); + exit(1); + } + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + /* Setup the fragment program */ + glGenProgramsARB(1, &modulateProg); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(modulate2D), (const GLubyte *)modulate2D); + + printf("glGetError = 0x%x\n", (int) glGetError()); + printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + + glEnable(GL_FRAGMENT_PROGRAM_ARB); + + glClearColor(.3, .3, .3, 0); +} + +static void Reshape(int width, int height) +{ + + glViewport(0, 0, (GLint)width, (GLint)height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0); + glMatrixMode(GL_MODELVIEW); +} + +static void Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,1); + glVertex3f( 0.9, -0.9, -30.0); + glColor3f(1,0,0); + glVertex3f( 0.9, 0.9, -30.0); + glColor3f(0,1,0); + glVertex3f(-0.9, 0.0, -30.0); + glEnd(); + + glFlush(); + + +} + + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + + + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB; + type |= GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/fp/tri-scs.c b/progs/fp/tri-scs.c new file mode 100644 index 00000000000..ce7c0062c33 --- /dev/null +++ b/progs/fp/tri-scs.c @@ -0,0 +1,111 @@ + +#include +#include +#include +#define GL_GLEXT_PROTOTYPES +#include +#include "GL/gl.h" + + + +static void Init( void ) +{ + static const char *modulate2D = + "!!ARBfp1.0\n" + "TEMP R0; \n" + "MUL R0, fragment.color, {3.14}.x; \n" + "SCS result.color, R0.x; \n" + "END" + ; + GLuint modulateProg; + + if (!glutExtensionSupported("GL_ARB_fragment_program")) { + printf("Error: GL_ARB_fragment_program not supported!\n"); + exit(1); + } + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + /* Setup the fragment program */ + glGenProgramsARB(1, &modulateProg); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(modulate2D), (const GLubyte *)modulate2D); + + printf("glGetError = 0x%x\n", (int) glGetError()); + printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + + glEnable(GL_FRAGMENT_PROGRAM_ARB); + + glClearColor(.3, .3, .3, 0); +} + +static void Reshape(int width, int height) +{ + + glViewport(0, 0, (GLint)width, (GLint)height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0); + glMatrixMode(GL_MODELVIEW); +} + +static void Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,1); + glVertex3f( 0.9, -0.9, -30.0); + glColor3f(1,0,0); + glVertex3f( 0.9, 0.9, -30.0); + glColor3f(0,1,0); + glVertex3f(-0.9, 0.0, -30.0); + glEnd(); + + glFlush(); + + +} + + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + + + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB; + type |= GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/fp/tri-sge.c b/progs/fp/tri-sge.c new file mode 100644 index 00000000000..6a360ca9328 --- /dev/null +++ b/progs/fp/tri-sge.c @@ -0,0 +1,109 @@ + +#include +#include +#include +#define GL_GLEXT_PROTOTYPES +#include +#include "GL/gl.h" + + + +static void Init( void ) +{ + static const char *modulate2D = + "!!ARBfp1.0\n" + "SGE result.color, {0.5}.x, fragment.color; \n" + "END" + ; + GLuint modulateProg; + + if (!glutExtensionSupported("GL_ARB_fragment_program")) { + printf("Error: GL_ARB_fragment_program not supported!\n"); + exit(1); + } + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + /* Setup the fragment program */ + glGenProgramsARB(1, &modulateProg); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(modulate2D), (const GLubyte *)modulate2D); + + printf("glGetError = 0x%x\n", (int) glGetError()); + printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + + glEnable(GL_FRAGMENT_PROGRAM_ARB); + + glClearColor(.3, .3, .3, 0); +} + +static void Reshape(int width, int height) +{ + + glViewport(0, 0, (GLint)width, (GLint)height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0); + glMatrixMode(GL_MODELVIEW); +} + +static void Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,1); + glVertex3f( 0.9, -0.9, -30.0); + glColor3f(1,0,0); + glVertex3f( 0.9, 0.9, -30.0); + glColor3f(0,1,0); + glVertex3f(-0.9, 0.0, -30.0); + glEnd(); + + glFlush(); + + +} + + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + + + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB; + type |= GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/fp/tri-sge2.c b/progs/fp/tri-sge2.c new file mode 100644 index 00000000000..c4330098ed4 --- /dev/null +++ b/progs/fp/tri-sge2.c @@ -0,0 +1,114 @@ + +#include +#include +#include +#define GL_GLEXT_PROTOTYPES +#include +#include "GL/gl.h" + + + +static void Init( void ) +{ + static const char *modulate2D = + "!!ARBfp1.0\n" + "TEMP R0;\n" + "TEMP R1;\n" + "SGE R0, fragment.color, fragment.color.yzxw; \n" + "SGE R1, fragment.color, fragment.color.zxyw; \n" + "MUL R0, R0, R1; \n" + "MUL result.color, R0, fragment.color; \n" + "END" + ; + GLuint modulateProg; + + if (!glutExtensionSupported("GL_ARB_fragment_program")) { + printf("Error: GL_ARB_fragment_program not supported!\n"); + exit(1); + } + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + /* Setup the fragment program */ + glGenProgramsARB(1, &modulateProg); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(modulate2D), (const GLubyte *)modulate2D); + + printf("glGetError = 0x%x\n", (int) glGetError()); + printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + + glEnable(GL_FRAGMENT_PROGRAM_ARB); + + glClearColor(.3, .3, .3, 0); +} + +static void Reshape(int width, int height) +{ + + glViewport(0, 0, (GLint)width, (GLint)height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0); + glMatrixMode(GL_MODELVIEW); +} + +static void Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,1); + glVertex3f( 0.9, -0.9, -30.0); + glColor3f(1,0,0); + glVertex3f( 0.9, 0.9, -30.0); + glColor3f(0,1,0); + glVertex3f(-0.9, 0.0, -30.0); + glEnd(); + + glFlush(); + + +} + + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + + + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB; + type |= GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/fp/tri-sin.c b/progs/fp/tri-sin.c new file mode 100644 index 00000000000..772903e4b23 --- /dev/null +++ b/progs/fp/tri-sin.c @@ -0,0 +1,114 @@ + +#include +#include +#include +#define GL_GLEXT_PROTOTYPES +#include +#include "GL/gl.h" + + + +static void Init( void ) +{ + static const char *modulate2D = + "!!ARBfp1.0\n" + "TEMP R0; \n" + "MUL R0, fragment.color, {3.14}.x; \n" + "MOV result.color, {0.0}.x; \n" + "SIN result.color.x, R0.x; \n" + "SIN result.color.y, R0.y; \n" + "SIN result.color.z, R0.z; \n" + "END" + ; + GLuint modulateProg; + + if (!glutExtensionSupported("GL_ARB_fragment_program")) { + printf("Error: GL_ARB_fragment_program not supported!\n"); + exit(1); + } + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + /* Setup the fragment program */ + glGenProgramsARB(1, &modulateProg); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(modulate2D), (const GLubyte *)modulate2D); + + printf("glGetError = 0x%x\n", (int) glGetError()); + printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + + glEnable(GL_FRAGMENT_PROGRAM_ARB); + + glClearColor(.3, .3, .3, 0); +} + +static void Reshape(int width, int height) +{ + + glViewport(0, 0, (GLint)width, (GLint)height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0); + glMatrixMode(GL_MODELVIEW); +} + +static void Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,1); + glVertex3f( 0.9, -0.9, -30.0); + glColor3f(1,0,0); + glVertex3f( 0.9, 0.9, -30.0); + glColor3f(0,1,0); + glVertex3f(-0.9, 0.0, -30.0); + glEnd(); + + glFlush(); + + +} + + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + + + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB; + type |= GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/fp/tri-slt.c b/progs/fp/tri-slt.c new file mode 100644 index 00000000000..4148a8def34 --- /dev/null +++ b/progs/fp/tri-slt.c @@ -0,0 +1,109 @@ + +#include +#include +#include +#define GL_GLEXT_PROTOTYPES +#include +#include "GL/gl.h" + + + +static void Init( void ) +{ + static const char *modulate2D = + "!!ARBfp1.0\n" + "SLT result.color, {0.5}.x, fragment.color; \n" + "END" + ; + GLuint modulateProg; + + if (!glutExtensionSupported("GL_ARB_fragment_program")) { + printf("Error: GL_ARB_fragment_program not supported!\n"); + exit(1); + } + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + /* Setup the fragment program */ + glGenProgramsARB(1, &modulateProg); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(modulate2D), (const GLubyte *)modulate2D); + + printf("glGetError = 0x%x\n", (int) glGetError()); + printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + + glEnable(GL_FRAGMENT_PROGRAM_ARB); + + glClearColor(.3, .3, .3, 0); +} + +static void Reshape(int width, int height) +{ + + glViewport(0, 0, (GLint)width, (GLint)height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0); + glMatrixMode(GL_MODELVIEW); +} + +static void Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,1); + glVertex3f( 0.9, -0.9, -30.0); + glColor3f(1,0,0); + glVertex3f( 0.9, 0.9, -30.0); + glColor3f(0,1,0); + glVertex3f(-0.9, 0.0, -30.0); + glEnd(); + + glFlush(); + + +} + + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + + + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB; + type |= GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/fp/tri-sub.c b/progs/fp/tri-sub.c new file mode 100644 index 00000000000..6faa4145501 --- /dev/null +++ b/progs/fp/tri-sub.c @@ -0,0 +1,109 @@ + +#include +#include +#include +#define GL_GLEXT_PROTOTYPES +#include +#include "GL/gl.h" + + + +static void Init( void ) +{ + static const char *modulate2D = + "!!ARBfp1.0\n" + "SUB result.color, fragment.color.yzxw, fragment.color; \n" + "END" + ; + GLuint modulateProg; + + if (!glutExtensionSupported("GL_ARB_fragment_program")) { + printf("Error: GL_ARB_fragment_program not supported!\n"); + exit(1); + } + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + /* Setup the fragment program */ + glGenProgramsARB(1, &modulateProg); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(modulate2D), (const GLubyte *)modulate2D); + + printf("glGetError = 0x%x\n", (int) glGetError()); + printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + + glEnable(GL_FRAGMENT_PROGRAM_ARB); + + glClearColor(.3, .3, .3, 0); +} + +static void Reshape(int width, int height) +{ + + glViewport(0, 0, (GLint)width, (GLint)height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0); + glMatrixMode(GL_MODELVIEW); +} + +static void Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,1); + glVertex3f( 0.9, -0.9, -30.0); + glColor3f(1,0,0); + glVertex3f( 0.9, 0.9, -30.0); + glColor3f(0,1,0); + glVertex3f(-0.9, 0.0, -30.0); + glEnd(); + + glFlush(); + + +} + + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + + + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB; + type |= GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/fp/tri-swz.c b/progs/fp/tri-swz.c new file mode 100644 index 00000000000..5f34f7a3222 --- /dev/null +++ b/progs/fp/tri-swz.c @@ -0,0 +1,109 @@ + +#include +#include +#include +#define GL_GLEXT_PROTOTYPES +#include +#include "GL/gl.h" + + + +static void Init( void ) +{ + static const char *modulate2D = + "!!ARBfp1.0\n" + "SWZ result.color, fragment.color, 1,x,y,z; \n" + "END" + ; + GLuint modulateProg; + + if (!glutExtensionSupported("GL_ARB_fragment_program")) { + printf("Error: GL_ARB_fragment_program not supported!\n"); + exit(1); + } + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + /* Setup the fragment program */ + glGenProgramsARB(1, &modulateProg); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(modulate2D), (const GLubyte *)modulate2D); + + printf("glGetError = 0x%x\n", (int) glGetError()); + printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + + glEnable(GL_FRAGMENT_PROGRAM_ARB); + + glClearColor(.3, .3, .3, 0); +} + +static void Reshape(int width, int height) +{ + + glViewport(0, 0, (GLint)width, (GLint)height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0); + glMatrixMode(GL_MODELVIEW); +} + +static void Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,1); + glVertex3f( 0.9, -0.9, -30.0); + glColor3f(1,0,0); + glVertex3f( 0.9, 0.9, -30.0); + glColor3f(0,1,0); + glVertex3f(-0.9, 0.0, -30.0); + glEnd(); + + glFlush(); + + +} + + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + + + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB; + type |= GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/fp/tri-swz2.c b/progs/fp/tri-swz2.c new file mode 100644 index 00000000000..fd76b58f539 --- /dev/null +++ b/progs/fp/tri-swz2.c @@ -0,0 +1,109 @@ + +#include +#include +#include +#define GL_GLEXT_PROTOTYPES +#include + + + +static void Init( void ) +{ + static const char *modulate2D = + "!!ARBfp1.0\n" + "TEMP R0, R1;\n" + "SWZ result.color, fragment.color, 1, 0, 0, 1; \n" + "END" + ; + GLuint modulateProg; + + if (!glutExtensionSupported("GL_ARB_fragment_program")) { + printf("Error: GL_ARB_fragment_program not supported!\n"); + exit(1); + } + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + /* Setup the fragment program */ + glGenProgramsARB(1, &modulateProg); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(modulate2D), (const GLubyte *)modulate2D); + + printf("glGetError = 0x%x\n", (int) glGetError()); + printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + + glEnable(GL_FRAGMENT_PROGRAM_ARB); + + glClearColor(.3, .3, .3, 0); +} + +static void Reshape(int width, int height) +{ + + glViewport(0, 0, (GLint)width, (GLint)height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0); + glMatrixMode(GL_MODELVIEW); +} + +static void Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,1); + glVertex3f( 0.9, -0.9, -30.0); + glColor3f(1,0,0); + glVertex3f( 0.9, 0.9, -30.0); + glColor3f(0,1,0); + glVertex3f(-0.9, 0.0, -30.0); + glEnd(); + + glFlush(); + + +} + + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + + + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB; + type |= GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/fp/tri-tex.c b/progs/fp/tri-tex.c new file mode 100644 index 00000000000..87f63894ce9 --- /dev/null +++ b/progs/fp/tri-tex.c @@ -0,0 +1,130 @@ + +#include +#include +#include +#include +#define GL_GLEXT_PROTOTYPES +#include + +#include "readtex.c" + + +#define TEXTURE_FILE "../images/girl.rgb" + + + +static void Init( void ) +{ + static const char *modulate2D = + "!!ARBfp1.0\n" + "TEX result.color, fragment.color, texture[0], 2D; \n" + "END" + ; + GLuint modulateProg; + GLuint Texture; + + if (!glutExtensionSupported("GL_ARB_fragment_program")) { + printf("Error: GL_ARB_fragment_program not supported!\n"); + exit(1); + } + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + /* Setup the fragment program */ + glGenProgramsARB(1, &modulateProg); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(modulate2D), (const GLubyte *)modulate2D); + + printf("glGetError = 0x%x\n", (int) glGetError()); + printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + assert(glIsProgramARB(modulateProg)); + + glEnable(GL_FRAGMENT_PROGRAM_ARB); + + /* Load texture */ + glGenTextures(1, &Texture); + glBindTexture(GL_TEXTURE_2D, Texture); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + if (!LoadRGBMipmaps(TEXTURE_FILE, GL_RGB)) { + printf("Error: couldn't load texture image file %s\n", TEXTURE_FILE); + exit(1); + } + /* XXX this enable shouldn't really be needed!!! */ + glEnable(GL_TEXTURE_2D); + + glClearColor(.3, .3, .3, 0); +} + +static void Reshape(int width, int height) +{ + + glViewport(0, 0, (GLint)width, (GLint)height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0); + glMatrixMode(GL_MODELVIEW); +} + +static void Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,1); +/* glTexCoord2f(1, 0); */ + glVertex3f( 0.9, -0.9, -30.0); + glColor3f(1,0,0); +/* glTexCoord2f(1, 1); */ + glVertex3f( 0.9, 0.9, -30.0); + glColor3f(0,1,0); +/* glTexCoord2f(0, .5); */ + glVertex3f(-0.9, 0.0, -30.0); + glEnd(); + + glFlush(); +} + + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + + + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB; + type |= GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/fp/tri-xpd.c b/progs/fp/tri-xpd.c new file mode 100644 index 00000000000..9aca46b2faa --- /dev/null +++ b/progs/fp/tri-xpd.c @@ -0,0 +1,108 @@ + +#include +#include +#include +#define GL_GLEXT_PROTOTYPES +#include +#include "GL/gl.h" + + + +static void Init( void ) +{ + static const char *modulate2D = + "!!ARBfp1.0\n" + "XPD result.color, fragment.color, {2,2,2,0}; \n" + "END" + ; + GLuint modulateProg; + + if (!glutExtensionSupported("GL_ARB_fragment_program")) { + printf("Error: GL_ARB_fragment_program not supported!\n"); + exit(1); + } + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + /* Setup the fragment program */ + glGenProgramsARB(1, &modulateProg); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(modulate2D), (const GLubyte *)modulate2D); + + printf("glGetError = 0x%x\n", (int) glGetError()); + printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + + glEnable(GL_FRAGMENT_PROGRAM_ARB); + + glClearColor(.3, .3, .3, 0); +} + +static void Reshape(int width, int height) +{ + + glViewport(0, 0, (GLint)width, (GLint)height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0); + glMatrixMode(GL_MODELVIEW); +} + +static void Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,1); + glVertex3f( 0.9, -0.9, -30.0); + glColor3f(1,0,0); + glVertex3f( 0.9, 0.9, -30.0); + glColor3f(0,1,0); + glVertex3f(-0.9, 0.0, -30.0); + glEnd(); + + glFlush(); + + +} + + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB; + type |= GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/ggi/asc-view.c b/progs/ggi/asc-view.c new file mode 100644 index 00000000000..d37fba9d9f7 --- /dev/null +++ b/progs/ggi/asc-view.c @@ -0,0 +1,377 @@ +/* + test program for the ggi-mesa driver + + Copyright (C) 1997,1998 Uwe Maurer - uwe_maurer@t-online.de + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include + +ggi_visual_t vis,vis_mem; + +GGIMesaContext ctx; + +int screen_x=GGI_AUTO,screen_y=GGI_AUTO; +ggi_graphtype bpp=GT_AUTO; + +//#define ZBUFFER + +//#define SMOOTH_NORMALS + +void Init() +{ + GLfloat h=(GLfloat)3/4; + GLfloat pos[4]={5,5,-20,0}; + GLfloat specular[4]={.4,.4,.4,1}; + GLfloat diffuse[4]={.3,.3,.3,1}; + GLfloat ambient[4]={.2,.2,.2,1}; + + int err; + + if (ggiInit()<0) + { + printf("ggiInit() failed\n"); + exit(1); + } + ctx=GGIMesaCreateContext(); + if (ctx==NULL) + { + printf("Can't create Context!\n"); + exit(1); + } + + vis=ggiOpen(NULL); + vis_mem=ggiOpen("display-memory",NULL); + if (vis==NULL || vis_mem==NULL) + { + printf("Can't open ggi_visuals!\n"); + exit(1); + } + err=ggiSetGraphMode(vis,screen_x,screen_y,screen_x,screen_y,bpp); + err+=ggiSetGraphMode(vis_mem,screen_x,screen_y,screen_x,screen_y,bpp); + if (err) + { + printf("Can't set %ix%i\n",screen_x,screen_y); + exit(1); + } + + if (GGIMesaSetVisual(ctx,vis_mem,GL_TRUE,GL_FALSE)<0) + { + printf("GGIMesaSetVisual() failed!\n"); + exit(1); + } + + GGIMesaMakeCurrent(ctx); + + glViewport(0,0,screen_x,screen_y); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glFrustum(-1,1,-h,h,1,50); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTranslatef(0,0,-9); + glShadeModel(GL_FLAT); + + glFrontFace(GL_CW); + glEnable(GL_CULL_FACE); + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + + glLightfv(GL_LIGHT0,GL_POSITION,pos); + + glLightfv(GL_LIGHT0,GL_DIFFUSE,diffuse); + glLightfv(GL_LIGHT0,GL_AMBIENT,ambient); + glLightfv(GL_LIGHT0,GL_SPECULAR,specular); + + #ifdef ZBUFFER + glEnable(GL_DEPTH_TEST); + #endif +} + + +#define MAX_VERTS 1000 +#define MAX_TRIS 2000 +#define MAX_LEN 1024 +#define MAX_F 100000000 + +void LoadAsc(GLuint *list,char *file) +{ + FILE *fp; + + GLfloat p[MAX_VERTS][3]; + GLfloat normal[MAX_VERTS][3]; + float ncount[MAX_VERTS]; + int v[MAX_TRIS][3]; + char line[MAX_LEN]; + char *s; + int i,j; + int verts,faces; + GLuint v0,v1,v2; + GLfloat n[3]; + GLfloat len,k; + GLfloat min[3]={MAX_F,MAX_F,MAX_F}; + GLfloat max[3]={-MAX_F,-MAX_F,-MAX_F}; + char *coord_str[]={"X","Z","Y"}; + + fp=fopen(file,"r"); + if (!fp) + { + printf("Can't open %s!\n",file); + exit(1); + } + + while (strncmp(fgets(line,MAX_LEN,fp),"Tri-mesh",8)) ; + + s=strstr(line,":")+1; + verts=atoi(s); + s=strstr(s,":")+1; + faces=atoi(s); + + if (verts>MAX_VERTS) + { + printf("Too many vertices..\n"); + exit(1); + } + + while (strncmp(fgets(line,MAX_LEN,fp),"Vertex list",11)) ; + + for (i=0;imax[j]) max[j]=k; + if (klen) {len=k;j=i;} + n[i]=(max[i]+min[i])/2; + } + + len/=2; + + for (i=0;iread); + rotate+=10; + frames++; + if (frames==(*maxframes)) break; + + if (ggiKbhit(vis)) + { + *maxframes=frames; + break; + } + } + + gettimeofday(&stop,NULL); + len=(double)(stop.tv_sec-start.tv_sec)+ + (double)(stop.tv_usec-start.tv_usec)/1e6; + return len; +} + +void visible(int vis) +{ + if (vis == GLUT_VISIBLE) + glutIdleFunc(idle); + else + glutIdleFunc(NULL); +} + +int main(int argc, char *argv[]) +{ + glutInit(&argc, argv); + glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE); + + glutInitWindowPosition(0, 0); + glutInitWindowSize(300, 300); + glutCreateWindow("asc-view"); + init(); + + glutDisplayFunc(draw); + glutReshapeFunc(reshape); + glutKeyboardFunc(key); + glutSpecialFunc(special); + glutVisibilityFunc(visible); + + glutMainLoop(); +#if 0 + GLuint l; + char *file; + int maxframes=0; + double len; + + Init(); + + file=(argc>1) ? argv[1] : "asc/box.asc"; + if (argc>2) maxframes=atoi(argv[2]); + + if (argc==1) + { + printf("usage: %s filename.asc\n",argv[0]); + } + + LoadAsc(&l,file); + + len=Display(l,&maxframes); + + printf("\ttime: %.3f sec\n",len); + printf("\tframes: %i\n",maxframes); + printf("\tfps: %.3f \n",(double)maxframes/len); + + GGIMesaDestroyContext(ctx); + ggiClose(vis); + ggiClose(vis_mem); + ggiExit(); +#endif + return 0; +} + diff --git a/progs/ggi/blah b/progs/ggi/blah new file mode 100644 index 00000000000..2c1664d7d05 --- /dev/null +++ b/progs/ggi/blah @@ -0,0 +1,2 @@ +Terminating on signal 11 + diff --git a/progs/ggi/blat b/progs/ggi/blat new file mode 100644 index 00000000000..7ff64a9d10d --- /dev/null +++ b/progs/ggi/blat @@ -0,0 +1,7 @@ +#!/bin/sh + +function foobar() { + echo "foo!" +} + +foobar diff --git a/progs/ggi/box.asc b/progs/ggi/box.asc new file mode 100644 index 00000000000..f8b23fd85af --- /dev/null +++ b/progs/ggi/box.asc @@ -0,0 +1,66 @@ +Ambient light color: Red=0.039216 Green=0.039216 Blue=0.039216 + +Named object: "Object01" +Tri-mesh, Vertices: 8 Faces: 12 +Vertex list: +Vertex 0: X: -20 Y: -19.999998 Z: 20.000002 +Vertex 1: X: 20 Y: -19.999998 Z: 20.000002 +Vertex 2: X: 20 Y: 20.000002 Z: 19.999998 +Vertex 3: X: -20 Y: 20.000002 Z: 19.999998 +Vertex 4: X: -20 Y: -20.000002 Z: -19.999998 +Vertex 5: X: 20 Y: -20.000002 Z: -19.999998 +Vertex 6: X: 20 Y: 19.999998 Z: -20.000002 +Vertex 7: X: -20 Y: 19.999998 Z: -20.000002 +Face list: +Face 0: A:0 B:1 C:2 AB:1 BC:1 CA:0 +Smoothing: 1 +Face 1: A:0 B:2 C:3 AB:0 BC:1 CA:1 +Smoothing: 1 +Face 2: A:0 B:4 C:5 AB:1 BC:1 CA:0 +Smoothing: 2 +Face 3: A:0 B:5 C:1 AB:0 BC:1 CA:1 +Smoothing: 2 +Face 4: A:1 B:5 C:6 AB:1 BC:1 CA:0 +Smoothing: 3 +Face 5: A:1 B:6 C:2 AB:0 BC:1 CA:1 +Smoothing: 3 +Face 6: A:2 B:6 C:7 AB:1 BC:1 CA:0 +Smoothing: 4 +Face 7: A:2 B:7 C:3 AB:0 BC:1 CA:1 +Smoothing: 4 +Face 8: A:3 B:7 C:4 AB:1 BC:1 CA:0 +Smoothing: 5 +Face 9: A:3 B:4 C:0 AB:0 BC:1 CA:1 +Smoothing: 5 +Face 10: A:4 B:7 C:6 AB:1 BC:1 CA:0 +Smoothing: 6 +Face 11: A:4 B:6 C:5 AB:0 BC:1 CA:1 +Smoothing: 6 + + + + + + + + + + + + + + + + + + + + + + + + + Page 1 + + + diff --git a/progs/ggi/cone.asc b/progs/ggi/cone.asc new file mode 100644 index 00000000000..5c522859963 --- /dev/null +++ b/progs/ggi/cone.asc @@ -0,0 +1,198 @@ +Ambient light color: Red=0.039216 Green=0.039216 Blue=0.039216 + +Named object: "Object01" +Tri-mesh, Vertices: 34 Faces: 64 +Vertex list: +Vertex 0: X: 60.167416 Y: -87.419525 Z: -53.3088 +Vertex 1: X: 76.70787 Y: -87.419518 Z: -29.84565 +Vertex 2: X: 83.0103 Y: -87.419518 Z: -1.838764 +Vertex 3: X: 78.115204 Y: -87.419518 Z: 26.448057 +Vertex 4: X: 62.767834 Y: -87.41951 Z: 50.708401 +Vertex 5: X: 39.304672 Y: -87.41951 Z: 67.248848 +Vertex 6: X: 11.297782 Y: -87.41951 Z: 73.551254 +Vertex 7: X: -16.989004 Y: -87.41951 Z: 68.656158 +Vertex 8: X: -41.249344 Y: -87.41951 Z: 53.308777 +Vertex 9: X: -57.789783 Y: -87.419518 Z: 29.845612 +Vertex 10: X: -64.092194 Y: -87.419518 Z: 1.838721 +Vertex 11: X: -59.197079 Y: -87.419518 Z: -26.448097 +Vertex 12: X: -43.849678 Y: -87.419525 Z: -50.708427 +Vertex 13: X: -20.386503 Y: -87.419525 Z: -67.248856 +Vertex 14: X: 7.62039 Y: -87.419525 Z: -73.551239 +Vertex 15: X: 35.907204 Y: -87.419525 Z: -68.656105 +Vertex 16: X: 101.684875 Y: 94.590591 Z: -96.955391 +Vertex 17: X: 131.767838 Y: 94.590591 Z: -54.281792 +Vertex 18: X: 143.230377 Y: 94.590599 Z: -3.344275 +Vertex 19: X: 134.327423 Y: 94.590607 Z: 48.102379 +Vertex 20: X: 106.414383 Y: 94.590607 Z: 92.225876 +Vertex 21: X: 63.740765 Y: 94.590607 Z: 122.3088 +Vertex 22: X: 12.803238 Y: 94.590614 Z: 133.771301 +Vertex 23: X: -38.643349 Y: 94.590607 Z: 124.868355 +Vertex 24: X: -82.766846 Y: 94.590607 Z: 96.955307 +Vertex 25: X: -112.849762 Y: 94.590607 Z: 54.281677 +Vertex 26: X: -124.312256 Y: 94.590599 Z: 3.344152 +Vertex 27: X: -115.409271 Y: 94.590591 Z: -48.102493 +Vertex 28: X: -87.496201 Y: 94.590591 Z: -92.225967 +Vertex 29: X: -44.822552 Y: 94.590591 Z: -122.308861 +Vertex 30: X: 6.114983 Y: 94.590584 Z: -133.771332 +Vertex 31: X: 57.561623 Y: 94.590591 Z: -124.868301 +Vertex 32: X: 9.459057 Y: -87.419518 Z: 0.000008 +Vertex 33: X: 9.459057 Y: 94.590599 Z: -0.000008 +Face list: +Face 0: A:0 B:1 C:32 AB:1 BC:0 CA:0 +Smoothing: 1 +Face 1: A:1 B:2 C:32 AB:1 BC:0 CA:0 +Smoothing: 1 +Face 2: A:2 B:3 C:32 AB:1 BC:0 CA:0 +Smoothing: 1 +Face 3: A:3 B:4 C:32 AB:1 BC:0 CA:0 +Smoothing: 1 +Face 4: A:4 B:5 C:32 AB:1 BC:0 CA:0 +Smoothing: 1 +Face 5: A:5 B:6 C:32 AB:1 BC:0 CA:0 +Smoothing: 1 +Face 6: A:6 B:7 C:32 AB:1 BC:0 CA:0 +Smoothing: 1 +Face 7: A:7 B:8 C:32 AB:1 BC:0 CA:0 +Smoothing: 1 +Face 8: A:8 B:9 C:32 AB:1 BC:0 CA:0 +Smoothing: 1 +Face 9: A:9 B:10 C:32 AB:1 BC:0 CA:0 +Smoothing: 1 +Face 10: A:10 B:11 C:32 AB:1 BC:0 CA:0 + + Page 1 + + + +Smoothing: 1 +Face 11: A:11 B:12 C:32 AB:1 BC:0 CA:0 +Smoothing: 1 +Face 12: A:12 B:13 C:32 AB:1 BC:0 CA:0 +Smoothing: 1 +Face 13: A:13 B:14 C:32 AB:1 BC:0 CA:0 +Smoothing: 1 +Face 14: A:14 B:15 C:32 AB:1 BC:0 CA:0 +Smoothing: 1 +Face 15: A:15 B:0 C:32 AB:1 BC:0 CA:0 +Smoothing: 1 +Face 16: A:0 B:16 C:17 AB:1 BC:1 CA:0 +Smoothing: 2 +Face 17: A:0 B:17 C:1 AB:0 BC:1 CA:1 +Smoothing: 2 +Face 18: A:1 B:17 C:18 AB:1 BC:1 CA:0 +Smoothing: 3 +Face 19: A:1 B:18 C:2 AB:0 BC:1 CA:1 +Smoothing: 3 +Face 20: A:2 B:18 C:19 AB:1 BC:1 CA:0 +Smoothing: 4 +Face 21: A:2 B:19 C:3 AB:0 BC:1 CA:1 +Smoothing: 4 +Face 22: A:3 B:19 C:20 AB:1 BC:1 CA:0 +Smoothing: 5 +Face 23: A:3 B:20 C:4 AB:0 BC:1 CA:1 +Smoothing: 5 +Face 24: A:4 B:20 C:21 AB:1 BC:1 CA:0 +Smoothing: 6 +Face 25: A:4 B:21 C:5 AB:0 BC:1 CA:1 +Smoothing: 6 +Face 26: A:5 B:21 C:22 AB:1 BC:1 CA:0 +Smoothing: 7 +Face 27: A:5 B:22 C:6 AB:0 BC:1 CA:1 +Smoothing: 7 +Face 28: A:6 B:22 C:23 AB:1 BC:1 CA:0 +Smoothing: 8 +Face 29: A:6 B:23 C:7 AB:0 BC:1 CA:1 +Smoothing: 8 +Face 30: A:7 B:23 C:24 AB:1 BC:1 CA:0 +Smoothing: 9 +Face 31: A:7 B:24 C:8 AB:0 BC:1 CA:1 +Smoothing: 9 +Face 32: A:8 B:24 C:25 AB:1 BC:1 CA:0 +Smoothing: 10 +Face 33: A:8 B:25 C:9 AB:0 BC:1 CA:1 +Smoothing: 10 +Face 34: A:9 B:25 C:26 AB:1 BC:1 CA:0 +Smoothing: 11 +Face 35: A:9 B:26 C:10 AB:0 BC:1 CA:1 +Smoothing: 11 +Face 36: A:10 B:26 C:27 AB:1 BC:1 CA:0 +Smoothing: 12 +Face 37: A:10 B:27 C:11 AB:0 BC:1 CA:1 +Smoothing: 12 +Face 38: A:11 B:27 C:28 AB:1 BC:1 CA:0 +Smoothing: 13 +Face 39: A:11 B:28 C:12 AB:0 BC:1 CA:1 +Smoothing: 13 +Face 40: A:12 B:28 C:29 AB:1 BC:1 CA:0 +Smoothing: 14 + + Page 2 + + + +Face 41: A:12 B:29 C:13 AB:0 BC:1 CA:1 +Smoothing: 14 +Face 42: A:13 B:29 C:30 AB:1 BC:1 CA:0 +Smoothing: 15 +Face 43: A:13 B:30 C:14 AB:0 BC:1 CA:1 +Smoothing: 15 +Face 44: A:14 B:30 C:31 AB:1 BC:1 CA:0 +Smoothing: 16 +Face 45: A:14 B:31 C:15 AB:0 BC:1 CA:1 +Smoothing: 16 +Face 46: A:15 B:31 C:16 AB:1 BC:1 CA:0 +Smoothing: 17 +Face 47: A:15 B:16 C:0 AB:0 BC:1 CA:1 +Smoothing: 17 +Face 48: A:16 B:33 C:17 AB:0 BC:0 CA:1 +Smoothing: 18 +Face 49: A:17 B:33 C:18 AB:0 BC:0 CA:1 +Smoothing: 18 +Face 50: A:18 B:33 C:19 AB:0 BC:0 CA:1 +Smoothing: 18 +Face 51: A:19 B:33 C:20 AB:0 BC:0 CA:1 +Smoothing: 18 +Face 52: A:20 B:33 C:21 AB:0 BC:0 CA:1 +Smoothing: 18 +Face 53: A:21 B:33 C:22 AB:0 BC:0 CA:1 +Smoothing: 18 +Face 54: A:22 B:33 C:23 AB:0 BC:0 CA:1 +Smoothing: 18 +Face 55: A:23 B:33 C:24 AB:0 BC:0 CA:1 +Smoothing: 18 +Face 56: A:24 B:33 C:25 AB:0 BC:0 CA:1 +Smoothing: 18 +Face 57: A:25 B:33 C:26 AB:0 BC:0 CA:1 +Smoothing: 18 +Face 58: A:26 B:33 C:27 AB:0 BC:0 CA:1 +Smoothing: 18 +Face 59: A:27 B:33 C:28 AB:0 BC:0 CA:1 +Smoothing: 18 +Face 60: A:28 B:33 C:29 AB:0 BC:0 CA:1 +Smoothing: 18 +Face 61: A:29 B:33 C:30 AB:0 BC:0 CA:1 +Smoothing: 18 +Face 62: A:30 B:33 C:31 AB:0 BC:0 CA:1 +Smoothing: 18 +Face 63: A:31 B:33 C:16 AB:0 BC:0 CA:1 +Smoothing: 18 + + + + + + + + + + + + + + + + + Page 3 + + + diff --git a/progs/ggi/gears.c b/progs/ggi/gears.c new file mode 100644 index 00000000000..56711f5d544 --- /dev/null +++ b/progs/ggi/gears.c @@ -0,0 +1,340 @@ +/* $Id: gears.c,v 1.3 1999-08-22 08:56:50 jtaylor Exp $ */ + +/* + * 3-D gear wheels. This program is in the public domain. + * + * Brian Paul + */ + +/* Conversion to GLUT by Mark J. Kilgard */ + +#include +#include +#include +#include + +#ifndef M_PI +#define M_PI 3.14159265 +#endif + +static GLint T0 = 0; +static GLint Frames = 0; + + +/** + + Draw a gear wheel. You'll probably want to call this function when + building a display list since we do a lot of trig here. + + Input: inner_radius - radius of hole at center + outer_radius - radius at center of teeth + width - width of gear + teeth - number of teeth + tooth_depth - depth of tooth + + **/ + +static void +gear(GLfloat inner_radius, GLfloat outer_radius, GLfloat width, + GLint teeth, GLfloat tooth_depth) +{ + GLint i; + GLfloat r0, r1, r2; + GLfloat angle, da; + GLfloat u, v, len; + + r0 = inner_radius; + r1 = outer_radius - tooth_depth / 2.0; + r2 = outer_radius + tooth_depth / 2.0; + + da = 2.0 * M_PI / teeth / 4.0; + + glShadeModel(GL_FLAT); + + glNormal3f(0.0, 0.0, 1.0); + + /* draw front face */ + glBegin(GL_QUAD_STRIP); + for (i = 0; i <= teeth; i++) { + angle = i * 2.0 * M_PI / teeth; + glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5); + glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5); + if (i < teeth) { + glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5); + glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), width * 0.5); + } + } + glEnd(); + + /* draw front sides of teeth */ + glBegin(GL_QUADS); + da = 2.0 * M_PI / teeth / 4.0; + for (i = 0; i < teeth; i++) { + angle = i * 2.0 * M_PI / teeth; + + glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5); + glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), width * 0.5); + glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), width * 0.5); + glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), width * 0.5); + } + glEnd(); + + glNormal3f(0.0, 0.0, -1.0); + + /* draw back face */ + glBegin(GL_QUAD_STRIP); + for (i = 0; i <= teeth; i++) { + angle = i * 2.0 * M_PI / teeth; + glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5); + glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5); + if (i < teeth) { + glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), -width * 0.5); + glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5); + } + } + glEnd(); + + /* draw back sides of teeth */ + glBegin(GL_QUADS); + da = 2.0 * M_PI / teeth / 4.0; + for (i = 0; i < teeth; i++) { + angle = i * 2.0 * M_PI / teeth; + + glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), -width * 0.5); + glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), -width * 0.5); + glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), -width * 0.5); + glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5); + } + glEnd(); + + /* draw outward faces of teeth */ + glBegin(GL_QUAD_STRIP); + for (i = 0; i < teeth; i++) { + angle = i * 2.0 * M_PI / teeth; + + glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5); + glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5); + u = r2 * cos(angle + da) - r1 * cos(angle); + v = r2 * sin(angle + da) - r1 * sin(angle); + len = sqrt(u * u + v * v); + u /= len; + v /= len; + glNormal3f(v, -u, 0.0); + glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), width * 0.5); + glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), -width * 0.5); + glNormal3f(cos(angle), sin(angle), 0.0); + glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), width * 0.5); + glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), -width * 0.5); + u = r1 * cos(angle + 3 * da) - r2 * cos(angle + 2 * da); + v = r1 * sin(angle + 3 * da) - r2 * sin(angle + 2 * da); + glNormal3f(v, -u, 0.0); + glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), width * 0.5); + glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), -width * 0.5); + glNormal3f(cos(angle), sin(angle), 0.0); + } + + glVertex3f(r1 * cos(0), r1 * sin(0), width * 0.5); + glVertex3f(r1 * cos(0), r1 * sin(0), -width * 0.5); + + glEnd(); + + glShadeModel(GL_SMOOTH); + + /* draw inside radius cylinder */ + glBegin(GL_QUAD_STRIP); + for (i = 0; i <= teeth; i++) { + angle = i * 2.0 * M_PI / teeth; + glNormal3f(-cos(angle), -sin(angle), 0.0); + glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5); + glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5); + } + glEnd(); + +} + +static GLfloat view_rotx = 20.0, view_roty = 30.0, view_rotz = 0.0; +static GLint gear1, gear2, gear3; +static GLfloat angle = 0.0; + +static void +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); + + 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, 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 %g seconds = %g FPS\n", Frames, seconds, fps); + T0 = t; + Frames = 0; + } + } +} + + +static void +idle(void) +{ + angle += 2.0; + glutPostRedisplay(); +} + +/* change view angle, exit upon ESC */ +/* ARGSUSED1 */ +static void +key(unsigned char k, int x, int y) +{ + switch (k) { + case 'z': + view_rotz += 5.0; + break; + case 'Z': + view_rotz -= 5.0; + break; + case 27: /* Escape */ + exit(0); /* FIXME: Shutdown and free resources cleanly in ggiglut */ + break; + default: + return; + } + glutPostRedisplay(); +} + +/* change view angle */ +/* ARGSUSED1 */ +static void +special(int k, int x, int y) +{ + switch (k) { + case GLUT_KEY_UP: + view_rotx += 5.0; + break; + case GLUT_KEY_DOWN: + view_rotx -= 5.0; + break; + case GLUT_KEY_LEFT: + view_roty += 5.0; + break; + case GLUT_KEY_RIGHT: + view_roty -= 5.0; + break; + default: + return; + } + glutPostRedisplay(); +} + +/* new window size or exposure */ +static void +reshape(int width, int height) +{ + GLfloat h = (GLfloat) height / (GLfloat) width; + + glViewport(0, 0, (GLint) width, (GLint) height); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glFrustum(-1.0, 1.0, -h, h, 5.0, 60.0); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTranslatef(0.0, 0.0, -40.0); +} + +static void +init(void) +{ + 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); + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + glEnable(GL_DEPTH_TEST); + + /* make the gears */ + gear1 = glGenLists(1); + glNewList(gear1, GL_COMPILE); + glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, red); + gear(1.0, 4.0, 1.0, 20, 0.7); + glEndList(); + + gear2 = glGenLists(1); + glNewList(gear2, GL_COMPILE); + glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, green); + gear(0.5, 2.0, 2.0, 10, 0.7); + glEndList(); + + gear3 = glGenLists(1); + glNewList(gear3, GL_COMPILE); + glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, blue); + gear(1.3, 2.0, 0.5, 10, 0.7); + glEndList(); + + glEnable(GL_NORMALIZE); +} + +void +visible(int vis) +{ + if (vis == GLUT_VISIBLE) + glutIdleFunc(idle); + else + glutIdleFunc(NULL); +} + +int main(int argc, char *argv[]) +{ + glutInit(&argc, argv); + glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE); + +// glutInitWindowPosition(0, 0); +// glutInitWindowSize(300, 300); + glutCreateWindow("Gears"); + init(); + + glutDisplayFunc(draw); + glutReshapeFunc(reshape); + glutKeyboardFunc(key); + glutSpecialFunc(special); + glutVisibilityFunc(visible); + + glutMainLoop(); + + return 0; +} diff --git a/progs/ggi/gears2.c b/progs/ggi/gears2.c new file mode 100644 index 00000000000..9468c031777 --- /dev/null +++ b/progs/ggi/gears2.c @@ -0,0 +1,390 @@ +/* gears.c */ + +/* + * 3-D gear wheels. This program is in the public domain. + * + * Brian Paul + * modified by Uwe Maurer (uwe_maurer@t-online.de) + */ + +#include +#include +#include +#include +#include +#ifndef M_PI +# define M_PI 3.14159265 +#endif + + +ggi_visual_t vis; +char text[100]; +int db_flag,vis_x, vis_y, vir_x, vir_y, gt; + +/* + * Draw a gear wheel. You'll probably want to call this function when + * building a display list since we do a lot of trig here. + * + * Input: inner_radius - radius of hole at center + * outer_radius - radius at center of teeth + * width - width of gear + * teeth - number of teeth + * tooth_depth - depth of tooth + */ +static void gear( GLfloat inner_radius, GLfloat outer_radius, GLfloat width, + GLint teeth, GLfloat tooth_depth ) +{ + GLint i; + GLfloat r0, r1, r2; + GLfloat angle, da; + GLfloat u, v, len; + + r0 = inner_radius; + r1 = outer_radius - tooth_depth/2.0; + r2 = outer_radius + tooth_depth/2.0; + + da = 2.0*M_PI / teeth / 4.0; + + glShadeModel( GL_FLAT ); + + glNormal3f( 0.0, 0.0, 1.0 ); + + /* draw front face */ + glBegin( GL_QUAD_STRIP ); + for (i=0;i<=teeth;i++) { + angle = i * 2.0*M_PI / teeth; + glVertex3f( r0*cos(angle), r0*sin(angle), width*0.5 ); + glVertex3f( r1*cos(angle), r1*sin(angle), width*0.5 ); + glVertex3f( r0*cos(angle), r0*sin(angle), width*0.5 ); + glVertex3f( r1*cos(angle+3*da), r1*sin(angle+3*da), width*0.5 ); + } + glEnd(); + + /* draw front sides of teeth */ + glBegin( GL_QUADS ); + da = 2.0*M_PI / teeth / 4.0; + for (i=0;i GGI"); + ggiPuts(vis,0,ggiGetInfo(vis)->mode->visible.y," Mesa -> GGI"); + + ggiPuts(vis,0,16,text); + ggiPuts(vis,0,ggiGetInfo(vis)->mode->visible.y+16,text); +#endif + + if(db_flag) + ggiMesaSwapBuffers(); + + count++; + if (count==limit) { + exit(1); + } + ++n; + /* + if (!(n%10)){ + ggi_color rgb = { 10000, 10000, 10000 }; + ggiSetSimpleMode(vis,vis_x+(n/10),vis_y+(n/10),db_flag?2:1, gt); + glViewport(0, 0,vis_x+(n/10),vis_y+(n/10)); + ggiSetGCForeground(vis, ggiMapColor(vis, &rgb)); + ggiDrawBox(vis, 20, 20, 100, 100); + if(db_flag) + ggiSetWriteFrame(vis, 1); + } + */ +} + +static void idle( void ) +{ + angle += 2.0; + draw(); +} + +/* new window size or exposure */ +static void reshape( int width, int height ) +{ + GLfloat h = (GLfloat) height / (GLfloat) width; + + if(db_flag) + glDrawBuffer(GL_BACK); + else + glDrawBuffer(GL_FRONT); + glViewport(0, 0, (GLint)width, (GLint)height); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glFrustum( -1.0, 1.0, -h, h, 5.0, 60.0 ); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTranslatef( 0.0, 0.0, -40.0 ); + glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); + +} + + +static void init( void ) +{ + static GLfloat pos[4] = {5.0, 5.0, 10.0, 0.0 }; + static GLfloat red[4] = {0.9, 0.9, 0.9, 1.0 }; + static GLfloat green[4] = {0.0, 0.8, 0.9, 1.0 }; + static GLfloat blue[4] = {0.2, 0.2, 1.0, 1.0 }; + + glLightfv( GL_LIGHT0, GL_POSITION, pos ); + glEnable( GL_CULL_FACE ); + glEnable( GL_LIGHTING ); + glEnable( GL_LIGHT0 ); + glEnable( GL_DEPTH_TEST ); + + /* make the gears */ + gear1 = glGenLists(1); + glNewList(gear1, GL_COMPILE); + glMaterialfv( GL_FRONT, GL_AMBIENT_AND_DIFFUSE, red ); + glIndexi(1); + gear( 1.0, 4.0, 1.0, 20, 0.7 ); + glEndList(); + + gear2 = glGenLists(1); + glNewList(gear2, GL_COMPILE); + glMaterialfv( GL_FRONT, GL_AMBIENT_AND_DIFFUSE, green ); + glIndexi(2); + gear( 0.5, 2.0, 2.0, 10, 0.7 ); + glEndList(); + + gear3 = glGenLists(1); + glNewList(gear3, GL_COMPILE); + glMaterialfv( GL_FRONT, GL_AMBIENT_AND_DIFFUSE, blue ); + glIndexi(3); + gear( 1.3, 2.0, 0.5, 10, 0.7 ); + glEndList(); + + glEnable( GL_NORMALIZE ); +} + +static void usage(char *s) +{ + printf("%s visible_x visible_y virtual_x virtual_y bpp db_flag\n",s); + printf("example:\n"); + printf("%s 320 200 320 400 8 1\n",s); + exit(1); +} + +int main( int argc, char *argv[] ) +{ + ggi_mesa_context_t ctx; + ggi_mode mode; + int bpp; + + limit=0; + + if (argc<7) usage(argv[0]); + + vis_x=atoi(argv[1]); + vis_y=atoi(argv[2]); + vir_x=atoi(argv[3]); + vir_y=atoi(argv[4]); + bpp=atoi(argv[5]); + db_flag=atoi(argv[6]); + + switch(bpp) + { + case 4: gt=GT_4BIT;break; + case 8: gt=GT_8BIT;break; + case 15:gt=GT_15BIT;break; + case 16:gt=GT_16BIT;break; + case 24:gt=GT_24BIT;break; + case 32:gt=GT_32BIT;break; + default: + printf("%i Bits per Pixel ???\n",bpp); + exit(1); + } + sprintf(text,"%sx%s %i colors, RGB mode, %s", + argv[1],argv[2],1< /dev/null + + +# Emacs tags +tags: + etags `find . -name \*.[ch]` `find ../include` + + +include depend diff --git a/progs/miniglx/glfbdevtest.c b/progs/miniglx/glfbdevtest.c new file mode 100644 index 00000000000..8dbf0df461b --- /dev/null +++ b/progs/miniglx/glfbdevtest.c @@ -0,0 +1,478 @@ +/* $Id: glfbdevtest.c,v 1.1 2003-08-06 17:47:15 keithw Exp $ */ + +/* + * Test the GLFBDev interface. Only tested with radeonfb driver!!!! + */ + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "GL/glfbdev.h" + +#define DEFAULT_DEPTH 8 + +static struct fb_fix_screeninfo FixedInfo; +static struct fb_var_screeninfo VarInfo, OrigVarInfo; +static int DesiredDepth = 0; +static int OriginalVT = -1; +static int ConsoleFD = -1; +static int FrameBufferFD = -1; +static caddr_t FrameBuffer = (caddr_t) -1; +static caddr_t MMIOAddress = (caddr_t) -1; + + +static void +print_fixed_info(const struct fb_fix_screeninfo *fixed, const char *s) +{ + static const char *visuals[] = { + "MONO01", "MONO10", "TRUECOLOR", "PSEUDOCOLOR", + "DIRECTCOLOR", "STATIC_PSEUDOCOLOR" + }; + + printf("%s info -----------------------\n", s); + printf("id = %16s\n", fixed->id); + printf("smem_start = 0x%x\n", fixed->smem_start); + printf("smem_len = %d (0x%x)\n", fixed->smem_len, fixed->smem_len); + printf("type = 0x%x\n", fixed->type); + printf("type_aux = 0x%x\n", fixed->type_aux); + printf("visual = 0x%x (%s)\n", fixed->visual, visuals[fixed->visual]); + printf("xpanstep = %d\n", fixed->xpanstep); + printf("ypanstep = %d\n", fixed->ypanstep); + printf("ywrapstep = %d\n", fixed->ywrapstep); + printf("line_length = %d\n", fixed->line_length); + printf("mmio_start = 0x%x\n", fixed->mmio_start); + printf("mmio_len = %d (0x%x)\n", fixed->mmio_len, fixed->mmio_len); + printf("accel = 0x%x\n", fixed->accel); +} + + +static void +print_var_info(const struct fb_var_screeninfo *var, const char *s) +{ + printf("%s info -----------------------\n", s); + printf("xres = %d\n", var->xres); + printf("yres = %d\n", var->yres); + printf("xres_virtual = %d\n", var->xres_virtual); + printf("yres_virtual = %d\n", var->yres_virtual); + printf("xoffset = %d\n", var->xoffset); + printf("yoffset = %d\n", var->yoffset); + printf("bits_per_pixel = %d\n", var->bits_per_pixel); + printf("grayscale = %d\n", var->grayscale); + + printf("red.offset = %d length = %d msb_right = %d\n", + var->red.offset, var->red.length, var->red.msb_right); + printf("green.offset = %d length = %d msb_right = %d\n", + var->green.offset, var->green.length, var->green.msb_right); + printf("blue.offset = %d length = %d msb_right = %d\n", + var->blue.offset, var->blue.length, var->blue.msb_right); + printf("transp.offset = %d length = %d msb_right = %d\n", + var->transp.offset, var->transp.length, var->transp.msb_right); + + printf("nonstd = %d\n", var->nonstd); + printf("activate = %d\n", var->activate); + printf("height = %d mm\n", var->height); + printf("width = %d mm\n", var->width); + printf("accel_flags = 0x%x\n", var->accel_flags); + printf("pixclock = %d\n", var->pixclock); + printf("left_margin = %d\n", var->left_margin); + printf("right_margin = %d\n", var->right_margin); + printf("upper_margin = %d\n", var->upper_margin); + printf("lower_margin = %d\n", var->lower_margin); + printf("hsync_len = %d\n", var->hsync_len); + printf("vsync_len = %d\n", var->vsync_len); + printf("sync = %d\n", var->sync); + printf("vmode = %d\n", var->vmode); +} + + +static void +signal_handler(int signumber) +{ + signal(signumber, SIG_IGN); /* prevent recursion! */ + fprintf(stderr, "error: got signal %d (exiting)\n", signumber); + exit(1); +} + + +static void +initialize_fbdev( void ) +{ + char ttystr[1000]; + int fd, vtnumber, ttyfd; + int sz; + + if (geteuid()) { + fprintf(stderr, "error: you need to be root\n"); + exit(1); + } + +#if 1 + /* open the framebuffer device */ + FrameBufferFD = open("/dev/fb0", O_RDWR); + if (FrameBufferFD < 0) { + fprintf(stderr, "Error opening /dev/fb0: %s\n", strerror(errno)); + exit(1); + } +#endif + + /* open /dev/tty0 and get the vt number */ + if ((fd = open("/dev/tty0", O_WRONLY, 0)) < 0) { + fprintf(stderr, "error opening /dev/tty0\n"); + exit(1); + } + if (ioctl(fd, VT_OPENQRY, &vtnumber) < 0 || vtnumber < 0) { + fprintf(stderr, "error: couldn't get a free vt\n"); + exit(1); + } + close(fd); + + /* open the console tty */ + sprintf(ttystr, "/dev/tty%d", vtnumber); /* /dev/tty1-64 */ + ConsoleFD = open(ttystr, O_RDWR | O_NDELAY, 0); + if (ConsoleFD < 0) { + fprintf(stderr, "error couldn't open console fd\n"); + exit(1); + } + + /* save current vt number */ + { + struct vt_stat vts; + if (ioctl(ConsoleFD, VT_GETSTATE, &vts) == 0) + OriginalVT = vts.v_active; + } + + /* disconnect from controlling tty */ + ttyfd = open("/dev/tty", O_RDWR); + if (ttyfd >= 0) { + ioctl(ttyfd, TIOCNOTTY, 0); + close(ttyfd); + } + + /* some magic to restore the vt when we exit */ + { + struct vt_mode vt; + if (ioctl(ConsoleFD, VT_ACTIVATE, vtnumber) != 0) + printf("ioctl VT_ACTIVATE: %s\n", strerror(errno)); + if (ioctl(ConsoleFD, VT_WAITACTIVE, vtnumber) != 0) + printf("ioctl VT_WAITACTIVE: %s\n", strerror(errno)); + + if (ioctl(ConsoleFD, VT_GETMODE, &vt) < 0) { + fprintf(stderr, "error: ioctl VT_GETMODE: %s\n", strerror(errno)); + exit(1); + } + + vt.mode = VT_PROCESS; + vt.relsig = SIGUSR1; + vt.acqsig = SIGUSR1; + if (ioctl(ConsoleFD, VT_SETMODE, &vt) < 0) { + fprintf(stderr, "error: ioctl(VT_SETMODE) failed: %s\n", + strerror(errno)); + exit(1); + } + } + + /* go into graphics mode */ + if (ioctl(ConsoleFD, KDSETMODE, KD_GRAPHICS) < 0) { + fprintf(stderr, "error: ioctl(KDSETMODE, KD_GRAPHICS) failed: %s\n", + strerror(errno)); + exit(1); + } + + +#if 0 + /* open the framebuffer device */ + FrameBufferFD = open("/dev/fb0", O_RDWR); + if (FrameBufferFD < 0) { + fprintf(stderr, "Error opening /dev/fb0: %s\n", strerror(errno)); + exit(1); + } +#endif + + /* Get the fixed screen info */ + if (ioctl(FrameBufferFD, FBIOGET_FSCREENINFO, &FixedInfo)) { + fprintf(stderr, "error: ioctl(FBIOGET_FSCREENINFO) failed: %s\n", + strerror(errno)); + exit(1); + } + + print_fixed_info(&FixedInfo, "Fixed"); + + + /* get the variable screen info */ + if (ioctl(FrameBufferFD, FBIOGET_VSCREENINFO, &OrigVarInfo)) { + fprintf(stderr, "error: ioctl(FBIOGET_VSCREENINFO) failed: %s\n", + strerror(errno)); + exit(1); + } + + print_var_info(&OrigVarInfo, "Orig Var"); + + /* operate on a copy */ + VarInfo = OrigVarInfo; + + /* set the depth, resolution, etc */ + DesiredDepth = 32; + if (DesiredDepth) + VarInfo.bits_per_pixel = DesiredDepth; + + if (VarInfo.bits_per_pixel == 16) { + VarInfo.red.offset = 11; + VarInfo.green.offset = 5; + VarInfo.blue.offset = 0; + VarInfo.red.length = 5; + VarInfo.green.length = 6; + VarInfo.blue.length = 5; + VarInfo.transp.offset = 0; + VarInfo.transp.length = 0; + } + else if (VarInfo.bits_per_pixel == 32) { + VarInfo.red.offset = 16; + VarInfo.green.offset = 8; + VarInfo.blue.offset = 0; + VarInfo.transp.offset = 24; + VarInfo.red.length = 8; + VarInfo.green.length = 8; + VarInfo.blue.length = 8; + VarInfo.transp.length = 8; + } + /* timing values taken from /etc/fb.modes (1280x1024 @ 75Hz) */ + VarInfo.xres_virtual = VarInfo.xres = 1280; + VarInfo.yres_virtual = VarInfo.yres = 1024; + VarInfo.pixclock = 7408; + VarInfo.left_margin = 248; + VarInfo.right_margin = 16; + VarInfo.upper_margin = 38; + VarInfo.lower_margin = 1; + VarInfo.hsync_len = 144; + VarInfo.vsync_len = 3; + + VarInfo.xoffset = 0; + VarInfo.yoffset = 0; + VarInfo.nonstd = 0; + VarInfo.vmode &= ~FB_VMODE_YWRAP; /* turn off scrolling */ + + /* set new variable screen info */ + if (ioctl(FrameBufferFD, FBIOPUT_VSCREENINFO, &VarInfo)) { + fprintf(stderr, "ioctl(FBIOPUT_VSCREENINFO failed): %s\n", + strerror(errno)); + exit(1); + } + + print_var_info(&VarInfo, "New Var"); + + if (FixedInfo.visual != FB_VISUAL_TRUECOLOR && + FixedInfo.visual != FB_VISUAL_DIRECTCOLOR) { + fprintf(stderr, "non-TRUE/DIRECT-COLOR visuals (0x%x) not supported by this demo.\n", FixedInfo.visual); + exit(1); + } + + /* initialize colormap */ + if (FixedInfo.visual == FB_VISUAL_DIRECTCOLOR) { + struct fb_cmap cmap; + unsigned short red[256], green[256], blue[256]; + int i; + + /* we're assuming 256 entries here */ + printf("initializing directcolor colormap\n"); + cmap.start = 0; + cmap.len = 256; + cmap.red = red; + cmap.green = green; + cmap.blue = blue; + cmap.transp = NULL; + for (i = 0; i < cmap.len; i++) { + red[i] = green[i] = blue[i] = (i << 8) | i; + } + if (ioctl(FrameBufferFD, FBIOPUTCMAP, (void *) &cmap) < 0) { + fprintf(stderr, "ioctl(FBIOPUTCMAP) failed [%d]\n", i); + } + } + + /* + * fbdev says the frame buffer is at offset zero, and the mmio region + * is immediately after. + */ + + /* mmap the framebuffer into our address space */ + FrameBuffer = (caddr_t) mmap(0, /* start */ + FixedInfo.smem_len, /* bytes */ + PROT_READ | PROT_WRITE, /* prot */ + MAP_SHARED, /* flags */ + FrameBufferFD, /* fd */ + 0 /* offset */); + if (FrameBuffer == (caddr_t) - 1) { + fprintf(stderr, "error: unable to mmap framebuffer: %s\n", + strerror(errno)); + exit(1); + } + printf("FrameBuffer = %p\n", FrameBuffer); + +#if 1 + /* mmap the MMIO region into our address space */ + MMIOAddress = (caddr_t) mmap(0, /* start */ + FixedInfo.mmio_len, /* bytes */ + PROT_READ | PROT_WRITE, /* prot */ + MAP_SHARED, /* flags */ + FrameBufferFD, /* fd */ + FixedInfo.smem_len /* offset */); + if (MMIOAddress == (caddr_t) - 1) { + fprintf(stderr, "error: unable to mmap mmio region: %s\n", + strerror(errno)); + } + printf("MMIOAddress = %p\n", MMIOAddress); + + /* try out some simple MMIO register reads */ + if (1) + { + typedef unsigned int CARD32; + typedef unsigned char CARD8; +#define RADEON_CONFIG_MEMSIZE 0x00f8 +#define RADEON_MEM_SDRAM_MODE_REG 0x0158 +#define MMIO_IN32(base, offset) \ + *(volatile CARD32 *)(void *)(((CARD8*)(base)) + (offset)) +#define INREG(addr) MMIO_IN32(MMIOAddress, addr) + int sz, type; + const char *typeStr[] = {"SDR", "DDR", "64-bit SDR"}; + sz = INREG(RADEON_CONFIG_MEMSIZE); + type = INREG(RADEON_MEM_SDRAM_MODE_REG); + printf("RADEON_CONFIG_MEMSIZE = %d (%d MB)\n", sz, sz / 1024 / 1024); + printf("RADEON_MEM_SDRAM_MODE_REG >> 30 = %d (%s)\n", + type >> 30, typeStr[type>>30]); + } +#endif + +} + + +static void +shutdown_fbdev( void ) +{ + struct vt_mode VT; + + printf("cleaning up...\n"); + /* restore original variable screen info */ + if (ioctl(FrameBufferFD, FBIOPUT_VSCREENINFO, &OrigVarInfo)) { + fprintf(stderr, "ioctl(FBIOPUT_VSCREENINFO failed): %s\n", + strerror(errno)); + exit(1); + } + + munmap(MMIOAddress, FixedInfo.mmio_len); + munmap(FrameBuffer, FixedInfo.smem_len); + close(FrameBufferFD); + + /* restore text mode */ + ioctl(ConsoleFD, KDSETMODE, KD_TEXT); + + /* set vt */ + if (ioctl(ConsoleFD, VT_GETMODE, &VT) != -1) { + VT.mode = VT_AUTO; + ioctl(ConsoleFD, VT_SETMODE, &VT); + } + + /* restore original vt */ + if (OriginalVT >= 0) { + ioctl(ConsoleFD, VT_ACTIVATE, OriginalVT); + OriginalVT = -1; + } + + close(ConsoleFD); +} + + +static void +gltest( void ) +{ + static const int attribs[] = { + GLFBDEV_DOUBLE_BUFFER, + GLFBDEV_DEPTH_SIZE, 16, + GLFBDEV_NONE + }; + GLFBDevContextPtr ctx; + GLFBDevBufferPtr buf; + GLFBDevVisualPtr vis; + int bytes, r, g, b, a; + float ang; + + printf("GLFBDEV_VENDOR = %s\n", glFBDevGetString(GLFBDEV_VENDOR)); + printf("GLFBDEV_VERSION = %s\n", glFBDevGetString(GLFBDEV_VERSION)); + + /* framebuffer size */ + bytes = VarInfo.xres_virtual * VarInfo.yres_virtual * VarInfo.bits_per_pixel / 8; + + vis = glFBDevCreateVisual( &FixedInfo, &VarInfo, attribs ); + assert(vis); + + buf = glFBDevCreateBuffer( &FixedInfo, &VarInfo, vis, FrameBuffer, NULL, bytes ); + assert(buf); + + ctx = glFBDevCreateContext( vis, NULL ); + assert(buf); + + b = glFBDevMakeCurrent( ctx, buf, buf ); + assert(b); + + /*printf("GL_EXTENSIONS: %s\n", glGetString(GL_EXTENSIONS));*/ + glGetIntegerv(GL_RED_BITS, &r); + glGetIntegerv(GL_GREEN_BITS, &g); + glGetIntegerv(GL_BLUE_BITS, &b); + glGetIntegerv(GL_ALPHA_BITS, &a); + printf("RED_BITS=%d GREEN_BITS=%d BLUE_BITS=%d ALPHA_BITS=%d\n", + r, g, b, a); + + glClearColor(0.5, 0.5, 1.0, 0); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glFrustum(-1, 1, -1, 1, 2, 30); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTranslatef(0, 0, -15); + glViewport(0, 0, VarInfo.xres_virtual, VarInfo.yres_virtual); + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + glEnable(GL_DEPTH_TEST); + + for (ang = 0; ang <= 180; ang += 15) { + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glPushMatrix(); + glRotatef(ang, 1, 0, 0); + glutSolidTorus(1, 3, 40, 20); + glPopMatrix(); + glFBDevSwapBuffers(buf); + } + + /* clean up */ + b = glFBDevMakeCurrent( NULL, NULL, NULL); + assert(b); + + glFBDevDestroyContext(ctx); + glFBDevDestroyBuffer(buf); + glFBDevDestroyVisual(vis); +} + + +int +main( int argc, char *argv[] ) +{ + signal(SIGUSR1, signal_handler); /* exit if someone tries a vt switch */ + signal(SIGSEGV, signal_handler); /* catch segfaults */ + + initialize_fbdev(); + gltest(); + shutdown_fbdev(); + + return 0; +} diff --git a/progs/miniglx/manytex.c b/progs/miniglx/manytex.c new file mode 100644 index 00000000000..3ba89d499e4 --- /dev/null +++ b/progs/miniglx/manytex.c @@ -0,0 +1,382 @@ +/* $Id: manytex.c,v 1.2 2003-08-23 01:28:59 jonsmirl Exp $ */ + +/* + * test handling of many texture maps + * Also tests texture priority and residency. + * + * Brian Paul + * August 2, 2000 + */ + + +#include +#include +#include +#include +#include +#include + + +static GLint NumTextures = 20; +static GLuint *TextureID = NULL; +static GLint *TextureWidth = NULL, *TextureHeight = NULL; +static GLboolean *TextureResidency = NULL; +static GLint TexWidth = 128, TexHeight = 128; +static GLfloat Zrot = 0; +static GLboolean Anim = GL_TRUE; +static GLint WinWidth = 500, WinHeight = 400; +static GLboolean MipMap = GL_FALSE; +static GLboolean LinearFilter = GL_FALSE; +static GLboolean RandomSize = GL_FALSE; +static GLint Rows, Columns; +static GLint LowPriorityCount = 0; + + +static void Idle( void ) +{ + Zrot += 1.0; + glutPostRedisplay(); +} + + +static void Display( void ) +{ + GLfloat spacing = WinWidth / Columns; + GLfloat size = spacing * 0.4; + GLint i; + + /* test residency */ + if (0) + { + GLboolean b; + GLint i, resident; + b = glAreTexturesResident(NumTextures, TextureID, TextureResidency); + if (b) { + printf("all resident\n"); + } + else { + resident = 0; + for (i = 0; i < NumTextures; i++) { + if (TextureResidency[i]) { + resident++; + } + } + printf("%d of %d texture resident\n", resident, NumTextures); + } + } + + /* render the textured quads */ + glClear( GL_COLOR_BUFFER_BIT ); + for (i = 0; i < NumTextures; i++) { + GLint row = i / Columns; + GLint col = i % Columns; + GLfloat x = col * spacing + spacing * 0.5; + GLfloat y = row * spacing + spacing * 0.5; + + GLfloat maxDim = (TextureWidth[i] > TextureHeight[i]) + ? TextureWidth[i] : TextureHeight[i]; + GLfloat w = TextureWidth[i] / maxDim; + GLfloat h = TextureHeight[i] / maxDim; + + glPushMatrix(); + glTranslatef(x, y, 0.0); + glRotatef(Zrot, 0, 0, 1); + glScalef(size, size, 1); + + glBindTexture(GL_TEXTURE_2D, TextureID[i]); + glBegin(GL_POLYGON); +#if 0 + glTexCoord2f(0, 0); glVertex2f(-1, -1); + glTexCoord2f(1, 0); glVertex2f( 1, -1); + glTexCoord2f(1, 1); glVertex2f( 1, 1); + glTexCoord2f(0, 1); glVertex2f(-1, 1); +#else + glTexCoord2f(0, 0); glVertex2f(-w, -h); + glTexCoord2f(1, 0); glVertex2f( w, -h); + glTexCoord2f(1, 1); glVertex2f( w, h); + glTexCoord2f(0, 1); glVertex2f(-w, h); +#endif + glEnd(); + glPopMatrix(); + } + + glutSwapBuffers(); +} + + +static void Reshape( int width, int height ) +{ + WinWidth = width; + WinHeight = height; + glViewport( 0, 0, width, height ); + glMatrixMode( GL_PROJECTION ); + glLoadIdentity(); + glOrtho(0, width, 0, height, -1, 1); + glMatrixMode( GL_MODELVIEW ); + glLoadIdentity(); +} + + +/* + * Return a random int in [min, max]. + */ +static int RandomInt(int min, int max) +{ + int i = rand(); + int j = i % (max - min + 1); + return min + j; +} + + + +static void Init( void ) +{ + GLint i; + + if (RandomSize) { + printf("Creating %d %s random-size textures, ", NumTextures, + MipMap ? "Mipmapped" : "non-Mipmapped"); + } + else { + printf("Creating %d %s %d x %d textures, ", NumTextures, + MipMap ? "Mipmapped" : "non-Mipmapped", + TexWidth, TexHeight); + } + + if (LinearFilter) { + printf("bilinear filtering\n"); + } + else { + printf("nearest filtering\n"); + } + + + /* compute number of rows and columns of rects */ + { + GLfloat area = (GLfloat) (WinWidth * WinHeight) / (GLfloat) NumTextures; + GLfloat edgeLen = sqrt(area); + + Columns = WinWidth / edgeLen; + Rows = (NumTextures + Columns - 1) / Columns; + printf("Rows: %d Cols: %d\n", Rows, Columns); + } + + + if (!TextureID) { + TextureID = (GLuint *) malloc(sizeof(GLuint) * NumTextures); + assert(TextureID); + glGenTextures(NumTextures, TextureID); + } + + if (!TextureResidency) { + TextureResidency = (GLboolean *) malloc(sizeof(GLboolean) * NumTextures); + assert(TextureResidency); + } + + if (!TextureWidth) { + TextureWidth = (GLint *) malloc(sizeof(GLint) * NumTextures); + assert(TextureWidth); + } + if (!TextureHeight) { + TextureHeight = (GLint *) malloc(sizeof(GLint) * NumTextures); + assert(TextureHeight); + } + + for (i = 0; i < NumTextures; i++) { + GLubyte color[4]; + GLubyte *texImage; + GLint j, row, col; + + row = i / Columns; + col = i % Columns; + + glBindTexture(GL_TEXTURE_2D, TextureID[i]); + + if (i < LowPriorityCount) + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_PRIORITY, 0.5F); + + if (RandomSize) { +#if 0 + int k = (glutGet(GLUT_ELAPSED_TIME) % 7) + 2; + TexWidth = 1 << k; + TexHeight = 1 << k; +#else + TexWidth = 1 << RandomInt(2, 7); + TexHeight = 1 << RandomInt(2, 7); + printf("Random size of %3d: %d x %d\n", i, TexWidth, TexHeight); +#endif + } + + TextureWidth[i] = TexWidth; + TextureHeight[i] = TexHeight; + + texImage = (GLubyte*) malloc(4 * TexWidth * TexHeight * sizeof(GLubyte)); + assert(texImage); + + /* determine texture color */ + color[0] = (GLint) (255.0 * ((float) col / (Columns - 1))); + color[1] = 127; + color[2] = (GLint) (255.0 * ((float) row / (Rows - 1))); + color[3] = 255; + + /* fill in solid-colored teximage */ + for (j = 0; j < TexWidth * TexHeight; j++) { + texImage[j*4+0] = color[0]; + texImage[j*4+1] = color[1]; + texImage[j*4+2] = color[2]; + texImage[j*4+3] = color[3]; + } + + if (MipMap) { + GLint level = 0; + GLint w = TexWidth, h = TexHeight; + while (1) { + glTexImage2D(GL_TEXTURE_2D, level, GL_RGBA, w, h, 0, + GL_RGBA, GL_UNSIGNED_BYTE, texImage); + if (w == 1 && h == 1) + break; + if (w > 1) + w /= 2; + if (h > 1) + h /= 2; + level++; + /*printf("%d: %d x %d\n", level, w, h);*/ + } + if (LinearFilter) { + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, + GL_LINEAR_MIPMAP_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + } + else { + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, + GL_NEAREST_MIPMAP_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + } + } + else { + /* Set corners to white */ + int k = 0; + texImage[k+0] = texImage[k+1] = texImage[k+2] = texImage[k+3] = 255; + k = (TexWidth - 1) * 4; + texImage[k+0] = texImage[k+1] = texImage[k+2] = texImage[k+3] = 255; + k = (TexWidth * TexHeight - TexWidth) * 4; + texImage[k+0] = texImage[k+1] = texImage[k+2] = texImage[k+3] = 255; + k = (TexWidth * TexHeight - 1) * 4; + texImage[k+0] = texImage[k+1] = texImage[k+2] = texImage[k+3] = 255; + + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, TexWidth, TexHeight, 0, + GL_RGBA, GL_UNSIGNED_BYTE, texImage); + if (LinearFilter) { + 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); + } + } + + free(texImage); + } + + glEnable(GL_TEXTURE_2D); +} + + +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 's': + Idle(); + break; + case 'z': + Zrot -= step; + break; + case 'Z': + Zrot += step; + break; + case ' ': + Init(); + break; + case 27: + exit(0); + break; + } + glutPostRedisplay(); +} + + +int main( int argc, char *argv[] ) +{ + GLint i; + + glutInit( &argc, argv ); + glutInitWindowPosition( 0, 0 ); + glutInitWindowSize( WinWidth, WinHeight ); + glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE ); + glutCreateWindow(argv[0]); + glutReshapeFunc( Reshape ); + glutKeyboardFunc( Key ); + glutDisplayFunc( Display ); + if (Anim) + glutIdleFunc(Idle); + + for (i = 1; i < argc; i++) { + if (strcmp(argv[i], "-n") == 0) { + NumTextures = atoi(argv[i+1]); + if (NumTextures <= 0) { + printf("Error, bad number of textures\n"); + return 1; + } + i++; + } + else if (strcmp(argv[i], "-mipmap") == 0) { + MipMap = GL_TRUE; + } + else if (strcmp(argv[i], "-linear") == 0) { + LinearFilter = GL_TRUE; + } + else if (strcmp(argv[i], "-size") == 0) { + TexWidth = atoi(argv[i+1]); + TexHeight = atoi(argv[i+2]); + assert(TexWidth >= 1); + assert(TexHeight >= 1); + i += 2; + } + else if (strcmp(argv[i], "-randomsize") == 0) { + RandomSize = GL_TRUE; + } + else if (strcmp(argv[i], "-lowpri") == 0) { + LowPriorityCount = atoi(argv[i+1]); + i++; + } + else { + printf("Usage:\n"); + printf(" manytex [options]\n"); + printf("Options:\n"); + printf(" -n \n"); + printf(" -size - specify texture size\n"); + printf(" -randomsize - use random size textures\n"); + printf(" -mipmap - generate mipmaps\n"); + printf(" -linear - use linear filtering instead of nearest\n"); + printf(" -lowpri - Set lower priority on textures\n"); + return 0; + } + } + + Init(); + + glutMainLoop(); + + return 0; +} diff --git a/progs/miniglx/miniglxsample.c b/progs/miniglx/miniglxsample.c new file mode 100644 index 00000000000..d4d6729f932 --- /dev/null +++ b/progs/miniglx/miniglxsample.c @@ -0,0 +1,128 @@ + +#define USE_MINIGLX 1 /* 1 = use Mini GLX, 0 = use Xlib/GLX */ + +#include +#include +#include +#include + +#if USE_MINIGLX +#include +#else +#include +#include +#endif + +static void _subset_Rectf( GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2 ) +{ + glBegin( GL_QUADS ); + glVertex2f( x1, y1 ); + glVertex2f( x2, y1 ); + glVertex2f( x2, y2 ); + glVertex2f( x1, y2 ); + glEnd(); +} + + +/* + * Create a simple double-buffered RGBA window. + */ +static Window +MakeWindow(Display * dpy, unsigned int width, unsigned int height) +{ + int visAttributes[] = { + GLX_RGBA, + GLX_RED_SIZE, 1, + GLX_GREEN_SIZE, 1, + GLX_BLUE_SIZE, 1, + GLX_DOUBLEBUFFER, + None + }; + XSetWindowAttributes attr; + unsigned long attrMask; + Window root; + Window win; + GLXContext ctx; + XVisualInfo *visinfo; + + root = RootWindow(dpy, 0); + + /* Choose GLX visual / pixel format */ + visinfo = glXChooseVisual(dpy, 0, visAttributes); + if (!visinfo) { + printf("Error: couldn't get an RGB, Double-buffered visual\n"); + exit(1); + } + + /* Create the window */ + attr.background_pixel = 0; + attr.border_pixel = 0; + attr.colormap = XCreateColormap(dpy, root, visinfo->visual, AllocNone); + attrMask = CWBackPixel | CWBorderPixel | CWColormap; + win = XCreateWindow(dpy, root, 0, 0, width, height, + 0, visinfo->depth, InputOutput, + visinfo->visual, attrMask, &attr); + if (!win) { + printf("Error: XCreateWindow failed\n"); + exit(1); + } + + /* Display the window */ + XMapWindow(dpy, win); + + /* Create GLX rendering context */ + ctx = glXCreateContext(dpy, visinfo, NULL, True); + if (!ctx) { + printf("Error: glXCreateContext failed\n"); + exit(1); + } + + /* Bind the rendering context and window */ + glXMakeCurrent(dpy, win, ctx); + + glViewport(0, 0, width, height); + + return win; +} + + +/* + * Draw a few frames of a rotating square. + */ +static void +DrawFrames(Display * dpy, Window win) +{ + int angle; + glShadeModel(GL_FLAT); + glClearColor(0.5, 0.5, 0.5, 1.0); + for (angle = 0; angle < 360; angle += 10) { + glClear(GL_COLOR_BUFFER_BIT); + glColor3f(1.0, 1.0, 0.0); + glPushMatrix(); + glRotatef(angle, 0, 0, 1); + _subset_Rectf(-0.8, -0.8, 0.8, 0.8); + glPopMatrix(); + glXSwapBuffers(dpy, win); + sleep(1); + } +} + + +int +main(int argc, char *argv[]) +{ + Display *dpy; + Window win; + + dpy = XOpenDisplay(NULL); + if (!dpy) { + printf("Error: XOpenDisplay failed\n"); + return 1; + } + + win = MakeWindow(dpy, 300, 300); + + DrawFrames(dpy, win); + + return 0; +} diff --git a/progs/miniglx/miniglxtest.c b/progs/miniglx/miniglxtest.c new file mode 100644 index 00000000000..25e4c59104d --- /dev/null +++ b/progs/miniglx/miniglxtest.c @@ -0,0 +1,195 @@ +/* $Id: miniglxtest.c,v 1.3 2004-03-25 14:58:39 brianp Exp $ */ + +/* + * Test the mini GLX interface. + */ + + +#include +#include +#include +#include +#define USE_MINI_GLX 1 +#if USE_MINI_GLX +#include +#else +#include +#endif + +#define FRONTBUFFER 1 +#define NR 6 +#define DO_SLEEPS 1 +#define NR_DISPLAYS 2 + +GLXContext ctx; + + +static void _subset_Rectf( GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2 ) +{ + glBegin( GL_QUADS ); + glVertex2f( x1, y1 ); + glVertex2f( x2, y1 ); + glVertex2f( x2, y2 ); + glVertex2f( x1, y2 ); + glEnd(); +} + + + +static void redraw( Display *dpy, Window w, int rot ) +{ + printf("Redraw event\n"); + +#if FRONTBUFFER + glDrawBuffer( GL_FRONT ); +#else +/* glDrawBuffer( GL_BACK ); */ +#endif + + glClearColor( rand()/(float)RAND_MAX, + rand()/(float)RAND_MAX, + rand()/(float)RAND_MAX, + 1); + + glClear( GL_COLOR_BUFFER_BIT ); + +#if 1 + glColor3f( rand()/(float)RAND_MAX, + rand()/(float)RAND_MAX, + rand()/(float)RAND_MAX ); + glPushMatrix(); + glRotatef(rot, 0, 0, 1); + glScalef(.5, .5, .5); + _subset_Rectf( -1, -1, 1, 1 ); + glPopMatrix(); +#endif + +#if FRONTBUFFER + glFlush(); +#else + glXSwapBuffers( dpy, w ); +#endif + glFinish(); +} + + +static Window make_rgb_db_window( Display *dpy, + unsigned int width, unsigned int height ) +{ + int attrib[] = { GLX_RGBA, + GLX_RED_SIZE, 1, + GLX_GREEN_SIZE, 1, + GLX_BLUE_SIZE, 1, +#if !FRONTBUFFER + GLX_DOUBLEBUFFER, +#endif + None }; + int scrnum; + XSetWindowAttributes attr; + unsigned long mask; + Window root; + Window win; + XVisualInfo *visinfo; + + scrnum = 0; + root = RootWindow( dpy, scrnum ); + + if (!(visinfo = glXChooseVisual( dpy, scrnum, attrib ))) { + printf("Error: couldn't get an RGB, Double-buffered visual\n"); + exit(1); + } + + if(!(ctx = glXCreateContext( dpy, visinfo, NULL, True ))) { + printf("Error: glXCreateContext failed\n"); + exit(1); + } + + /* window attributes */ + attr.background_pixel = 0; + attr.border_pixel = 0; + 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 ); + if (!win) { + printf("Error: XCreateWindow failed\n"); + exit(1); + } + + glXMakeCurrent( dpy, win, ctx ); + + glViewport(0, 0, width, height); + + return win; +} + + +static void event_loop( Display *dpy, Window win ) +{ + int i; + + printf("Hang on... drawing %d frames\n", NR); + for (i = 0; i < NR; i++) { + redraw( dpy, win, i*10 ); + if (DO_SLEEPS) { + printf("sleep(1)\n"); + sleep(1); + } + } +} + + +static int foo( void ) +{ + Display *dpy; + Window win; + + dpy = XOpenDisplay(NULL); + if (!dpy) { + printf("Error: XOpenDisplay failed\n"); + return 1; + } + + win = make_rgb_db_window( dpy, 800, 600); + + srand(getpid()); + + glShadeModel( GL_FLAT ); + glClearColor( 0.5, 0.5, 0.5, 1.0 ); + + XMapWindow( dpy, win ); + + { + XEvent e; + while (1) { + XNextEvent( dpy, &e ); + if (e.type == MapNotify && e.xmap.window == win) { + break; + } + } + } + + event_loop( dpy, win ); + + glXDestroyContext( dpy, ctx ); + XDestroyWindow( dpy, win ); + + XCloseDisplay( dpy ); + + return 0; +} + + +int main() +{ + int i; + for (i = 0 ; i < NR_DISPLAYS ; i++) { + if (foo() != 0) + break; + } + + return 0; +} diff --git a/progs/miniglx/sample_server.c b/progs/miniglx/sample_server.c new file mode 100644 index 00000000000..cac6e3b8345 --- /dev/null +++ b/progs/miniglx/sample_server.c @@ -0,0 +1,112 @@ +/* $Id: sample_server.c,v 1.1 2003-08-06 17:47:15 keithw Exp $ */ + +/* + * Sample server that just keeps first available window mapped. + */ + + +#include +#include +#include +#include + +struct client { + struct client *next; + Window windowid; + int mappable; +}; + +struct client *clients = 0, *mapped_client = 0; + + +static struct client *find_client( Window id ) +{ + struct client *c; + + for (c = clients ; c ; c = c->next) + if (c->windowid == id) + return c; + + return 0; +} + +int main( int argc, char *argv[] ) +{ + Display *dpy; + XEvent ev; + + dpy = __miniglx_StartServer(NULL); + if (!dpy) { + fprintf(stderr, "Error: __miniglx_StartServer failed\n"); + return 1; + } + + while (XNextEvent( dpy, &ev )) { + struct client *c; + + switch (ev.type) { + case MapRequest: + fprintf(stderr, "MapRequest\n"); + c = find_client(ev.xmaprequest.window); + if (!c) break; + c->mappable = True; + break; + + case UnmapNotify: + fprintf(stderr, "UnmapNotify\n"); + c = find_client(ev.xunmap.window); + if (!c) break; + c->mappable = False; + if (c == mapped_client) + mapped_client = 0; + break; + + case CreateNotify: + fprintf(stderr, "CreateNotify\n"); + c = malloc(sizeof(*c)); + c->next = clients; + c->windowid = ev.xcreatewindow.window; + c->mappable = False; + clients = c; + break; + + case DestroyNotify: + fprintf(stderr, "DestroyNotify\n"); + c = find_client(ev.xdestroywindow.window); + if (!c) break; + if (c == clients) + clients = c->next; + else { + struct client *t; + for (t = clients ; t->next != c ; t = t->next) + ; + t->next = c->next; + } + + if (c == mapped_client) + mapped_client = 0; + + free(c); + break; + + default: + break; + } + + /* Search for first mappable client if none already mapped. + */ + if (!mapped_client) { + for (c = clients ; c ; c = c->next) { + if (c->mappable) { + XMapWindow( dpy, c->windowid ); + mapped_client = c; + break; + } + } + } + } + + XCloseDisplay( dpy ); + + return 0; +} diff --git a/progs/miniglx/sample_server2.c b/progs/miniglx/sample_server2.c new file mode 100644 index 00000000000..109677ba969 --- /dev/null +++ b/progs/miniglx/sample_server2.c @@ -0,0 +1,229 @@ +/* $Id: sample_server2.c,v 1.2 2003-08-23 01:28:59 jonsmirl Exp $ */ + +/* + * Sample server that just keeps first available window mapped. + * + * It also reads and echos anything that happens on stdin as an + * example of tracking events from sources other than miniglx clients. + * + * It reads & writes without blocking, so that eg. piping a lot of + * text to stdin and then hitting 'ctrl-S' on the output stream won't + * cause it to stop handling miniglx events. + * + * See select_tut in the linux manual pages for a good overview of the + * select(2) system call. + */ + + +#include +#include +#include +#include +#include +#include +#include +#include + +struct client { + struct client *next; + Window windowid; + int mappable; +}; + +struct client *clients = 0, *mapped_client = 0; + +#define BUFSZ 4096 +char rbuf[BUFSZ]; +int rbuf_count; + + +static struct client *find_client( Window id ) +{ + struct client *c; + + for (c = clients ; c ; c = c->next) + if (c->windowid == id) + return c; + + return 0; +} + +int main( int argc, char *argv[] ) +{ + Display *dpy; + XEvent ev; + int autostart = 0; + + if (argc == 2 && strcmp(argv[1], "-autostart") == 0) + autostart = 1; + + dpy = __miniglx_StartServer(NULL); + if (!dpy) { + fprintf(stderr, "Error: __miniglx_StartServer failed\n"); + return 1; + } + + /* How is vt switching communicated through the XNextEvent interface? + */ + while (1) { + int r, n; + struct timeval tv; + fd_set rfds, wfds; + int bored = 0; + + FD_ZERO(&rfds); + FD_ZERO(&wfds); + tv.tv_sec = 1; + tv.tv_usec = 0; + + if (rbuf_count) { + FD_SET( 1, &wfds ); /* notify when we can write out buffer */ + n = 1; + } + else { + FD_SET( 0, &rfds ); /* else notify when new data to read */ + n = 0; + } + + /* __miniglx_Select waits until any of these file groups becomes + * readable/writable/etc (like regular select), until timeout + * expires (like regular select), until a signal is received + * (like regular select) or until an event is available for + * XCheckMaskEvent(). + */ + r = __miniglx_Select( dpy, n+1, &rfds, &wfds, 0, &tv ); + + /* This can happen if select() is interrupted by a signal: + */ + if (r < 0 && errno != EINTR && errno != EAGAIN) { + perror ("select()"); + exit (1); + } + + if (tv.tv_sec == 0 && tv.tv_usec == 0) + bored = 1; + + /* Check and handle events on our local file descriptors + */ + if (FD_ISSET( 0, &rfds )) { + /* Something on stdin */ + assert(rbuf_count == 0); + r = read(0, rbuf, BUFSZ); + if (r < 1) { + perror("read"); + abort(); + } + rbuf_count = r; + } + + if (FD_ISSET( 1, &wfds )) { + /* Can write to stdout */ + assert(rbuf_count > 0); + r = write(1, rbuf, rbuf_count); + if (r < 1) { + perror("write"); + abort(); + } + rbuf_count -= r; + if (rbuf_count) + memmove(rbuf + r, rbuf, rbuf_count); + } + + + /* Check and handle events generated by miniglx: + */ + while (XCheckMaskEvent( dpy, ~0, &ev )) { + struct client *c; + bored = 0; + + fprintf(stderr, "Received event %d\n", ev.type); + + switch (ev.type) { + case CreateNotify: + fprintf(stderr, "CreateNotify -- new client\n"); + c = malloc(sizeof(*c)); + c->next = clients; + c->windowid = ev.xcreatewindow.window; + c->mappable = False; + clients = c; + break; + + case DestroyNotify: + fprintf(stderr, "DestroyNotify\n"); + c = find_client(ev.xdestroywindow.window); + if (!c) break; + if (c == clients) + clients = c->next; + else { + struct client *t; + for (t = clients ; t->next != c ; t = t->next) + ; + t->next = c->next; + } + + if (c == mapped_client) + mapped_client = 0; + + free(c); + break; + + case MapRequest: + fprintf(stderr, "MapRequest\n"); + c = find_client(ev.xmaprequest.window); + if (!c) break; + c->mappable = True; + break; + + case UnmapNotify: + fprintf(stderr, "UnmapNotify\n"); + c = find_client(ev.xunmap.window); + if (!c) break; + c->mappable = False; + if (c == mapped_client) + mapped_client = 0; + break; + + default: + break; + } + } + + + /* Search for first mappable client if none already mapped. + */ + if (!mapped_client) { + struct client *c; + for (c = clients ; c ; c = c->next) { + if (c->mappable) { + XMapWindow( dpy, c->windowid ); + mapped_client = c; + break; + } + } + if (!clients && autostart) { + system("nohup ./texline &"); + system("nohup ./manytex &"); + } + } + else if (bored) { + struct client *c; + /* bored of mapped client now, let's try & find another one */ + for (c = mapped_client->next ; c && !c->mappable ; c = c->next) + ; + if (!c) + for (c = clients ; c && !c->mappable ; c = c->next) + ; + if (c && c != mapped_client) { + XUnmapWindow( dpy, mapped_client->windowid ); + XMapWindow( dpy, c->windowid ); + mapped_client = c; + } + else + fprintf(stderr, "I'm bored!\n"); + } + } + + XCloseDisplay( dpy ); + + return 0; +} diff --git a/progs/miniglx/texline.c b/progs/miniglx/texline.c new file mode 100644 index 00000000000..3cc22fdf3f4 --- /dev/null +++ b/progs/miniglx/texline.c @@ -0,0 +1,268 @@ +/* $Id: texline.c,v 1.1 2003-08-06 17:47:15 keithw Exp $ */ + +/* + * Test textured lines. + * + * Brian Paul + * September 2000 + */ + + +#include +#include +#include +#include +#include "../util/readtex.c" /* I know, this is a hack. */ + +#define TEXTURE_FILE "../images/girl.rgb" + +static GLboolean Antialias = GL_FALSE; +static GLboolean Animate = GL_FALSE; +static GLint Texture = 1; +static GLboolean Stipple = GL_FALSE; +static GLfloat LineWidth = 1.0; + +static GLfloat Xrot = -60.0, Yrot = 0.0, Zrot = 0.0; +static GLfloat DYrot = 1.0; +static GLboolean Points = GL_FALSE; +static GLfloat Scale = 1.0; + +static void Idle( void ) +{ + if (Animate) { + Zrot += DYrot; + glutPostRedisplay(); + } +} + + +static void Display( void ) +{ + GLfloat x, y, s, t; + + glClear( GL_COLOR_BUFFER_BIT ); + + glPushMatrix(); + glRotatef(Xrot, 1.0, 0.0, 0.0); + glRotatef(Yrot, 0.0, 1.0, 0.0); + glRotatef(Zrot, 0.0, 0.0, 1.0); + glScalef(Scale, Scale, Scale); + + if (Texture) + glColor3f(1, 1, 1); + + if (Points) { + glBegin(GL_POINTS); + for (t = 0.0; t <= 1.0; t += 0.025) { + for (s = 0.0; s <= 1.0; s += 0.025) { + x = s * 2.0 - 1.0; + y = t * 2.0 - 1.0; + if (!Texture) + glColor3f(1, 0, 1); + glMultiTexCoord2fARB(GL_TEXTURE1_ARB, t, s); + glTexCoord2f(s, t); + glVertex2f(x, y); + } + } + glEnd(); + } + else { + glBegin(GL_LINES); + for (t = 0.0; t <= 1.0; t += 0.025) { + x = t * 2.0 - 1.0; + if (!Texture) + glColor3f(1, 0, 1); + glTexCoord2f(t, 0.0); + glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.0, t); + glVertex2f(x, -1.0); + if (!Texture) + glColor3f(0, 1, 0); + glTexCoord2f(t, 1.0); + glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 1.0, t); + glVertex2f(x, 1.0); + } + glEnd(); + } + + glPopMatrix(); + + glutSwapBuffers(); +} + + +static void Reshape( int width, int height ) +{ + GLfloat ar = (float) width / height; + glViewport( 0, 0, width, height ); + glMatrixMode( GL_PROJECTION ); + glLoadIdentity(); + glFrustum( -ar, ar, -1.0, 1.0, 10.0, 100.0 ); + glMatrixMode( GL_MODELVIEW ); + glLoadIdentity(); + glTranslatef( 0.0, 0.0, -12.0 ); +} + + +static void Key( unsigned char key, int x, int y ) +{ + (void) x; + (void) y; + switch (key) { + case 'a': + Antialias = !Antialias; + if (Antialias) { + glEnable(GL_LINE_SMOOTH); + glEnable(GL_POINT_SMOOTH); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + } + else { + glDisable(GL_LINE_SMOOTH); + glDisable(GL_POINT_SMOOTH); + glDisable(GL_BLEND); + } + break; + case 't': + Texture++; + if (Texture > 2) + Texture = 0; + if (Texture == 0) { + glActiveTextureARB(GL_TEXTURE0_ARB); + glDisable(GL_TEXTURE_2D); + glActiveTextureARB(GL_TEXTURE1_ARB); + glDisable(GL_TEXTURE_2D); + } + else if (Texture == 1) { + glActiveTextureARB(GL_TEXTURE0_ARB); + glEnable(GL_TEXTURE_2D); + glActiveTextureARB(GL_TEXTURE1_ARB); + glDisable(GL_TEXTURE_2D); + } + else { + glActiveTextureARB(GL_TEXTURE0_ARB); + glEnable(GL_TEXTURE_2D); + glActiveTextureARB(GL_TEXTURE1_ARB); + glEnable(GL_TEXTURE_2D); + } + break; + case 'w': + LineWidth -= 0.25; + if (LineWidth < 0.25) + LineWidth = 0.25; + glLineWidth(LineWidth); + glPointSize(LineWidth); + break; + case 'W': + LineWidth += 0.25; + if (LineWidth > 8.0) + LineWidth = 8.0; + glLineWidth(LineWidth); + glPointSize(LineWidth); + break; + case 'p': + Points = !Points; + break; + case 's': + Stipple = !Stipple; + if (Stipple) + glEnable(GL_LINE_STIPPLE); + else + glDisable(GL_LINE_STIPPLE); + break; + case ' ': + Animate = !Animate; + if (Animate) + glutIdleFunc(Idle); + else + glutIdleFunc(NULL); + break; + case 27: + exit(0); + break; + } + printf("LineWidth, PointSize = %f\n", LineWidth); + glutPostRedisplay(); +} + + +static void SpecialKey( int key, int x, int y ) +{ + float 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( int argc, char *argv[] ) +{ + GLuint u; + for (u = 0; u < 2; u++) { + glActiveTextureARB(GL_TEXTURE0_ARB + u); + glBindTexture(GL_TEXTURE_2D, 10+u); + if (u == 0) + glEnable(GL_TEXTURE_2D); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + + if (u == 0) + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); + else + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_ADD); + + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + if (!LoadRGBMipmaps(TEXTURE_FILE, GL_RGB)) { + printf("Error: couldn't load texture image\n"); + exit(1); + } + } + + glLineStipple(1, 0xff); + + 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)); + } +} + + +int main( int argc, char *argv[] ) +{ + glutInit( &argc, argv ); + glutInitWindowSize( 400, 300 ); + + glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE ); + + glutCreateWindow(argv[0] ); + + Init(argc, argv); + + glutReshapeFunc( Reshape ); + glutKeyboardFunc( Key ); + glutSpecialFunc( SpecialKey ); + glutDisplayFunc( Display ); + if (Animate) + glutIdleFunc( Idle ); + + glutMainLoop(); + return 0; +} diff --git a/progs/osdemos/Makefile b/progs/osdemos/Makefile new file mode 100644 index 00000000000..7d1bc08a4e0 --- /dev/null +++ b/progs/osdemos/Makefile @@ -0,0 +1,78 @@ +# progs/demos/Makefile + +TOP = ../.. +include $(TOP)/configs/current + +INCDIR = $(TOP)/include + +OSMESA_LIBS = -L$(LIB_DIR) -lglut -lOSMesa -lGLU -lGL $(APP_LIB_DEPS) + +OSMESA16_LIBS = -L$(LIB_DIR) -lglut -lOSMesa16 -lGLU -lGL $(APP_LIB_DEPS) + +OSMESA32_LIBS = -L$(LIB_DIR) -lglut -lOSMesa32 -lGLU -lGL $(APP_LIB_DEPS) + +LIB_DEP = $(LIB_DIR)/$(GL_LIB_NAME) $(LIB_DIR)/$(GLU_LIB_NAME) $(LIB_DIR)/$(GLUT_LIB_NAME) + +PROGS = \ + osdemo \ + ostest1 + + +##### RULES ##### + +.SUFFIXES: +.SUFFIXES: .c + + +# make executable from .c file: +.c: $(LIB_DEP) readtex.o + $(CC) -I$(INCDIR) $(CFLAGS) $< readtex.o $(APP_LIB_DEPS) -o $@ + + +##### TARGETS ##### + +default: readtex.o $(PROGS) + + +readtex.c: $(TOP)/progs/util/readtex.c + cp $< . + +readtex.h: $(TOP)/progs/util/readtex.h + cp $< . + +readtex.o: readtex.c readtex.h + $(CC) -c -I$(INCDIR) $(CFLAGS) readtex.c + + +showbuffer.c: $(TOP)/progs/util/showbuffer.c + cp $< . + +showbuffer.h: $(TOP)/progs/util/showbuffer.h + cp $< . + +showbuffer.o: showbuffer.c showbuffer.h + $(CC) -c -I$(INCDIR) $(CFLAGS) showbuffer.c + + +# special case: need the -lOSMesa library: +osdemo: osdemo.c + $(CC) -I$(INCDIR) $(CFLAGS) osdemo.c $(OSMESA_LIBS) -o $@ + +# special case: need the -lOSMesa library: +ostest1: ostest1.c + $(CC) -I$(INCDIR) $(CFLAGS) ostest1.c $(OSMESA_LIBS) -o $@ + +# another special case: need the -lOSMesa16 library: +osdemo16: osdemo16.c + $(CC) -I$(INCDIR) $(CFLAGS) osdemo16.c $(OSMESA16_LIBS) -o $@ + +# another special case: need the -lOSMesa32 library: +osdemo32: osdemo32.c + $(CC) -I$(INCDIR) $(CFLAGS) osdemo32.c $(OSMESA32_LIBS) -o $@ + + + +clean: + -rm -f $(PROGS) + -rm -f *.o *~ + -rm -f readtex.[ch] showbuffer.[ch] diff --git a/progs/osdemos/osdemo.c b/progs/osdemos/osdemo.c new file mode 100644 index 00000000000..95e2ff97875 --- /dev/null +++ b/progs/osdemos/osdemo.c @@ -0,0 +1,274 @@ + +/* + * Demo of off-screen Mesa rendering + * + * See Mesa/include/GL/osmesa.h for documentation of the OSMesa functions. + * + * If you want to render BIG images you'll probably have to increase + * MAX_WIDTH and MAX_HEIGHT in src/config.h. + * + * This program is in the public domain. + * + * Brian Paul + * + * PPM output provided by Joerg Schmalzl. + * ASCII PPM output added by Brian Paul. + * + * Usage: osdemo [-perf] [filename] + * + * -perf: Redraws the image 1000 times, displaying the FPS every 5 secs. + * filename: file to store the TGA or PPM output + */ + + +#include +#include +#include +#include "GL/osmesa.h" +#include "GL/glut.h" + + +#define SAVE_TARGA + + +#define WIDTH 400 +#define HEIGHT 400 + +static GLint T0 = 0; +static GLint Frames = 0; +static int perf = 0; + +static void render_image( void ) +{ + GLfloat light_ambient[] = { 0.0, 0.0, 0.0, 1.0 }; + GLfloat light_diffuse[] = { 1.0, 1.0, 1.0, 1.0 }; + GLfloat light_specular[] = { 1.0, 1.0, 1.0, 1.0 }; + GLfloat light_position[] = { 1.0, 1.0, 1.0, 0.0 }; + GLfloat red_mat[] = { 1.0, 0.2, 0.2, 1.0 }; + GLfloat green_mat[] = { 0.2, 1.0, 0.2, 1.0 }; + GLfloat blue_mat[] = { 0.2, 0.2, 1.0, 1.0 }; + + + glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient); + glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse); + glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular); + glLightfv(GL_LIGHT0, GL_POSITION, light_position); + + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + glEnable(GL_DEPTH_TEST); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-2.5, 2.5, -2.5, 2.5, -10.0, 10.0); + glMatrixMode(GL_MODELVIEW); + + glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); + + glPushMatrix(); + glRotatef(20.0, 1.0, 0.0, 0.0); + + glPushMatrix(); + glTranslatef(-0.75, 0.5, 0.0); + glRotatef(90.0, 1.0, 0.0, 0.0); + glMaterialfv( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, red_mat ); + glutSolidTorus(0.275, 0.85, 20, 20); + glPopMatrix(); + + glPushMatrix(); + glTranslatef(-0.75, -0.5, 0.0); + glRotatef(270.0, 1.0, 0.0, 0.0); + glMaterialfv( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, green_mat ); + glutSolidCone(1.0, 2.0, 16, 1); + glPopMatrix(); + + 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(); + + glPopMatrix(); + + /* This is very important!!! + * Make sure buffered commands are finished!!! + */ + glFinish(); + + Frames++; + if (perf) { + 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); + T0 = t; + Frames = 0; + } + } +} + + +#ifdef SAVE_TARGA + +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=0; y--) { + for (x=0; x=0; y--) { + for (x=0; x= 305 + /* specify Z, stencil, accum sizes */ + OSMesaContext ctx = OSMesaCreateContextExt( OSMESA_RGBA, 16, 0, 0, NULL ); +#else + OSMesaContext ctx = OSMesaCreateContext( OSMESA_RGBA, NULL ); +#endif + if (!ctx) { + printf("OSMesaCreateContext failed!\n"); + return 0; + } + + for ( i=1; i +#include +#include "GL/osmesa.h" +#include "GL/glut.h" + + +#define SAVE_TARGA + + +#define WIDTH 400 +#define HEIGHT 400 + + + +static void render_image( void ) +{ + GLfloat light_ambient[] = { 0.0, 0.0, 0.0, 1.0 }; + GLfloat light_diffuse[] = { 1.0, 1.0, 1.0, 1.0 }; + GLfloat light_specular[] = { 1.0, 1.0, 1.0, 1.0 }; + GLfloat light_position[] = { 1.0, 1.0, 1.0, 0.0 }; + GLfloat red_mat[] = { 1.0, 0.2, 0.2, 1.0 }; + GLfloat green_mat[] = { 0.2, 1.0, 0.2, 0.5 }; + GLfloat blue_mat[] = { 0.2, 0.2, 1.0, 1.0 }; + GLfloat white_mat[] = { 1.0, 1.0, 1.0, 1.0 }; + GLfloat purple_mat[] = { 1.0, 0.2, 1.0, 1.0 }; + GLUquadricObj *qobj = gluNewQuadric(); + + glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient); + glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse); + glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular); + glLightfv(GL_LIGHT0, GL_POSITION, light_position); + + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + glEnable(GL_DEPTH_TEST); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-2.5, 2.5, -2.5, 2.5, -10.0, 10.0); + glMatrixMode(GL_MODELVIEW); + + glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); + + glPushMatrix(); + glRotatef(20.0, 1.0, 0.0, 0.0); + +#if 0 + glPushMatrix(); + glTranslatef(-0.75, 0.5, 0.0); + glRotatef(90.0, 1.0, 0.0, 0.0); + glMaterialfv( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, red_mat ); + glutSolidTorus(0.275, 0.85, 20, 20); + glPopMatrix(); +#endif + + /* red square */ + glPushMatrix(); + glTranslatef(0.0, -0.5, 0.0); + glRotatef(90, 1, 0.5, 0); + glScalef(3, 3, 3); + glDisable(GL_LIGHTING); + glColor4f(1, 0, 0, 0.5); + glBegin(GL_POLYGON); + glVertex2f(-1, -1); + glVertex2f( 1, -1); + glVertex2f( 1, 1); + glVertex2f(-1, 1); + glEnd(); + glEnable(GL_LIGHTING); + glPopMatrix(); + +#if 0 + /* green square */ + glPushMatrix(); + glTranslatef(0.0, 0.5, 0.1); + glDisable(GL_LIGHTING); + glColor3f(0, 1, 0); + glBegin(GL_POLYGON); + glVertex2f(-1, -1); + glVertex2f( 1, -1); + glVertex2f( 1, 1); + glVertex2f(-1, 1); + glEnd(); + glEnable(GL_LIGHTING); + glPopMatrix(); + + /* blue square */ + glPushMatrix(); + glTranslatef(0.75, 0.5, 0.3); + glDisable(GL_LIGHTING); + glColor3f(0, 0, 0.5); + glBegin(GL_POLYGON); + glVertex2f(-1, -1); + glVertex2f( 1, -1); + glVertex2f( 1, 1); + glVertex2f(-1, 1); + glEnd(); + glEnable(GL_LIGHTING); + glPopMatrix(); +#endif + glPushMatrix(); + glTranslatef(-0.75, -0.5, 0.0); + glRotatef(270.0, 1.0, 0.0, 0.0); + glMaterialfv( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, green_mat ); + glColor4f(0,1,0,0.5); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + gluCylinder(qobj, 1.0, 0.0, 2.0, 16, 1); + glDisable(GL_BLEND); + glPopMatrix(); + + glPushMatrix(); + glTranslatef(0.75, 1.0, 1.0); + glMaterialfv( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, blue_mat ); + gluSphere(qobj, 1.0, 20, 20); + glPopMatrix(); + + glPopMatrix(); + + /* This is very important!!! + * Make sure buffered commands are finished!!! + */ + glFinish(); + + gluDeleteQuadric(qobj); + + { + GLint r, g, b, a; + glGetIntegerv(GL_RED_BITS, &r); + glGetIntegerv(GL_GREEN_BITS, &g); + glGetIntegerv(GL_BLUE_BITS, &b); + glGetIntegerv(GL_ALPHA_BITS, &a); + printf("channel sizes: %d %d %d %d\n", r, g, b, a); + } +} + + + +static void +write_targa(const char *filename, const GLushort *buffer, int width, int height) +{ + FILE *f = fopen( filename, "w" ); + if (f) { + int i, x, y; + const GLushort *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> 8, f); /* write blue */ + fputc(ptr[i+1] >> 8, f); /* write green */ + fputc(ptr[i] >> 8, f); /* write red */ + } + } + } +} + + +static void +write_ppm(const char *filename, const GLushort *buffer, int width, int height) +{ + const int binary = 0; + FILE *f = fopen( filename, "w" ); + if (f) { + int i, x, y; + const GLushort *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> 8, f); /* write red */ + fputc(ptr[i+1] >> 8, f); /* write green */ + fputc(ptr[i+2] >> 8, 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> 8, ptr[i+1] >> 8, ptr[i+2] >> 8); + counter++; + if (counter % 5 == 0) + fprintf(f, "\n"); + } + } + } + fclose(f); + } +} + + + +int main( int argc, char *argv[] ) +{ + GLushort *buffer; + + /* Create an RGBA-mode context */ +#if OSMESA_MAJOR_VERSION * 100 + OSMESA_MINOR_VERSION >= 305 + /* specify Z, stencil, accum sizes */ + OSMesaContext ctx = OSMesaCreateContextExt( GL_RGBA, 16, 0, 0, NULL ); +#else + OSMesaContext ctx = OSMesaCreateContext( GL_RGBA, NULL ); +#endif + if (!ctx) { + printf("OSMesaCreateContext failed!\n"); + return 0; + } + + /* Allocate the image buffer */ + buffer = (GLushort *) malloc( WIDTH * HEIGHT * 4 * sizeof(GLushort)); + if (!buffer) { + printf("Alloc image buffer failed!\n"); + return 0; + } + + /* Bind the buffer to the context and make it current */ + if (!OSMesaMakeCurrent( ctx, buffer, GL_UNSIGNED_SHORT, WIDTH, HEIGHT )) { + printf("OSMesaMakeCurrent failed!\n"); + return 0; + } + + render_image(); + + if (argc>1) { +#ifdef SAVE_TARGA + write_targa(argv[1], buffer, WIDTH, HEIGHT); +#else + write_ppm(argv[1], buffer, WIDTH, HEIGHT); +#endif + } + else { + printf("Specify a filename if you want to make an image file\n"); + } + + printf("all done\n"); + + /* free the image buffer */ + free( buffer ); + + /* destroy the context */ + OSMesaDestroyContext( ctx ); + + return 0; +} diff --git a/progs/osdemos/osdemo32.c b/progs/osdemos/osdemo32.c new file mode 100644 index 00000000000..7295b46a830 --- /dev/null +++ b/progs/osdemos/osdemo32.c @@ -0,0 +1,308 @@ +/* + * Demo of off-screen Mesa rendering with 32-bit float color channels. + * This requires the libOSMesa32.so library. + * + * Compile with something like this: + * + * gcc osdemo32.c -I../../include -L../../lib -lglut -lGLU -lOSMesa32 -lm -o osdemo32 + */ + + +#include +#include +#include "GL/osmesa.h" +#include "GL/glut.h" + + +#define SAVE_TARGA + + +#define WIDTH 400 +#define HEIGHT 400 + + + +static void render_image( void ) +{ + GLfloat light_ambient[] = { 0.0, 0.0, 0.0, 1.0 }; + GLfloat light_diffuse[] = { 1.0, 1.0, 1.0, 1.0 }; + GLfloat light_specular[] = { 1.0, 1.0, 1.0, 1.0 }; + GLfloat light_position[] = { 1.0, 1.0, 1.0, 0.0 }; + GLfloat red_mat[] = { 1.0, 0.2, 0.2, 1.0 }; + GLfloat green_mat[] = { 0.2, 1.0, 0.2, 0.5 }; + GLfloat blue_mat[] = { 0.2, 0.2, 1.0, 1.0 }; + GLfloat white_mat[] = { 1.0, 1.0, 1.0, 1.0 }; + GLfloat purple_mat[] = { 1.0, 0.2, 1.0, 1.0 }; + GLUquadricObj *qobj = gluNewQuadric(); + + glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient); + glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse); + glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular); + glLightfv(GL_LIGHT0, GL_POSITION, light_position); + + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + glEnable(GL_DEPTH_TEST); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-2.5, 2.5, -2.5, 2.5, -10.0, 10.0); + glMatrixMode(GL_MODELVIEW); + + glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); + + glPushMatrix(); + glRotatef(20.0, 1.0, 0.0, 0.0); + +#if 0 + glPushMatrix(); + glTranslatef(-0.75, 0.5, 0.0); + glRotatef(90.0, 1.0, 0.0, 0.0); + glMaterialfv( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, red_mat ); + glutSolidTorus(0.275, 0.85, 20, 20); + glPopMatrix(); +#endif + + /* red square */ + glPushMatrix(); + glTranslatef(0.0, -0.5, 0.0); + glRotatef(90, 1, 0.5, 0); + glScalef(3, 3, 3); + glDisable(GL_LIGHTING); + glColor4f(1, 0, 0, 0.5); + glBegin(GL_POLYGON); + glVertex2f(-1, -1); + glVertex2f( 1, -1); + glVertex2f( 1, 1); + glVertex2f(-1, 1); + glEnd(); + glEnable(GL_LIGHTING); + glPopMatrix(); + +#if 0 + /* green square */ + glPushMatrix(); + glTranslatef(0.0, 0.5, 0.1); + glDisable(GL_LIGHTING); + glColor3f(0, 1, 0); + glBegin(GL_POLYGON); + glVertex2f(-1, -1); + glVertex2f( 1, -1); + glVertex2f( 1, 1); + glVertex2f(-1, 1); + glEnd(); + glEnable(GL_LIGHTING); + glPopMatrix(); + + /* blue square */ + glPushMatrix(); + glTranslatef(0.75, 0.5, 0.3); + glDisable(GL_LIGHTING); + glColor3f(0, 0, 0.5); + glBegin(GL_POLYGON); + glVertex2f(-1, -1); + glVertex2f( 1, -1); + glVertex2f( 1, 1); + glVertex2f(-1, 1); + glEnd(); + glEnable(GL_LIGHTING); + glPopMatrix(); +#endif + glPushMatrix(); + glTranslatef(-0.75, -0.5, 0.0); + glRotatef(270.0, 1.0, 0.0, 0.0); + glMaterialfv( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, green_mat ); + glColor4f(0,1,0,0.5); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + gluCylinder(qobj, 1.0, 0.0, 2.0, 16, 1); + glDisable(GL_BLEND); + glPopMatrix(); + + glPushMatrix(); + glTranslatef(0.75, 1.0, 1.0); + glMaterialfv( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, blue_mat ); + gluSphere(qobj, 1.0, 20, 20); + glPopMatrix(); + + glPopMatrix(); + + /* This is very important!!! + * Make sure buffered commands are finished!!! + */ + glFinish(); + + gluDeleteQuadric(qobj); + + { + GLint r, g, b, a; + glGetIntegerv(GL_RED_BITS, &r); + glGetIntegerv(GL_GREEN_BITS, &g); + glGetIntegerv(GL_BLUE_BITS, &b); + glGetIntegerv(GL_ALPHA_BITS, &a); + printf("channel sizes: %d %d %d %d\n", r, g, b, a); + } +} + + + +static void +write_targa(const char *filename, const GLfloat *buffer, int width, int height) +{ + FILE *f = fopen( filename, "w" ); + if (f) { + int i, x, y; + const GLfloat *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 255) r = 255; + if (g > 255) g = 255; + if (b > 255) b = 255; + fputc(b, f); /* write blue */ + fputc(g, f); /* write green */ + fputc(r, f); /* write red */ + } + } + } +} + + +static void +write_ppm(const char *filename, const GLfloat *buffer, int width, int height) +{ + const int binary = 0; + FILE *f = fopen( filename, "w" ); + if (f) { + int i, x, y; + const GLfloat *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 255) r = 255; + if (g > 255) g = 255; + if (b > 255) b = 255; + fputc(r, f); /* write red */ + fputc(g, f); /* write green */ + fputc(b, 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 255) r = 255; + if (g > 255) g = 255; + if (b > 255) b = 255; + fprintf(f, " %3d %3d %3d", r, g, b); + counter++; + if (counter % 5 == 0) + fprintf(f, "\n"); + } + } + } + fclose(f); + } +} + + + +int main( int argc, char *argv[] ) +{ + GLfloat *buffer; + + /* Create an RGBA-mode context */ +#if OSMESA_MAJOR_VERSION * 100 + OSMESA_MINOR_VERSION >= 305 + /* specify Z, stencil, accum sizes */ + OSMesaContext ctx = OSMesaCreateContextExt( GL_RGBA, 16, 0, 0, NULL ); +#else + OSMesaContext ctx = OSMesaCreateContext( GL_RGBA, NULL ); +#endif + if (!ctx) { + printf("OSMesaCreateContext failed!\n"); + return 0; + } + + /* Allocate the image buffer */ + buffer = (GLfloat *) malloc( WIDTH * HEIGHT * 4 * sizeof(GLfloat)); + if (!buffer) { + printf("Alloc image buffer failed!\n"); + return 0; + } + + /* Bind the buffer to the context and make it current */ + if (!OSMesaMakeCurrent( ctx, buffer, GL_FLOAT, WIDTH, HEIGHT )) { + printf("OSMesaMakeCurrent failed!\n"); + return 0; + } + + render_image(); + + if (argc>1) { +#ifdef SAVE_TARGA + write_targa(argv[1], buffer, WIDTH, HEIGHT); +#else + write_ppm(argv[1], buffer, WIDTH, HEIGHT); +#endif + } + else { + printf("Specify a filename if you want to make an image file\n"); + } + + printf("all done\n"); + + /* free the image buffer */ + free( buffer ); + + /* destroy the context */ + OSMesaDestroyContext( ctx ); + + return 0; +} diff --git a/progs/osdemos/ostest1.c b/progs/osdemos/ostest1.c new file mode 100644 index 00000000000..61f0f3da29c --- /dev/null +++ b/progs/osdemos/ostest1.c @@ -0,0 +1,344 @@ +/* + * Test OSMesa interface at 8, 16 and 32 bits/channel. + * + * Usage: osdemo [options] + * + * Options: + * -f generate image files + * -g render gradient and print color values + */ + +#include +#include +#include +#include +#include "GL/osmesa.h" +#include "GL/glut.h" + + +#define WIDTH 600 +#define HEIGHT 600 + +static GLboolean WriteFiles = GL_FALSE; +static GLboolean Gradient = GL_FALSE; + + +/** + * Draw red/green gradient across bottom of image. + * Read pixels to check deltas. + */ +static void +render_gradient(void) +{ + GLfloat row[WIDTH][4]; + int i; + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-1, 1, -1, 1, -1, 1); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + + glBegin(GL_POLYGON); + glColor3f(1, 0, 0); + glVertex2f(-1, -1.0); + glVertex2f(-1, -0.9); + glColor3f(0, 1, 0); + glVertex2f(1, -0.9); + glVertex2f(1, -1.0); + glEnd(); + glFinish(); + + glReadPixels(0, 0, WIDTH, 1, GL_RGBA, GL_FLOAT, row); + for (i = 0; i < 4; i++) { + printf("row[i] = %f, %f, %f\n", row[i][0], row[i][1], row[i][2]); + } +} + + +static void +render_image(void) +{ + static const GLfloat light_ambient[4] = { 0.0, 0.0, 0.0, 1.0 }; + static const GLfloat light_diffuse[4] = { 1.0, 1.0, 1.0, 1.0 }; + static const GLfloat light_specular[4] = { 1.0, 1.0, 1.0, 1.0 }; + static const GLfloat light_position[4] = { 1.0, 1.0, 1.0, 0.0 }; + static const GLfloat red_mat[4] = { 1.0, 0.2, 0.2, 1.0 }; + static const GLfloat green_mat[4] = { 0.2, 1.0, 0.2, 1.0 }; + static const GLfloat blue_mat[4] = { 0.2, 0.2, 1.0, 1.0 }; + static const GLfloat yellow_mat[4] = { 0.8, 0.8, 0.0, 1.0 }; + static const GLfloat purple_mat[4] = { 0.8, 0.4, 0.8, 0.6 }; + + glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient); + glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse); + glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular); + glLightfv(GL_LIGHT0, GL_POSITION, light_position); + + glEnable(GL_DEPTH_TEST); + glEnable(GL_LIGHT0); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glFrustum(-1.0, 1.0, -1.0, 1.0, 2.0, 50.0); + glMatrixMode(GL_MODELVIEW); + glTranslatef(0, 0.5, -7); + + glClearColor(0.3, 0.3, 0.7, 0.0); + glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); + + glPushMatrix(); + glRotatef(20.0, 1.0, 0.0, 0.0); + + /* ground */ + glEnable(GL_TEXTURE_2D); + glBegin(GL_POLYGON); + glNormal3f(0, 1, 0); + glTexCoord2f(0, 0); glVertex3f(-5, -1, -5); + glTexCoord2f(1, 0); glVertex3f( 5, -1, -5); + glTexCoord2f(1, 1); glVertex3f( 5, -1, 5); + glTexCoord2f(0, 1); glVertex3f(-5, -1, 5); + glEnd(); + glDisable(GL_TEXTURE_2D); + + glEnable(GL_LIGHTING); + + glPushMatrix(); + glTranslatef(-1.5, 0.5, 0.0); + glRotatef(90.0, 1.0, 0.0, 0.0); + glMaterialfv( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, red_mat ); + glutSolidTorus(0.275, 0.85, 20, 20); + glPopMatrix(); + + glPushMatrix(); + glTranslatef(-1.5, -0.5, 0.0); + glRotatef(270.0, 1.0, 0.0, 0.0); + glMaterialfv( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, green_mat ); + glutSolidCone(1.0, 2.0, 16, 1); + glPopMatrix(); + + 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(); + + glPushMatrix(); + glTranslatef(0.75, 0.0, 1.3); + glMaterialfv( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, yellow_mat ); + glutWireTeapot(1.0); + glPopMatrix(); + + glPushMatrix(); + glTranslatef(-0.5, 0.0, 2.5); + glRotatef(40, 0, 1, 0); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_BLEND); + glEnable(GL_CULL_FACE); + glMaterialfv( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, purple_mat ); + glutSolidCube(1.0); + glDisable(GL_BLEND); + glDisable(GL_CULL_FACE); + glPopMatrix(); + + glDisable(GL_LIGHTING); + + glPopMatrix(); + + glDisable(GL_DEPTH_TEST); +} + + +static void +init_context(void) +{ + const GLint texWidth = 64, texHeight = 64; + GLubyte *texImage; + int i, j; + + /* checker image */ + texImage = malloc(texWidth * texHeight * 4); + for (i = 0; i < texHeight; i++) { + for (j = 0; j < texWidth; j++) { + int k = (i * texWidth + j) * 4; + if ((i % 5) == 0 || (j % 5) == 0) { + texImage[k+0] = 200; + texImage[k+1] = 200; + texImage[k+2] = 200; + texImage[k+3] = 255; + } + else { + if ((i % 5) == 1 || (j % 5) == 1) { + texImage[k+0] = 50; + texImage[k+1] = 50; + texImage[k+2] = 50; + texImage[k+3] = 255; + } + else { + texImage[k+0] = 100; + texImage[k+1] = 100; + texImage[k+2] = 100; + texImage[k+3] = 255; + } + } + } + } + + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texWidth, texHeight, 0, + GL_RGBA, GL_UNSIGNED_BYTE, texImage); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + + free(texImage); +} + + +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=0; y--) { + for (x=0; x> 8; + write_ppm(filename, buffer8, WIDTH, HEIGHT); + free(buffer8); + } + else if (type == GL_FLOAT) { + GLfloat *buffer32 = (GLfloat *) buffer; + GLubyte *buffer8 = malloc(WIDTH * HEIGHT * 4); + int i; + for (i = 0; i < WIDTH * HEIGHT * 4; i++) + buffer8[i] = (GLubyte) (buffer32[i] * 255.0); + write_ppm(filename, buffer8, WIDTH, HEIGHT); + free(buffer8); + } + else { + write_ppm(filename, buffer, WIDTH, HEIGHT); + } + } + + OSMesaDestroyContext(ctx); + + return 1; +} + + +int +main( int argc, char *argv[] ) +{ + int i; + + for (i = 1; i < argc; i++) { + if (strcmp(argv[i], "-f") == 0) + WriteFiles = GL_TRUE; + else if (strcmp(argv[i], "-g") == 0) + Gradient = GL_TRUE; + } + + test(GL_UNSIGNED_BYTE, 8, "image8.ppm"); + test(GL_UNSIGNED_SHORT, 16, "image16.ppm"); + test(GL_FLOAT, 32, "image32.ppm"); + + return 0; +} diff --git a/progs/redbook/.cvsignore b/progs/redbook/.cvsignore new file mode 100644 index 00000000000..8ed3efe3e23 --- /dev/null +++ b/progs/redbook/.cvsignore @@ -0,0 +1,64 @@ +.cvsignore +aaindex +aapoly +aargb +accanti +accpersp +alpha +alpha3D +anti +bezcurve +bezmesh +checker +clip +colormat +cube +depthcue +dof +double +drawf +feedback +fog +fogindex +font +hello +image +light +lines +list +material +mipmap +model +movelight +nurbs +pickdepth +picksquare +plane +planet +polyoff +polys +quadric +robot +sccolorlight +scene +scenebamb +sceneflat +select +smooth +stencil +stroke +surface +teaambient +teapots +tess +tesswind +texbind +texgen +texprox +texsub +texturesurf +torus +trim +unproject +varray +wrap diff --git a/progs/redbook/Imakefile b/progs/redbook/Imakefile new file mode 100644 index 00000000000..ab3b6d7f793 --- /dev/null +++ b/progs/redbook/Imakefile @@ -0,0 +1,221 @@ +LOCAL_LIBRARIES = $(XLIB) $(TOP)\lib\Mesaaux.a $(TOP)\lib\Mesaglu.a $(TOP)\lib\MesaGL.a + +INCLUDES = -I$(TOP)\include + +SRCS = accanti.c \ + accnot.c \ + accpersp.c \ + accum.c \ + aim.c \ + alpha.c \ + alpha3D.c \ + anti.c \ + antiindex.c \ + antipindex.c \ + antipoint.c \ + antipoly.c \ + bezcurve.c \ + bezmesh.c \ + bezsurf.c \ + checker.c \ + checker2.c \ + chess.c \ + clip.c \ + colormat.c \ + cone.c \ + cube.c \ + curve.c \ + depthcue.c \ + disk.c \ + dof.c \ + dofnot.c \ + double.c \ + drawf.c \ + feedback.c \ + fog.c \ + fogindex.c \ + font.c \ + light.c \ + linelist.c \ + lines.c \ + list.c \ + list2.c \ + maplight.c \ + material.c \ + mipmap.c \ + model.c \ + movelight.c \ + nurbs.c \ + pickdepth.c \ + pickline.c \ + picksquare.c \ + plane.c \ + planet.c \ + planetup.c \ + polys.c \ + robot.c \ + sccolorlight.c \ + scene.c \ + scenebamb.c \ + sceneflat.c \ + select.c \ + simple.c \ + smooth.c \ + sphere.c \ + stencil.c \ + stroke.c \ + surface.c \ + tea.c \ + teaambient.c \ + teapots.c \ + texgen.c \ + texturesurf.c \ + trim.c \ + xfont.c + +PROGRAMS = ProgramTargetName(accanti) \ + ProgramTargetName(accnot) \ + ProgramTargetName(accpersp) \ + ProgramTargetName(accum) \ + ProgramTargetName(aim) \ + ProgramTargetName(alpha) \ + ProgramTargetName(alpha3D) \ + ProgramTargetName(anti) \ + ProgramTargetName(antiindex) \ + ProgramTargetName(antipindex) \ + ProgramTargetName(antipoint) \ + ProgramTargetName(antipoly) \ + ProgramTargetName(bezcurve) \ + ProgramTargetName(bezmesh) \ + ProgramTargetName(bezsurf) \ + ProgramTargetName(checker) \ + ProgramTargetName(checker2) \ + ProgramTargetName(chess) \ + ProgramTargetName(clip) \ + ProgramTargetName(colormat) \ + ProgramTargetName(cone) \ + ProgramTargetName(cube) \ + ProgramTargetName(curve) \ + ProgramTargetName(depthcue) \ + ProgramTargetName(disk) \ + ProgramTargetName(dof) \ + ProgramTargetName(dofnot) \ + ProgramTargetName(double) \ + ProgramTargetName(drawf) \ + ProgramTargetName(feedback) \ + ProgramTargetName(fog) \ + ProgramTargetName(fogindex) \ + ProgramTargetName(font) \ + ProgramTargetName(light) \ + ProgramTargetName(linelist) \ + ProgramTargetName(lines) \ + ProgramTargetName(list) \ + ProgramTargetName(list2) \ + ProgramTargetName(maplight) \ + ProgramTargetName(material) \ + ProgramTargetName(mipmap) \ + ProgramTargetName(model) \ + ProgramTargetName(movelight) \ + ProgramTargetName(nurbs) \ + ProgramTargetName(pickdepth) \ + ProgramTargetName(pickline) \ + ProgramTargetName(picksquare) \ + ProgramTargetName(plane) \ + ProgramTargetName(planet) \ + ProgramTargetName(planetup) \ + ProgramTargetName(polys) \ + ProgramTargetName(robot) \ + ProgramTargetName(sccolorlight) \ + ProgramTargetName(scene) \ + ProgramTargetName(scenebamb) \ + ProgramTargetName(sceneflat) \ + ProgramTargetName(select) \ + ProgramTargetName(simple) \ + ProgramTargetName(smooth) \ + ProgramTargetName(sphere) \ + ProgramTargetName(stencil) \ + ProgramTargetName(stroke) \ + ProgramTargetName(surface) \ + ProgramTargetName(tea) \ + ProgramTargetName(teaambient) \ + ProgramTargetName(teapots) \ + ProgramTargetName(texgen) \ + ProgramTargetName(texturesurf) \ + ProgramTargetName(trim) \ + ProgramTargetName(xfont) + +AllTarget($(PROGRAMS)) + +NormalProgramTarget(accanti,accanti.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(accnot,accnot.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(accpersp,accpersp.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(accum,accum.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(aim,aim.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(alpha,alpha.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(alpha3D,alpha3D.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(anti,anti.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(antiindex,antiindex.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(antipindex,antipindex.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(antipoint,antipoint.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(antipoly,antipoly.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(bezcurve,bezcurve.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(bezmesh,bezmesh.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(bezsurf,bezsurf.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(checker,checker.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(checker2,checker2.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(chess,chess.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(clip,clip.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(colormat,colormat.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(cone,cone.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(cube,cube.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(curve,curve.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(depthcue,depthcue.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(disk,disk.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(dof,dof.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(dofnot,dofnot.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(double,double.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(drawf,drawf.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(feedback,feedback.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(fog,fog.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(fogindex,fogindex.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(font,font.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(light,light.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(linelist,linelist.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(lines,lines.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(list,list.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(list2,list2.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(maplight,maplight.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(material,material.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(mipmap,mipmap.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(model,model.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(movelight,movelight.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(nurbs,nurbs.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(pickdepth,pickdepth.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(pickline,pickline.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(picksquare,picksquare.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(plane,plane.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(planet,planet.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(planetup,planetup.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(polys,polys.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(robot,robot.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(sccolorlight,sccolorlight.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(scene,scene.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(scenebamb,scenebamb.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(sceneflat,sceneflat.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(select,select.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(simple,simple.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(smooth,smooth.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(sphere,sphere.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(stencil,stencil.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(stroke,stroke.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(surface,surface.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(tea,tea.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(teaambient,teaambient.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(teapots,teapots.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(texgen,texgen.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(texturesurf,texturesurf.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(trim,trim.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(xfont,xfont.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) + +DependTarget() + diff --git a/progs/redbook/Makefile b/progs/redbook/Makefile new file mode 100644 index 00000000000..4cfbb9aeacd --- /dev/null +++ b/progs/redbook/Makefile @@ -0,0 +1,39 @@ +# progs/redbook/Makefile + +TOP = ../.. +include $(TOP)/configs/current + +INCDIR = $(TOP)/include + +LIB_DEP = $(LIB_DIR)/$(GL_LIB_NAME) $(LIB_DIR)/$(GLU_LIB_NAME) $(LIB_DIR)/$(GLUT_LIB_NAME) + +PROGS = aaindex aapoly aargb accanti accpersp alpha alpha3D anti \ + bezcurve bezmesh checker clip colormat cube depthcue dof \ + double drawf feedback fog fogindex font hello image light \ + lines list material mipmap model movelight nurbs pickdepth \ + picksquare plane planet polyoff polys quadric robot sccolorlight \ + scene scenebamb sceneflat select smooth stencil stroke surface \ + teaambient teapots tess tesswind texbind texgen texprox texsub \ + texturesurf torus trim unproject varray wrap + + + +##### RULES ##### + +.SUFFIXES: +.SUFFIXES: .c + +.c: $(LIB_DEP) + $(CC) -I$(INCDIR) $(CFLAGS) $< $(APP_LIB_DEPS) -o $@ + + + +##### TARGETS ###### + +default: $(PROGS) + + +clean: + -rm -f $(PROGS) + -rm -f *.o *~ + diff --git a/progs/redbook/Makefile.win b/progs/redbook/Makefile.win new file mode 100644 index 00000000000..7e57b8e47f8 --- /dev/null +++ b/progs/redbook/Makefile.win @@ -0,0 +1,78 @@ +# Makefile for Win32 + +TOP = .. +INCDIR = ..\include +LIBDIR = ..\lib + +!include + +SRCS= \ + aaindex.c \ + aapoly.c \ + aargb.c \ + accanti.c \ + accpersp.c \ + alpha.c \ + alpha3D.c \ + anti.c \ + bezcurve.c \ + bezmesh.c \ + checker.c \ + clip.c \ + colormat.c \ + cube.c \ + depthcue.c \ + dof.c \ + double.c \ + drawf.c \ + feedback.c \ + fog.c \ + fogindex.c \ + font.c \ + hello.c \ + image.c \ + light.c \ + lines.c \ + list.c \ + material.c \ + mipmap.c \ + model.c \ + movelight.c \ + nurbs.c \ + pickdepth.c \ + picksquare.c \ + plane.c \ + planet.c \ + polyoff.c \ + polys.c \ + quadric.c \ + robot.c \ + sccolorlight.c \ + scene.c \ + scenebamb.c \ + sceneflat.c \ + select.c \ + smooth.c \ + stencil.c \ + stroke.c \ + surface.c \ + teaambient.c \ + teapots.c \ + tess.c \ + tesswind.c \ + texbind.c \ + texgen.c \ + texprox.c \ + texsub.c \ + texturesurf.c \ + torus.c \ + trim.c \ + unproject.c \ + varray.c \ + wrap.c + +!include "$(TOP)/mesawin32.mak" + +$(EXES) : $*.obj + @echo $@ + $(link) -out:$@ $* /LIBPATH:$(LIBDIR) $(LIBS) \ No newline at end of file diff --git a/progs/redbook/README b/progs/redbook/README new file mode 100644 index 00000000000..4c8d5a74c9a --- /dev/null +++ b/progs/redbook/README @@ -0,0 +1,41 @@ +/* + * For the software in this directory + * (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. + */ + +The source code examples in this directory accompany the examples +printed in the _OpenGL Programming Guide_, published by Addison-Wesley; +ISBN 0-201-63274-8. diff --git a/progs/redbook/Windows/redbook.dsw b/progs/redbook/Windows/redbook.dsw new file mode 100644 index 00000000000..71ba7e89e3e --- /dev/null +++ b/progs/redbook/Windows/redbook.dsw @@ -0,0 +1,29 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00 +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! + +############################################################################### + +Project: "teapots"=".\teapots.dsp" - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/progs/redbook/Windows/teapots.dsp b/progs/redbook/Windows/teapots.dsp new file mode 100644 index 00000000000..4d39865810c --- /dev/null +++ b/progs/redbook/Windows/teapots.dsp @@ -0,0 +1,112 @@ +# Microsoft Developer Studio Project File - Name="teapots" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=teapots - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "teapots.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "teapots.mak" CFG="teapots - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "teapots - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "teapots - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "teapots - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /I "../../../include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../../../lib/GLUT32.LIB ../../../lib/GLU32.LIB ../../../lib/OPENGL32.LIB /nologo /subsystem:console /machine:I386 /out:"../teapots.exe" +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copy DLLs +PostBuild_Cmds=copy ..\..\..\lib\*.dll .. +# End Special Build Tool + +!ELSEIF "$(CFG)" == "teapots - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../../../include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../../../lib/GLUT32.LIB ../../../lib/GLU32.LIB ../../../lib/OPENGL32.LIB /nologo /subsystem:console /debug /machine:I386 /out:"../teapots.exe" /pdbtype:sept +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copy DLLs +PostBuild_Cmds=copy ..\..\..\lib\*.dll .. +# End Special Build Tool + +!ENDIF + +# Begin Target + +# Name "teapots - Win32 Release" +# Name "teapots - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=..\teapots.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/progs/redbook/aaindex.c b/progs/redbook/aaindex.c new file mode 100644 index 00000000000..7dbc7b4b9b2 --- /dev/null +++ b/progs/redbook/aaindex.c @@ -0,0 +1,153 @@ +/* + * Copyright (c) 1993-1997, 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(R) is a registered trademark of Silicon Graphics, Inc. + */ + +/* + * aaindex.c + * This program draws shows how to draw anti-aliased lines in color + * index mode. It draws two diagonal lines to form an X; when 'r' + * is typed in the window, the lines are rotated in opposite + * directions. + */ +#include +#include "stdlib.h" + +#define RAMPSIZE 16 +#define RAMP1START 32 +#define RAMP2START 48 + +static float rotAngle = 0.; + +/* Initialize antialiasing for color index mode, + * including loading a green color ramp starting + * at RAMP1START, and a blue color ramp starting + * at RAMP2START. The ramps must be a multiple of 16. + */ +void init(void) +{ + int i; + + for (i = 0; i < RAMPSIZE; i++) { + GLfloat shade; + shade = (GLfloat) i/(GLfloat) RAMPSIZE; + glutSetColor(RAMP1START+(GLint)i, 0., shade, 0.); + glutSetColor(RAMP2START+(GLint)i, 0., 0., shade); + } + + glEnable (GL_LINE_SMOOTH); + glHint (GL_LINE_SMOOTH_HINT, GL_DONT_CARE); + glLineWidth (1.5); + + glClearIndex ((GLfloat) RAMP1START); +} + +/* Draw 2 diagonal lines to form an X + */ +void display(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glIndexi(RAMP1START); + glPushMatrix(); + glRotatef(-rotAngle, 0.0, 0.0, 0.1); + glBegin (GL_LINES); + glVertex2f (-0.5, 0.5); + glVertex2f (0.5, -0.5); + glEnd (); + glPopMatrix(); + + glIndexi(RAMP2START); + glPushMatrix(); + glRotatef(rotAngle, 0.0, 0.0, 0.1); + glBegin (GL_LINES); + glVertex2f (0.5, 0.5); + glVertex2f (-0.5, -0.5); + glEnd (); + glPopMatrix(); + + glFlush(); +} + +void reshape(int w, int h) +{ + glViewport(0, 0, (GLsizei) w, (GLsizei) h); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + if (w <= h) + gluOrtho2D (-1.0, 1.0, + -1.0*(GLfloat)h/(GLfloat)w, 1.0*(GLfloat)h/(GLfloat)w); + else + gluOrtho2D (-1.0*(GLfloat)w/(GLfloat)h, + 1.0*(GLfloat)w/(GLfloat)h, -1.0, 1.0); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); +} + +/* ARGSUSED1 */ +void keyboard(unsigned char key, int x, int y) +{ + switch (key) { + case 'r': + case 'R': + rotAngle += 20.; + if (rotAngle >= 360.) rotAngle = 0.; + glutPostRedisplay(); + break; + case 27: /* Escape Key */ + exit(0); + break; + default: + break; + } +} + +/* Main Loop + * Open window with initial window size, title bar, + * color index display mode, and handle input events. + */ +int main(int argc, char** argv) +{ + glutInit(&argc, argv); + glutInitDisplayMode (GLUT_SINGLE | GLUT_INDEX); + glutInitWindowSize (200, 200); + glutCreateWindow (argv[0]); + init(); + glutReshapeFunc (reshape); + glutKeyboardFunc (keyboard); + glutDisplayFunc (display); + glutMainLoop(); + return 0; +} diff --git a/progs/redbook/aapoly.c b/progs/redbook/aapoly.c new file mode 100644 index 00000000000..757f0f48c43 --- /dev/null +++ b/progs/redbook/aapoly.c @@ -0,0 +1,172 @@ +/* + * Copyright (c) 1993-1997, 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(R) is a registered trademark of Silicon Graphics, Inc. + */ + +/* + * aapoly.c + * This program draws filled polygons with antialiased + * edges. The special GL_SRC_ALPHA_SATURATE blending + * function is used. + * Pressing the 't' key turns the antialiasing on and off. + */ +#include +#include +#include +#include + +GLboolean polySmooth = GL_TRUE; + +static void init(void) +{ + glCullFace (GL_BACK); + glEnable (GL_CULL_FACE); + glBlendFunc (GL_SRC_ALPHA_SATURATE, GL_ONE); + glClearColor (0.0, 0.0, 0.0, 0.0); +} + +#define NFACE 6 +#define NVERT 8 +void drawCube(GLdouble x0, GLdouble x1, GLdouble y0, GLdouble y1, + GLdouble z0, GLdouble z1) +{ + static GLfloat v[8][3]; + static GLfloat c[8][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}, {1.0, 1.0, 0.0, 1.0}, + {0.0, 0.0, 1.0, 1.0}, {1.0, 0.0, 1.0, 1.0}, + {0.0, 1.0, 1.0, 1.0}, {1.0, 1.0, 1.0, 1.0} + }; + +/* indices of front, top, left, bottom, right, back faces */ + static GLubyte indices[NFACE][4] = { + {4, 5, 6, 7}, {2, 3, 7, 6}, {0, 4, 7, 3}, + {0, 1, 5, 4}, {1, 5, 6, 2}, {0, 3, 2, 1} + }; + + v[0][0] = v[3][0] = v[4][0] = v[7][0] = x0; + v[1][0] = v[2][0] = v[5][0] = v[6][0] = x1; + v[0][1] = v[1][1] = v[4][1] = v[5][1] = y0; + v[2][1] = v[3][1] = v[6][1] = v[7][1] = y1; + v[0][2] = v[1][2] = v[2][2] = v[3][2] = z0; + v[4][2] = v[5][2] = v[6][2] = v[7][2] = z1; + +#ifdef GL_VERSION_1_1 + glEnableClientState (GL_VERTEX_ARRAY); + glEnableClientState (GL_COLOR_ARRAY); + glVertexPointer (3, GL_FLOAT, 0, v); + glColorPointer (4, GL_FLOAT, 0, c); + glDrawElements (GL_QUADS, NFACE*4, GL_UNSIGNED_BYTE, indices); + glDisableClientState (GL_VERTEX_ARRAY); + glDisableClientState (GL_COLOR_ARRAY); +#else + printf ("If this is GL Version 1.0, "); + printf ("vertex arrays are not supported.\n"); + exit(1); +#endif +} + +/* Note: polygons must be drawn from front to back + * for proper blending. + */ +void display(void) +{ + if (polySmooth) { + glClear (GL_COLOR_BUFFER_BIT); + glEnable (GL_BLEND); + glEnable (GL_POLYGON_SMOOTH); + glDisable (GL_DEPTH_TEST); + } + else { + glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glDisable (GL_BLEND); + glDisable (GL_POLYGON_SMOOTH); + glEnable (GL_DEPTH_TEST); + } + + glPushMatrix (); + glTranslatef (0.0, 0.0, -8.0); + glRotatef (30.0, 1.0, 0.0, 0.0); + glRotatef (60.0, 0.0, 1.0, 0.0); + drawCube(-0.5, 0.5, -0.5, 0.5, -0.5, 0.5); + glPopMatrix (); + + glFlush (); +} + +void reshape(int w, int h) +{ + glViewport(0, 0, (GLsizei) w, (GLsizei) h); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluPerspective(30.0, (GLfloat) w/(GLfloat) h, 1.0, 20.0); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); +} + +/* ARGSUSED1 */ +void keyboard(unsigned char key, int x, int y) +{ + switch (key) { + case 't': + case 'T': + polySmooth = !polySmooth; + glutPostRedisplay(); + break; + case 27: + exit(0); /* Escape key */ + break; + default: + break; + } +} + +/* Main Loop + */ +int main(int argc, char** argv) +{ + glutInit(&argc, argv); + glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB + | GLUT_ALPHA | GLUT_DEPTH); + glutInitWindowSize(200, 200); + glutCreateWindow(argv[0]); + init (); + glutReshapeFunc (reshape); + glutKeyboardFunc (keyboard); + glutDisplayFunc (display); + glutMainLoop(); + return 0; +} + diff --git a/progs/redbook/aargb.c b/progs/redbook/aargb.c new file mode 100644 index 00000000000..f51984170e6 --- /dev/null +++ b/progs/redbook/aargb.c @@ -0,0 +1,149 @@ +/* + * Copyright (c) 1993-1997, 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(R) is a registered trademark of Silicon Graphics, Inc. + */ + +/* + * aargb.c + * This program draws shows how to draw anti-aliased lines. It draws + * two diagonal lines to form an X; when 'r' is typed in the window, + * the lines are rotated in opposite directions. + */ +#include +#include +#include + +static float rotAngle = 0.; + +/* Initialize antialiasing for RGBA mode, including alpha + * blending, hint, and line width. Print out implementation + * specific info on line width granularity and width. + */ +void init(void) +{ + GLfloat values[2]; + glGetFloatv (GL_LINE_WIDTH_GRANULARITY, values); + printf ("GL_LINE_WIDTH_GRANULARITY value is %3.1f\n", values[0]); + + glGetFloatv (GL_LINE_WIDTH_RANGE, values); + printf ("GL_LINE_WIDTH_RANGE values are %3.1f %3.1f\n", + values[0], values[1]); + + glEnable (GL_LINE_SMOOTH); + glEnable (GL_BLEND); + glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glHint (GL_LINE_SMOOTH_HINT, GL_DONT_CARE); + glLineWidth (1.5); + + glClearColor(0.0, 0.0, 0.0, 0.0); +} + +/* Draw 2 diagonal lines to form an X + */ +void display(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glColor3f (0.0, 1.0, 0.0); + glPushMatrix(); + glRotatef(-rotAngle, 0.0, 0.0, 0.1); + glBegin (GL_LINES); + glVertex2f (-0.5, 0.5); + glVertex2f (0.5, -0.5); + glEnd (); + glPopMatrix(); + + glColor3f (0.0, 0.0, 1.0); + glPushMatrix(); + glRotatef(rotAngle, 0.0, 0.0, 0.1); + glBegin (GL_LINES); + glVertex2f (0.5, 0.5); + glVertex2f (-0.5, -0.5); + glEnd (); + glPopMatrix(); + + glFlush(); +} + +void reshape(int w, int h) +{ + glViewport(0, 0, w, h); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + if (w <= h) + gluOrtho2D (-1.0, 1.0, + -1.0*(GLfloat)h/(GLfloat)w, 1.0*(GLfloat)h/(GLfloat)w); + else + gluOrtho2D (-1.0*(GLfloat)w/(GLfloat)h, + 1.0*(GLfloat)w/(GLfloat)h, -1.0, 1.0); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); +} + +/* ARGSUSED1 */ +void keyboard(unsigned char key, int x, int y) +{ + switch (key) { + case 'r': + case 'R': + rotAngle += 20.; + if (rotAngle >= 360.) rotAngle = 0.; + glutPostRedisplay(); + break; + case 27: /* Escape Key */ + exit(0); + break; + default: + break; + } +} + +/* Main Loop + * Open window with initial window size, title bar, + * RGBA display mode, and handle input events. + */ +int main(int argc, char** argv) +{ + glutInit(&argc, argv); + glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); + glutInitWindowSize (200, 200); + glutCreateWindow (argv[0]); + init(); + glutReshapeFunc (reshape); + glutKeyboardFunc (keyboard); + glutDisplayFunc (display); + glutMainLoop(); + return 0; +} diff --git a/progs/redbook/accanti.c b/progs/redbook/accanti.c new file mode 100644 index 00000000000..12ca16f7a52 --- /dev/null +++ b/progs/redbook/accanti.c @@ -0,0 +1,182 @@ + +/* 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. + */ +/* accanti.c + */ +#include +#include +#include "jitter.h" + +/* Initialize lighting and other values. + */ +void myinit(void) +{ + GLfloat mat_ambient[] = { 1.0, 1.0, 1.0, 1.0 }; + GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 }; + GLfloat light_position[] = { 0.0, 0.0, 10.0, 1.0 }; + GLfloat lm_ambient[] = { 0.2, 0.2, 0.2, 1.0 }; + + glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient); + glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); + glMaterialf(GL_FRONT, GL_SHININESS, 50.0); + glLightfv(GL_LIGHT0, GL_POSITION, light_position); + glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lm_ambient); + + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + glDepthFunc(GL_LESS); + glEnable(GL_DEPTH_TEST); + glShadeModel (GL_FLAT); + + glClearColor(0.0, 0.0, 0.0, 0.0); + glClearAccum(0.0, 0.0, 0.0, 0.0); +} + +void displayObjects(void) +{ + GLfloat torus_diffuse[] = { 0.7, 0.7, 0.0, 1.0 }; + GLfloat cube_diffuse[] = { 0.0, 0.7, 0.7, 1.0 }; + GLfloat sphere_diffuse[] = { 0.7, 0.0, 0.7, 1.0 }; + GLfloat octa_diffuse[] = { 0.7, 0.4, 0.4, 1.0 }; + + glPushMatrix (); + glRotatef (30.0, 1.0, 0.0, 0.0); + + glPushMatrix (); + glTranslatef (-0.80, 0.35, 0.0); + glRotatef (100.0, 1.0, 0.0, 0.0); + glMaterialfv(GL_FRONT, GL_DIFFUSE, torus_diffuse); + glutSolidTorus (0.275, 0.85, 16, 16); + glPopMatrix (); + + glPushMatrix (); + glTranslatef (-0.75, -0.50, 0.0); + glRotatef (45.0, 0.0, 0.0, 1.0); + glRotatef (45.0, 1.0, 0.0, 0.0); + glMaterialfv(GL_FRONT, GL_DIFFUSE, cube_diffuse); + glutSolidCube (1.5); + glPopMatrix (); + + glPushMatrix (); + glTranslatef (0.75, 0.60, 0.0); + glRotatef (30.0, 1.0, 0.0, 0.0); + glMaterialfv(GL_FRONT, GL_DIFFUSE, sphere_diffuse); + glutSolidSphere (1.0, 16, 16); + glPopMatrix (); + + glPushMatrix (); + glTranslatef (0.70, -0.90, 0.25); + glMaterialfv(GL_FRONT, GL_DIFFUSE, octa_diffuse); + glutSolidOctahedron (); + glPopMatrix (); + + glPopMatrix (); +} + +#define ACSIZE 8 + +void display(void) +{ + GLint viewport[4]; + int jitter; + + glGetIntegerv (GL_VIEWPORT, viewport); + + glClear(GL_ACCUM_BUFFER_BIT); + for (jitter = 0; jitter < ACSIZE; jitter++) { + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glPushMatrix (); +/* Note that 4.5 is the distance in world space between + * left and right and bottom and top. + * This formula converts fractional pixel movement to + * world coordinates. + */ + glTranslatef (j8[jitter].x*4.5/viewport[2], + j8[jitter].y*4.5/viewport[3], 0.0); + displayObjects (); + glPopMatrix (); + glAccum(GL_ACCUM, 1.0/ACSIZE); + } + glAccum (GL_RETURN, 1.0); + glFlush(); +} + +void myReshape(int w, int h) +{ + glViewport(0, 0, w, h); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + if (w <= h) + glOrtho (-2.25, 2.25, -2.25*h/w, 2.25*h/w, -10.0, 10.0); + else + glOrtho (-2.25*w/h, 2.25*w/h, -2.25, 2.25, -10.0, 10.0); + glMatrixMode(GL_MODELVIEW); +} + +static void +key(unsigned char k, int x, int y) +{ + switch (k) { + case 27: /* Escape */ + exit(0); + break; + default: + return; + } + glutPostRedisplay(); +} + +/* Main Loop + * Open window with initial window size, title bar, + * RGBA display mode, and handle input events. + */ +int main(int argc, char** argv) +{ + glutInit(&argc, argv); + glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB + | GLUT_ACCUM | GLUT_DEPTH); + glutInitWindowSize (250, 250); + glutCreateWindow (argv[0]); + myinit(); + glutReshapeFunc (myReshape); + glutDisplayFunc(display); + glutKeyboardFunc(key); + glutMainLoop(); + return 0; /* ANSI C requires main to return int. */ +} diff --git a/progs/redbook/accpersp.c b/progs/redbook/accpersp.c new file mode 100644 index 00000000000..46e369ae631 --- /dev/null +++ b/progs/redbook/accpersp.c @@ -0,0 +1,240 @@ +/* + * Copyright (c) 1993-1997, 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(R) is a registered trademark of Silicon Graphics, Inc. + */ + +/* accpersp.c + * Use the accumulation buffer to do full-scene antialiasing + * on a scene with perspective projection, using the special + * routines accFrustum() and accPerspective(). + */ +#include +#include +#include +#include "jitter.h" + +#define PI_ 3.14159265358979323846 + +/* accFrustum() + * The first 6 arguments are identical to the glFrustum() call. + * + * pixdx and pixdy are anti-alias jitter in pixels. + * Set both equal to 0.0 for no anti-alias jitter. + * eyedx and eyedy are depth-of field jitter in pixels. + * Set both equal to 0.0 for no depth of field effects. + * + * focus is distance from eye to plane in focus. + * focus must be greater than, but not equal to 0.0. + * + * Note that accFrustum() calls glTranslatef(). You will + * probably want to insure that your ModelView matrix has been + * initialized to identity before calling accFrustum(). + */ +void accFrustum(GLdouble left, GLdouble right, GLdouble bottom, + GLdouble top, GLdouble nnear, GLdouble ffar, GLdouble pixdx, + GLdouble pixdy, GLdouble eyedx, GLdouble eyedy, GLdouble focus) +{ + GLdouble xwsize, ywsize; + GLdouble dx, dy; + GLint viewport[4]; + + glGetIntegerv (GL_VIEWPORT, viewport); + + xwsize = right - left; + ywsize = top - bottom; + + dx = -(pixdx*xwsize/(GLdouble) viewport[2] + eyedx*nnear/focus); + dy = -(pixdy*ywsize/(GLdouble) viewport[3] + eyedy*nnear/focus); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glFrustum (left + dx, right + dx, bottom + dy, top + dy, nnear, ffar); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTranslatef (-eyedx, -eyedy, 0.0); +} + +/* accPerspective() + * + * The first 4 arguments are identical to the gluPerspective() call. + * pixdx and pixdy are anti-alias jitter in pixels. + * Set both equal to 0.0 for no anti-alias jitter. + * eyedx and eyedy are depth-of field jitter in pixels. + * Set both equal to 0.0 for no depth of field effects. + * + * focus is distance from eye to plane in focus. + * focus must be greater than, but not equal to 0.0. + * + * Note that accPerspective() calls accFrustum(). + */ +void accPerspective(GLdouble fovy, GLdouble aspect, + GLdouble nnear, GLdouble ffar, GLdouble pixdx, GLdouble pixdy, + GLdouble eyedx, GLdouble eyedy, GLdouble focus) +{ + GLdouble fov2,left,right,bottom,top; + + fov2 = ((fovy*PI_) / 180.0) / 2.0; + + top = nnear / (cos(fov2) / sin(fov2)); + bottom = -top; + + right = top * aspect; + left = -right; + + accFrustum (left, right, bottom, top, nnear, ffar, + pixdx, pixdy, eyedx, eyedy, focus); +} + +/* Initialize lighting and other values. + */ +void init(void) +{ + GLfloat mat_ambient[] = { 1.0, 1.0, 1.0, 1.0 }; + GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 }; + GLfloat light_position[] = { 0.0, 0.0, 10.0, 1.0 }; + GLfloat lm_ambient[] = { 0.2, 0.2, 0.2, 1.0 }; + + glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient); + glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); + glMaterialf(GL_FRONT, GL_SHININESS, 50.0); + glLightfv(GL_LIGHT0, GL_POSITION, light_position); + glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lm_ambient); + + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + glEnable(GL_DEPTH_TEST); + glShadeModel (GL_FLAT); + + glClearColor(0.0, 0.0, 0.0, 0.0); + glClearAccum(0.0, 0.0, 0.0, 0.0); +} + +void displayObjects(void) +{ + GLfloat torus_diffuse[] = { 0.7, 0.7, 0.0, 1.0 }; + GLfloat cube_diffuse[] = { 0.0, 0.7, 0.7, 1.0 }; + GLfloat sphere_diffuse[] = { 0.7, 0.0, 0.7, 1.0 }; + GLfloat octa_diffuse[] = { 0.7, 0.4, 0.4, 1.0 }; + + glPushMatrix (); + glTranslatef (0.0, 0.0, -5.0); + glRotatef (30.0, 1.0, 0.0, 0.0); + + glPushMatrix (); + glTranslatef (-0.80, 0.35, 0.0); + glRotatef (100.0, 1.0, 0.0, 0.0); + glMaterialfv(GL_FRONT, GL_DIFFUSE, torus_diffuse); + glutSolidTorus (0.275, 0.85, 16, 16); + glPopMatrix (); + + glPushMatrix (); + glTranslatef (-0.75, -0.50, 0.0); + glRotatef (45.0, 0.0, 0.0, 1.0); + glRotatef (45.0, 1.0, 0.0, 0.0); + glMaterialfv(GL_FRONT, GL_DIFFUSE, cube_diffuse); + glutSolidCube (1.5); + glPopMatrix (); + + glPushMatrix (); + glTranslatef (0.75, 0.60, 0.0); + glRotatef (30.0, 1.0, 0.0, 0.0); + glMaterialfv(GL_FRONT, GL_DIFFUSE, sphere_diffuse); + glutSolidSphere (1.0, 16, 16); + glPopMatrix (); + + glPushMatrix (); + glTranslatef (0.70, -0.90, 0.25); + glMaterialfv(GL_FRONT, GL_DIFFUSE, octa_diffuse); + glutSolidOctahedron (); + glPopMatrix (); + + glPopMatrix (); +} + +#define ACSIZE 8 + +void display(void) +{ + GLint viewport[4]; + int jitter; + + glGetIntegerv (GL_VIEWPORT, viewport); + + glClear(GL_ACCUM_BUFFER_BIT); + for (jitter = 0; jitter < ACSIZE; jitter++) { + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + accPerspective (50.0, + (GLdouble) viewport[2]/(GLdouble) viewport[3], + 1.0, 15.0, j8[jitter].x, j8[jitter].y, 0.0, 0.0, 1.0); + displayObjects (); + glAccum(GL_ACCUM, 1.0/ACSIZE); + } + glAccum (GL_RETURN, 1.0); + glFlush(); +} + +void reshape(int w, int h) +{ + glViewport(0, 0, (GLsizei) w, (GLsizei) h); +} + +/* ARGSUSED1 */ +void keyboard(unsigned char key, int x, int y) +{ + switch (key) { + case 27: + exit(0); + break; + } +} + +/* Main Loop + * Be certain you request an accumulation buffer. + */ +int main(int argc, char** argv) +{ + glutInit(&argc, argv); + glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB + | GLUT_ACCUM | GLUT_DEPTH); + glutInitWindowSize (250, 250); + glutInitWindowPosition (100, 100); + glutCreateWindow (argv[0]); + init(); + glutReshapeFunc(reshape); + glutDisplayFunc(display); + glutKeyboardFunc(keyboard); + glutMainLoop(); + return 0; +} diff --git a/progs/redbook/alpha.c b/progs/redbook/alpha.c new file mode 100644 index 00000000000..6eeb45b96f1 --- /dev/null +++ b/progs/redbook/alpha.c @@ -0,0 +1,143 @@ +/* + * Copyright (c) 1993-1997, 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(R) is a registered trademark of Silicon Graphics, Inc. + */ + +/* + * alpha.c + * This program draws several overlapping filled polygons + * to demonstrate the effect order has on alpha blending results. + * Use the 't' key to toggle the order of drawing polygons. + */ +#include +#include + +static int leftFirst = GL_TRUE; + +/* Initialize alpha blending function. + */ +static void init(void) +{ + glEnable (GL_BLEND); + glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glShadeModel (GL_FLAT); + glClearColor (0.0, 0.0, 0.0, 0.0); +} + +static void drawLeftTriangle(void) +{ + /* draw yellow triangle on LHS of screen */ + + glBegin (GL_TRIANGLES); + glColor4f(1.0, 1.0, 0.0, 0.75); + glVertex3f(0.1, 0.9, 0.0); + glVertex3f(0.1, 0.1, 0.0); + glVertex3f(0.7, 0.5, 0.0); + glEnd(); +} + +static void drawRightTriangle(void) +{ + /* draw cyan triangle on RHS of screen */ + + glBegin (GL_TRIANGLES); + glColor4f(0.0, 1.0, 1.0, 0.75); + glVertex3f(0.9, 0.9, 0.0); + glVertex3f(0.3, 0.5, 0.0); + glVertex3f(0.9, 0.1, 0.0); + glEnd(); +} + +void display(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + if (leftFirst) { + drawLeftTriangle(); + drawRightTriangle(); + } + else { + drawRightTriangle(); + drawLeftTriangle(); + } + + glFlush(); +} + +void reshape(int w, int h) +{ + glViewport(0, 0, (GLsizei) w, (GLsizei) h); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + if (w <= h) + gluOrtho2D (0.0, 1.0, 0.0, 1.0*(GLfloat)h/(GLfloat)w); + else + gluOrtho2D (0.0, 1.0*(GLfloat)w/(GLfloat)h, 0.0, 1.0); +} + +/* ARGSUSED1 */ +void keyboard(unsigned char key, int x, int y) +{ + switch (key) { + case 't': + case 'T': + leftFirst = !leftFirst; + glutPostRedisplay(); + break; + case 27: /* Escape key */ + exit(0); + break; + default: + break; + } +} + +/* Main Loop + * Open window with initial window size, title bar, + * RGBA display mode, and handle input events. + */ +int main(int argc, char** argv) +{ + glutInit(&argc, argv); + glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); + glutInitWindowSize (200, 200); + glutCreateWindow (argv[0]); + init(); + glutReshapeFunc (reshape); + glutKeyboardFunc (keyboard); + glutDisplayFunc (display); + glutMainLoop(); + return 0; +} diff --git a/progs/redbook/alpha3D.c b/progs/redbook/alpha3D.c new file mode 100644 index 00000000000..6169bd162be --- /dev/null +++ b/progs/redbook/alpha3D.c @@ -0,0 +1,185 @@ +/* + * Copyright (c) 1993-1997, 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(R) is a registered trademark of Silicon Graphics, Inc. + */ + +/* + * alpha3D.c + * This program demonstrates how to intermix opaque and + * alpha blended polygons in the same scene, by using + * glDepthMask. Press the 'a' key to animate moving the + * transparent object through the opaque object. Press + * the 'r' key to reset the scene. + */ +#include +#include +#include + +#define MAXZ 8.0 +#define MINZ -8.0 +#define ZINC 4. + +static float solidZ = MAXZ; +static float transparentZ = MINZ; +static GLuint sphereList, cubeList; + +static void init(void) +{ + GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 0.15 }; + GLfloat mat_shininess[] = { 100.0 }; + GLfloat position[] = { 0.5, 0.5, 1.0, 0.0 }; + + glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); + glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess); + glLightfv(GL_LIGHT0, GL_POSITION, position); + + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + glEnable(GL_DEPTH_TEST); + + sphereList = glGenLists(1); + glNewList(sphereList, GL_COMPILE); + glutSolidSphere (0.4, 16, 16); + glEndList(); + + cubeList = glGenLists(1); + glNewList(cubeList, GL_COMPILE); + glutSolidCube (0.6); + glEndList(); +} + +void display(void) +{ + GLfloat mat_solid[] = { 0.75, 0.75, 0.0, 1.0 }; + GLfloat mat_zero[] = { 0.0, 0.0, 0.0, 1.0 }; + GLfloat mat_transparent[] = { 0.0, 0.8, 0.8, 0.6 }; + GLfloat mat_emission[] = { 0.0, 0.3, 0.3, 0.6 }; + + glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + glPushMatrix (); + glTranslatef (-0.15, -0.15, solidZ); + glMaterialfv(GL_FRONT, GL_EMISSION, mat_zero); + glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_solid); + glCallList (sphereList); + glPopMatrix (); + + glPushMatrix (); + glTranslatef (0.15, 0.15, transparentZ); + glRotatef (15.0, 1.0, 1.0, 0.0); + glRotatef (30.0, 0.0, 1.0, 0.0); + glMaterialfv(GL_FRONT, GL_EMISSION, mat_emission); + glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_transparent); + glEnable (GL_BLEND); + glDepthMask (GL_FALSE); + glBlendFunc (GL_SRC_ALPHA, GL_ONE); + glCallList (cubeList); + glDepthMask (GL_TRUE); + glDisable (GL_BLEND); + glPopMatrix (); + + glutSwapBuffers(); +} + +void reshape(int w, int h) +{ + glViewport(0, 0, (GLint) w, (GLint) h); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + if (w <= h) + glOrtho (-1.5, 1.5, -1.5*(GLfloat)h/(GLfloat)w, + 1.5*(GLfloat)h/(GLfloat)w, -10.0, 10.0); + else + glOrtho (-1.5*(GLfloat)w/(GLfloat)h, + 1.5*(GLfloat)w/(GLfloat)h, -1.5, 1.5, -10.0, 10.0); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); +} + +void animate(void) +{ + static double t0 = -1.; + if (solidZ <= MINZ || transparentZ >= MAXZ) + { + glutIdleFunc(NULL); + t0 = -1.; + } + else { + double t, dt; + t = glutGet(GLUT_ELAPSED_TIME) / 1000.; + if (t0 < 0.) + t0 = t; + dt = t - t0; + t0 = t; + solidZ -= ZINC*dt; + transparentZ += ZINC*dt; + glutPostRedisplay(); + } +} + +/* ARGSUSED1 */ +void keyboard(unsigned char key, int x, int y) +{ + switch (key) { + case 'a': + case 'A': + solidZ = MAXZ; + transparentZ = MINZ; + glutIdleFunc(animate); + break; + case 'r': + case 'R': + solidZ = MAXZ; + transparentZ = MINZ; + glutPostRedisplay(); + break; + case 27: + exit(0); + } +} + +int main(int argc, char** argv) +{ + glutInit(&argc, argv); + glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); + glutInitWindowSize(500, 500); + glutCreateWindow(argv[0]); + init(); + glutReshapeFunc(reshape); + glutKeyboardFunc(keyboard); + glutDisplayFunc(display); + glutMainLoop(); + return 0; +} diff --git a/progs/redbook/anti.c b/progs/redbook/anti.c new file mode 100644 index 00000000000..9eab0bc3511 --- /dev/null +++ b/progs/redbook/anti.c @@ -0,0 +1,124 @@ + +/* 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. + */ +/* + * anti.c + * This program draws antialiased lines in RGBA mode. + */ +#include +#include +#include + +/* Initialize antialiasing for RGBA mode, including alpha + * blending, hint, and line width. Print out implementation + * specific info on line width granularity and width. + */ +void myinit(void) +{ + GLfloat values[2]; + glGetFloatv (GL_LINE_WIDTH_GRANULARITY, values); + printf ("GL_LINE_WIDTH_GRANULARITY value is %3.1f\n", values[0]); + + glGetFloatv (GL_LINE_WIDTH_RANGE, values); + printf ("GL_LINE_WIDTH_RANGE values are %3.1f %3.1f\n", + values[0], values[1]); + + glEnable (GL_LINE_SMOOTH); + glEnable (GL_BLEND); + glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glHint (GL_LINE_SMOOTH_HINT, GL_DONT_CARE); + glLineWidth (1.5); + + glShadeModel(GL_FLAT); + glClearColor(0.0, 0.0, 0.0, 0.0); + glDepthFunc(GL_LESS); + glEnable(GL_DEPTH_TEST); +} + +/* display() draws an icosahedron with a large alpha value, 1.0. + */ +void display(void) +{ + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glColor4f (1.0, 1.0, 1.0, 1.0); + glutWireIcosahedron(); + glFlush(); +} + +void myReshape(int w, int h) +{ + glViewport(0, 0, w, h); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluPerspective (45.0, (GLfloat) w/(GLfloat) h, 3.0, 5.0); + + glMatrixMode(GL_MODELVIEW); + glLoadIdentity (); + glTranslatef (0.0, 0.0, -4.0); /* move object into view */ +} + +static void +key(unsigned char k, int x, int y) +{ + switch (k) { + case 27: /* Escape */ + exit(0); + break; + default: + return; + } + glutPostRedisplay(); +} + +/* Main Loop + * Open window with initial window size, title bar, + * RGBA display mode, and handle input events. + */ +int main(int argc, char** argv) +{ + glutInit(&argc, argv); + glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH); + glutCreateWindow (argv[0]); + myinit(); + glutReshapeFunc (myReshape); + glutDisplayFunc(display); + glutKeyboardFunc(key); + glutMainLoop(); + return 0; /* ANSI C requires main to return int. */ +} diff --git a/progs/redbook/bezcurve.c b/progs/redbook/bezcurve.c new file mode 100644 index 00000000000..5dee440396b --- /dev/null +++ b/progs/redbook/bezcurve.c @@ -0,0 +1,114 @@ +/* + * Copyright (c) 1993-1997, 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(R) is a registered trademark of Silicon Graphics, Inc. + */ + +/* bezcurve.c + * This program uses evaluators to draw a Bezier curve. + */ +#include +#include + +GLfloat ctrlpoints[4][3] = { + { -4.0, -4.0, 0.0}, { -2.0, 4.0, 0.0}, + {2.0, -4.0, 0.0}, {4.0, 4.0, 0.0}}; + +void init(void) +{ + glClearColor(0.0, 0.0, 0.0, 0.0); + glShadeModel(GL_FLAT); + glMap1f(GL_MAP1_VERTEX_3, 0.0, 1.0, 3, 4, &ctrlpoints[0][0]); + glEnable(GL_MAP1_VERTEX_3); +} + +void display(void) +{ + int i; + + glClear(GL_COLOR_BUFFER_BIT); + glColor3f(1.0, 1.0, 1.0); + glBegin(GL_LINE_STRIP); + for (i = 0; i <= 30; i++) + glEvalCoord1f((GLfloat) i/30.0); + glEnd(); + /* The following code displays the control points as dots. */ + glPointSize(5.0); + glColor3f(1.0, 1.0, 0.0); + glBegin(GL_POINTS); + for (i = 0; i < 4; i++) + glVertex3fv(&ctrlpoints[i][0]); + glEnd(); + glFlush(); +} + +void reshape(int w, int h) +{ + glViewport(0, 0, (GLsizei) w, (GLsizei) h); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + if (w <= h) + glOrtho(-5.0, 5.0, -5.0*(GLfloat)h/(GLfloat)w, + 5.0*(GLfloat)h/(GLfloat)w, -5.0, 5.0); + else + glOrtho(-5.0*(GLfloat)w/(GLfloat)h, + 5.0*(GLfloat)w/(GLfloat)h, -5.0, 5.0, -5.0, 5.0); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); +} + +/* ARGSUSED1 */ +void keyboard(unsigned char key, int x, int y) +{ + switch (key) { + case 27: + exit(0); + break; + } +} + +int main(int argc, char** argv) +{ + glutInit(&argc, argv); + glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); + glutInitWindowSize (500, 500); + glutInitWindowPosition (100, 100); + glutCreateWindow (argv[0]); + init (); + glutDisplayFunc(display); + glutReshapeFunc(reshape); + glutKeyboardFunc (keyboard); + glutMainLoop(); + return 0; +} diff --git a/progs/redbook/bezmesh.c b/progs/redbook/bezmesh.c new file mode 100644 index 00000000000..55e7e827f2b --- /dev/null +++ b/progs/redbook/bezmesh.c @@ -0,0 +1,162 @@ + +/* 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. + */ +/* bezsurf.c + * This program renders a lighted, filled Bezier surface, + * using two-dimensional evaluators. + */ +#include +#include + +GLfloat ctrlpoints[4][4][3] = +{ + { + {-1.5, -1.5, 4.0}, + {-0.5, -1.5, 2.0}, + {0.5, -1.5, -1.0}, + {1.5, -1.5, 2.0}}, + { + {-1.5, -0.5, 1.0}, + {-0.5, -0.5, 3.0}, + {0.5, -0.5, 0.0}, + {1.5, -0.5, -1.0}}, + { + {-1.5, 0.5, 4.0}, + {-0.5, 0.5, 0.0}, + {0.5, 0.5, 3.0}, + {1.5, 0.5, 4.0}}, + { + {-1.5, 1.5, -2.0}, + {-0.5, 1.5, -2.0}, + {0.5, 1.5, 0.0}, + {1.5, 1.5, -1.0}} +}; + +void +initlights(void) +{ + GLfloat ambient[] = + {0.2, 0.2, 0.2, 1.0}; + GLfloat position[] = + {0.0, 0.0, 2.0, 1.0}; + GLfloat mat_diffuse[] = + {0.6, 0.6, 0.6, 1.0}; + GLfloat mat_specular[] = + {1.0, 1.0, 1.0, 1.0}; + GLfloat mat_shininess[] = + {50.0}; + + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + + glLightfv(GL_LIGHT0, GL_AMBIENT, ambient); + glLightfv(GL_LIGHT0, GL_POSITION, position); + + glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); + glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); + glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess); +} + +void +display(void) +{ + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glPushMatrix(); + glRotatef(85.0, 1.0, 1.0, 1.0); + glEvalMesh2(GL_FILL, 0, 20, 0, 20); + glPopMatrix(); + glFlush(); +} + +void +myinit(void) +{ + glClearColor(0.0, 0.0, 0.0, 1.0); + glEnable(GL_DEPTH_TEST); + glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4, + 0, 1, 12, 4, &ctrlpoints[0][0][0]); + glEnable(GL_MAP2_VERTEX_3); + glEnable(GL_AUTO_NORMAL); + glEnable(GL_NORMALIZE); + glMapGrid2f(20, 0.0, 1.0, 20, 0.0, 1.0); + initlights(); /* for lighted version only */ +} + +void +myReshape(int w, int h) +{ + glViewport(0, 0, w, h); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + if (w <= h) + glOrtho(-4.0, 4.0, -4.0 * (GLfloat) h / (GLfloat) w, + 4.0 * (GLfloat) h / (GLfloat) w, -4.0, 4.0); + else + glOrtho(-4.0 * (GLfloat) w / (GLfloat) h, + 4.0 * (GLfloat) w / (GLfloat) h, -4.0, 4.0, -4.0, 4.0); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); +} + +static void +key(unsigned char k, int x, int y) +{ + switch (k) { + case 27: /* Escape */ + exit(0); + break; + default: + return; + } + glutPostRedisplay(); +} + +int +main(int argc, char **argv) +{ + glutInit(&argc, argv); + glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH); + glutCreateWindow(argv[0]); + myinit(); + glutReshapeFunc(myReshape); + glutDisplayFunc(display); + glutKeyboardFunc(key); + glutMainLoop(); + return 0; /* ANSI C requires main to return int. */ +} diff --git a/progs/redbook/checker.c b/progs/redbook/checker.c new file mode 100644 index 00000000000..06cbae7dd7e --- /dev/null +++ b/progs/redbook/checker.c @@ -0,0 +1,140 @@ + +/* 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. + */ +/* checker.c + * This program texture maps a checkerboard image onto + * two rectangles. This program clamps the texture, if + * the texture coordinates fall outside 0.0 and 1.0. + */ +#include +#include + +/* Create checkerboard texture */ +#define checkImageWidth 64 +#define checkImageHeight 64 +GLubyte checkImage[checkImageWidth][checkImageHeight][3]; + +void makeCheckImage(void) +{ + int i, j, c; + + for (i = 0; i < checkImageWidth; i++) { + for (j = 0; j < checkImageHeight; j++) { + c = ((((i&0x8)==0)^((j&0x8)==0)))*255; + checkImage[i][j][0] = (GLubyte) c; + checkImage[i][j][1] = (GLubyte) c; + checkImage[i][j][2] = (GLubyte) c; + } + } +} + +void myinit(void) +{ + glClearColor (0.0, 0.0, 0.0, 0.0); + glEnable(GL_DEPTH_TEST); + glDepthFunc(GL_LESS); + + makeCheckImage(); + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + glTexImage2D(GL_TEXTURE_2D, 0, 3, checkImageWidth, + checkImageHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, + &checkImage[0][0][0]); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); + glEnable(GL_TEXTURE_2D); + glShadeModel(GL_FLAT); +} + +void display(void) +{ + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glBegin(GL_QUADS); + glTexCoord2f(0.0, 0.0); glVertex3f(-2.0, -1.0, 0.0); + glTexCoord2f(0.0, 1.0); glVertex3f(-2.0, 1.0, 0.0); + glTexCoord2f(1.0, 1.0); glVertex3f(0.0, 1.0, 0.0); + glTexCoord2f(1.0, 0.0); glVertex3f(0.0, -1.0, 0.0); + + glTexCoord2f(0.0, 0.0); glVertex3f(1.0, -1.0, 0.0); + glTexCoord2f(0.0, 1.0); glVertex3f(1.0, 1.0, 0.0); + glTexCoord2f(1.0, 1.0); glVertex3f(2.41421, 1.0, -1.41421); + glTexCoord2f(1.0, 0.0); glVertex3f(2.41421, -1.0, -1.41421); + glEnd(); + glutSwapBuffers(); +} + +void myReshape(int w, int h) +{ + glViewport(0, 0, w, h); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluPerspective(60.0, 1.0*(GLfloat)w/(GLfloat)h, 1.0, 30.0); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTranslatef(0.0, 0.0, -3.6); +} + +static void +key(unsigned char k, int x, int y) +{ + switch (k) { + case 27: /* Escape */ + exit(0); + break; + default: + return; + } + glutPostRedisplay(); +} + +int +main(int argc, char** argv) +{ + glutInit(&argc, argv); + glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); + glutCreateWindow("checker"); + myinit(); + glutReshapeFunc (myReshape); + glutDisplayFunc(display); + glutKeyboardFunc(key); + glutMainLoop(); + return 0; /* ANSI C requires main to return int. */ +} diff --git a/progs/redbook/clip.c b/progs/redbook/clip.c new file mode 100644 index 00000000000..90816f2e278 --- /dev/null +++ b/progs/redbook/clip.c @@ -0,0 +1,108 @@ +/* + * Copyright (c) 1993-1997, 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(R) is a registered trademark of Silicon Graphics, Inc. + */ + +/* + * clip.c + * This program demonstrates arbitrary clipping planes. + */ +#include +#include + +void init(void) +{ + glClearColor (0.0, 0.0, 0.0, 0.0); + glShadeModel (GL_FLAT); +} + +void display(void) +{ + GLdouble eqn[4] = {0.0, 1.0, 0.0, 0.0}; + GLdouble eqn2[4] = {1.0, 0.0, 0.0, 0.0}; + + glClear(GL_COLOR_BUFFER_BIT); + + glColor3f (1.0, 1.0, 1.0); + glPushMatrix(); + glTranslatef (0.0, 0.0, -5.0); + +/* clip lower half -- y < 0 */ + glClipPlane (GL_CLIP_PLANE0, eqn); + glEnable (GL_CLIP_PLANE0); +/* clip left half -- x < 0 */ + glClipPlane (GL_CLIP_PLANE1, eqn2); + glEnable (GL_CLIP_PLANE1); + + glRotatef (90.0, 1.0, 0.0, 0.0); + glutWireSphere(1.0, 20, 16); + glPopMatrix(); + + glFlush (); +} + +void reshape (int w, int h) +{ + glViewport (0, 0, (GLsizei) w, (GLsizei) h); + glMatrixMode (GL_PROJECTION); + glLoadIdentity (); + gluPerspective(60.0, (GLfloat) w/(GLfloat) h, 1.0, 20.0); + glMatrixMode (GL_MODELVIEW); +} + +/* ARGSUSED1 */ +void keyboard(unsigned char key, int x, int y) +{ + switch (key) { + case 27: + exit(0); + break; + } +} + +int main(int argc, char** argv) +{ + glutInit(&argc, argv); + glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); + glutInitWindowSize (500, 500); + glutInitWindowPosition (100, 100); + glutCreateWindow (argv[0]); + init (); + glutDisplayFunc(display); + glutReshapeFunc(reshape); + glutKeyboardFunc(keyboard); + glutMainLoop(); + return 0; +} diff --git a/progs/redbook/colormat.c b/progs/redbook/colormat.c new file mode 100644 index 00000000000..9db4491bac5 --- /dev/null +++ b/progs/redbook/colormat.c @@ -0,0 +1,153 @@ +/* + * Copyright (c) 1993-1997, 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(R) is a registered trademark of Silicon Graphics, Inc. + */ + +/* + * colormat.c + * After initialization, the program will be in + * ColorMaterial mode. Interaction: pressing the + * mouse buttons will change the diffuse reflection values. + */ +#include +#include + +GLfloat diffuseMaterial[4] = { 0.5, 0.5, 0.5, 1.0 }; + +/* Initialize material property, light source, lighting model, + * and depth buffer. + */ +void init(void) +{ + GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 }; + GLfloat light_position[] = { 1.0, 1.0, 1.0, 0.0 }; + + glClearColor (0.0, 0.0, 0.0, 0.0); + glShadeModel (GL_SMOOTH); + glEnable(GL_DEPTH_TEST); + glMaterialfv(GL_FRONT, GL_DIFFUSE, diffuseMaterial); + glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); + glMaterialf(GL_FRONT, GL_SHININESS, 25.0); + glLightfv(GL_LIGHT0, GL_POSITION, light_position); + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + + glColorMaterial(GL_FRONT, GL_DIFFUSE); + glEnable(GL_COLOR_MATERIAL); +} + +void display(void) +{ + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glutSolidSphere(1.0, 20, 16); + glFlush (); +} + +void reshape (int w, int h) +{ + glViewport (0, 0, (GLsizei) w, (GLsizei) h); + glMatrixMode (GL_PROJECTION); + glLoadIdentity(); + if (w <= h) + glOrtho (-1.5, 1.5, -1.5*(GLfloat)h/(GLfloat)w, + 1.5*(GLfloat)h/(GLfloat)w, -10.0, 10.0); + else + glOrtho (-1.5*(GLfloat)w/(GLfloat)h, + 1.5*(GLfloat)w/(GLfloat)h, -1.5, 1.5, -10.0, 10.0); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); +} + +/* ARGSUSED2 */ +void mouse(int button, int state, int x, int y) +{ + switch (button) { + case GLUT_LEFT_BUTTON: + if (state == GLUT_DOWN) { + diffuseMaterial[0] += 0.1; + if (diffuseMaterial[0] > 1.0) + diffuseMaterial[0] = 0.0; + glColor4fv(diffuseMaterial); + glutPostRedisplay(); + } + break; + case GLUT_MIDDLE_BUTTON: + if (state == GLUT_DOWN) { + diffuseMaterial[1] += 0.1; + if (diffuseMaterial[1] > 1.0) + diffuseMaterial[1] = 0.0; + glColor4fv(diffuseMaterial); + glutPostRedisplay(); + } + break; + case GLUT_RIGHT_BUTTON: + if (state == GLUT_DOWN) { + diffuseMaterial[2] += 0.1; + if (diffuseMaterial[2] > 1.0) + diffuseMaterial[2] = 0.0; + glColor4fv(diffuseMaterial); + glutPostRedisplay(); + } + break; + default: + break; + } +} + +/* ARGSUSED1 */ +void keyboard(unsigned char key, int x, int y) +{ + switch (key) { + case 27: + exit(0); + break; + } +} + +int main(int argc, char** argv) +{ + glutInit(&argc, argv); + glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH); + glutInitWindowSize (500, 500); + glutInitWindowPosition (100, 100); + glutCreateWindow (argv[0]); + init (); + glutDisplayFunc(display); + glutReshapeFunc(reshape); + glutMouseFunc(mouse); + glutKeyboardFunc(keyboard); + glutMainLoop(); + return 0; +} diff --git a/progs/redbook/cube.c b/progs/redbook/cube.c new file mode 100644 index 00000000000..5ecc6280f33 --- /dev/null +++ b/progs/redbook/cube.c @@ -0,0 +1,97 @@ +/* + * Copyright (c) 1993-1997, 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(R) is a registered trademark of Silicon Graphics, Inc. + */ + +/* + * cube.c + * This program demonstrates a single modeling transformation, + * glScalef() and a single viewing transformation, gluLookAt(). + * A wireframe cube is rendered. + */ +#include +#include + +void init(void) +{ + glClearColor (0.0, 0.0, 0.0, 0.0); + glShadeModel (GL_FLAT); +} + +void display(void) +{ + glClear (GL_COLOR_BUFFER_BIT); + glColor3f (1.0, 1.0, 1.0); + glLoadIdentity (); /* clear the matrix */ + /* viewing transformation */ + gluLookAt (0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); + glScalef (1.0, 2.0, 1.0); /* modeling transformation */ + glutWireCube (1.0); + glFlush (); +} + +void reshape (int w, int h) +{ + glViewport (0, 0, (GLsizei) w, (GLsizei) h); + glMatrixMode (GL_PROJECTION); + glLoadIdentity (); + glFrustum (-1.0, 1.0, -1.0, 1.0, 1.5, 20.0); + glMatrixMode (GL_MODELVIEW); +} + +/* ARGSUSED1 */ +void keyboard(unsigned char key, int x, int y) +{ + switch (key) { + case 27: + exit(0); + break; + } +} + +int main(int argc, char** argv) +{ + glutInit(&argc, argv); + glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); + glutInitWindowSize (500, 500); + glutInitWindowPosition (100, 100); + glutCreateWindow (argv[0]); + init (); + glutDisplayFunc(display); + glutReshapeFunc(reshape); + glutKeyboardFunc(keyboard); + glutMainLoop(); + return 0; +} diff --git a/progs/redbook/depthcue.c b/progs/redbook/depthcue.c new file mode 100644 index 00000000000..a3e5b743aa7 --- /dev/null +++ b/progs/redbook/depthcue.c @@ -0,0 +1,115 @@ + +/* 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. + */ +/* + * depthcue.c + * This program draws a wireframe model, which uses + * intensity (brightness) to give clues to distance. + * Fog is used to achieve this effect. + */ +#include +#include + +/* Initialize linear fog for depth cueing. + */ +void myinit(void) +{ + GLfloat fogColor[4] = {0.0, 0.0, 0.0, 1.0}; + + glEnable(GL_FOG); + glFogi (GL_FOG_MODE, GL_LINEAR); + glHint (GL_FOG_HINT, GL_NICEST); /* per pixel */ + glFogf (GL_FOG_START, 3.0); + glFogf (GL_FOG_END, 5.0); + glFogfv (GL_FOG_COLOR, fogColor); + glClearColor(0.0, 0.0, 0.0, 1.0); + + glDepthFunc(GL_LESS); + glEnable(GL_DEPTH_TEST); + glShadeModel(GL_FLAT); +} + +/* display() draws an icosahedron. + */ +void display(void) +{ + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glColor3f (1.0, 1.0, 1.0); + glutWireIcosahedron(); + glFlush(); +} + +void myReshape(int w, int h) +{ + glViewport(0, 0, w, h); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluPerspective (45.0, (GLfloat) w/(GLfloat) h, 3.0, 5.0); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity (); + glTranslatef (0.0, 0.0, -4.0); /* move object into view */ +} + +static void +key(unsigned char k, int x, int y) +{ + switch (k) { + case 27: /* Escape */ + exit(0); + break; + default: + return; + } + glutPostRedisplay(); +} + +/* Main Loop + */ +int main(int argc, char** argv) +{ + glutInit(&argc, argv); + glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH); + glutCreateWindow(argv[0]); + myinit(); + glutReshapeFunc(myReshape); + glutDisplayFunc(display); + glutKeyboardFunc(key); + glutMainLoop(); + return 0; /* ANSI C requires main to return int. */ +} diff --git a/progs/redbook/dof.c b/progs/redbook/dof.c new file mode 100644 index 00000000000..6673dc2d54f --- /dev/null +++ b/progs/redbook/dof.c @@ -0,0 +1,251 @@ + +/* 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. + */ +/* + * dof.c + * This program demonstrates use of the accumulation buffer to + * create an out-of-focus depth-of-field effect. The teapots + * are drawn several times into the accumulation buffer. The + * viewing volume is jittered, except at the focal point, where + * the viewing volume is at the same position, each time. In + * this case, the gold teapot remains in focus. + */ +#include +#include +#include +#include "jitter.h" + +#define PI_ 3.14159265358979323846 + +/* accFrustum() + * The first 6 arguments are identical to the glFrustum() call. + * + * pixdx and pixdy are anti-alias jitter in pixels. + * Set both equal to 0.0 for no anti-alias jitter. + * eyedx and eyedy are depth-of field jitter in pixels. + * Set both equal to 0.0 for no depth of field effects. + * + * focus is distance from eye to plane in focus. + * focus must be greater than, but not equal to 0.0. + * + * Note that accFrustum() calls glTranslatef(). You will + * probably want to insure that your ModelView matrix has been + * initialized to identity before calling accFrustum(). + */ +void accFrustum(GLdouble left, GLdouble right, GLdouble bottom, + GLdouble top, GLdouble nnear, GLdouble ffar, GLdouble pixdx, + GLdouble pixdy, GLdouble eyedx, GLdouble eyedy, GLdouble focus) +{ + GLdouble xwsize, ywsize; + GLdouble dx, dy; + GLint viewport[4]; + + glGetIntegerv (GL_VIEWPORT, viewport); + + xwsize = right - left; + ywsize = top - bottom; + + dx = -(pixdx*xwsize/(GLdouble) viewport[2] + eyedx*nnear/focus); + dy = -(pixdy*ywsize/(GLdouble) viewport[3] + eyedy*nnear/focus); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glFrustum (left + dx, right + dx, bottom + dy, top + dy, nnear, ffar); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTranslatef (-eyedx, -eyedy, 0.0); +} + +/* accPerspective() + * + * The first 4 arguments are identical to the gluPerspective() call. + * pixdx and pixdy are anti-alias jitter in pixels. + * Set both equal to 0.0 for no anti-alias jitter. + * eyedx and eyedy are depth-of field jitter in pixels. + * Set both equal to 0.0 for no depth of field effects. + * + * focus is distance from eye to plane in focus. + * focus must be greater than, but not equal to 0.0. + * + * Note that accPerspective() calls accFrustum(). + */ +void accPerspective(GLdouble fovy, GLdouble aspect, + GLdouble nnear, GLdouble ffar, GLdouble pixdx, GLdouble pixdy, + GLdouble eyedx, GLdouble eyedy, GLdouble focus) +{ + GLdouble fov2,left,right,bottom,top; + + fov2 = ((fovy*PI_) / 180.0) / 2.0; + + top = nnear / (cos(fov2) / sin(fov2)); + bottom = -top; + + right = top * aspect; + left = -right; + + accFrustum (left, right, bottom, top, nnear, ffar, + pixdx, pixdy, eyedx, eyedy, focus); +} + +void myinit(void) +{ + GLfloat ambient[] = { 0.0, 0.0, 0.0, 1.0 }; + GLfloat diffuse[] = { 1.0, 1.0, 1.0, 1.0 }; + GLfloat position[] = { 0.0, 3.0, 3.0, 0.0 }; + + GLfloat lmodel_ambient[] = { 0.2, 0.2, 0.2, 1.0 }; + GLfloat local_view[] = { 0.0 }; + + glEnable(GL_DEPTH_TEST); + glDepthFunc(GL_LESS); + + glLightfv(GL_LIGHT0, GL_AMBIENT, ambient); + glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse); + glLightfv(GL_LIGHT0, GL_POSITION, position); + + glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient); + glLightModelfv(GL_LIGHT_MODEL_LOCAL_VIEWER, local_view); + + glFrontFace (GL_CW); + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + glEnable(GL_AUTO_NORMAL); + glEnable(GL_NORMALIZE); + + glMatrixMode (GL_MODELVIEW); + glLoadIdentity (); + + glClearColor(0.0, 0.0, 0.0, 0.0); + glClearAccum(0.0, 0.0, 0.0, 0.0); +} + +void renderTeapot (GLfloat x, GLfloat y, GLfloat z, + GLfloat ambr, GLfloat ambg, GLfloat ambb, + GLfloat difr, GLfloat difg, GLfloat difb, + GLfloat specr, GLfloat specg, GLfloat specb, GLfloat shine) +{ + float mat[4]; + + glPushMatrix(); + glTranslatef (x, y, z); + mat[0] = ambr; mat[1] = ambg; mat[2] = ambb; mat[3] = 1.0; + glMaterialfv (GL_FRONT, GL_AMBIENT, mat); + mat[0] = difr; mat[1] = difg; mat[2] = difb; + glMaterialfv (GL_FRONT, GL_DIFFUSE, mat); + mat[0] = specr; mat[1] = specg; mat[2] = specb; + glMaterialfv (GL_FRONT, GL_SPECULAR, mat); + glMaterialf (GL_FRONT, GL_SHININESS, shine*128.0); + glutSolidTeapot(0.5); + glPopMatrix(); +} + +/* display() draws 5 teapots into the accumulation buffer + * several times; each time with a jittered perspective. + * The focal point is at z = 5.0, so the gold teapot will + * stay in focus. The amount of jitter is adjusted by the + * magnitude of the accPerspective() jitter; in this example, 0.33. + * In this example, the teapots are drawn 8 times. See jitter.h + */ +void display(void) +{ + int jitter; + GLint viewport[4]; + + glGetIntegerv (GL_VIEWPORT, viewport); + glClear(GL_ACCUM_BUFFER_BIT); + + for (jitter = 0; jitter < 8; jitter++) { + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + accPerspective (45.0, + (GLdouble) viewport[2]/(GLdouble) viewport[3], + 1.0, 15.0, 0.0, 0.0, + 0.33*j8[jitter].x, 0.33*j8[jitter].y, 5.0); +/* ruby, gold, silver, emerald, and cyan teapots */ + renderTeapot (-1.1, -0.5, -4.5, 0.1745, 0.01175, 0.01175, + 0.61424, 0.04136, 0.04136, 0.727811, 0.626959, 0.626959, 0.6); + renderTeapot (-0.5, -0.5, -5.0, 0.24725, 0.1995, 0.0745, + 0.75164, 0.60648, 0.22648, 0.628281, 0.555802, 0.366065, 0.4); + renderTeapot (0.2, -0.5, -5.5, 0.19225, 0.19225, 0.19225, + 0.50754, 0.50754, 0.50754, 0.508273, 0.508273, 0.508273, 0.4); + renderTeapot (1.0, -0.5, -6.0, 0.0215, 0.1745, 0.0215, + 0.07568, 0.61424, 0.07568, 0.633, 0.727811, 0.633, 0.6); + renderTeapot (1.8, -0.5, -6.5, 0.0, 0.1, 0.06, 0.0, 0.50980392, + 0.50980392, 0.50196078, 0.50196078, 0.50196078, .25); + glAccum (GL_ACCUM, 0.125); + } + + glAccum (GL_RETURN, 1.0); + glFlush(); +} + +void myReshape(int w, int h) +{ + glViewport(0, 0, w, h); +} + +static void +key(unsigned char k, int x, int y) +{ + switch (k) { + case 27: /* Escape */ + exit(0); + break; + default: + return; + } + glutPostRedisplay(); +} + +/* Main Loop + * Open window with initial window size, title bar, + * RGBA display mode, depth buffer, and handle input events. + */ +int main(int argc, char** argv) +{ + glutInit(&argc, argv); + glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB + | GLUT_ACCUM | GLUT_DEPTH); + glutCreateWindow (argv[0]); + myinit(); + glutReshapeFunc(myReshape); + glutDisplayFunc(display); + glutKeyboardFunc(key); + glutMainLoop(); + return 0; /* ANSI C requires main to return int. */ +} diff --git a/progs/redbook/double.c b/progs/redbook/double.c new file mode 100644 index 00000000000..3153c70cc1d --- /dev/null +++ b/progs/redbook/double.c @@ -0,0 +1,146 @@ +/* + * Copyright (c) 1993-1997, 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(R) is a registered trademark of Silicon Graphics, Inc. + */ + +/* + * double.c + * This is a simple double buffered program. + * Pressing the left mouse button rotates the rectangle. + * Pressing the middle mouse button stops the rotation. + */ +#include +#include + +static GLfloat spin = 0.0; +static GLdouble t0 = 0.; + +void display(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + glPushMatrix(); + glRotatef(spin, 0.0, 0.0, 1.0); + glColor3f(1.0, 1.0, 1.0); + glRectf(-25.0, -25.0, 25.0, 25.0); + glPopMatrix(); + + glutSwapBuffers(); +} + +GLdouble gettime(void) +{ + return (GLdouble)(glutGet(GLUT_ELAPSED_TIME)) / 1000.; +} + +void spinDisplay(void) +{ + GLdouble t, dt; + t = gettime(); + dt = t - t0; + t0 = t; + spin = spin + 120.0*dt; + if (spin > 360.0) + spin = spin - 360.0; + glutPostRedisplay(); +} + +void init(void) +{ + glClearColor (0.0, 0.0, 0.0, 0.0); + glShadeModel (GL_FLAT); +} + +void reshape(int w, int h) +{ + glViewport (0, 0, (GLsizei) w, (GLsizei) h); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-50.0, 50.0, -50.0, 50.0, -1.0, 1.0); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); +} + +/* ARGSUSED2 */ +void mouse(int button, int state, int x, int y) +{ + switch (button) { + case GLUT_LEFT_BUTTON: + if (state == GLUT_DOWN) + { + t0 = gettime(); + glutIdleFunc(spinDisplay); + } + break; + case GLUT_MIDDLE_BUTTON: + if (state == GLUT_DOWN) + glutIdleFunc(NULL); + break; + default: + break; + } +} + +static void +key(unsigned char k, int x, int y) +{ + switch (k) { + case 27: /* Escape */ + exit(0); + break; + default: + return; + } + glutPostRedisplay(); +} + +/* + * Request double buffer display mode. + * Register mouse input callback functions + */ +int main(int argc, char** argv) +{ + glutInit(&argc, argv); + glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB); + glutInitWindowSize (250, 250); + glutInitWindowPosition (100, 100); + glutCreateWindow (argv[0]); + init (); + glutDisplayFunc(display); + glutReshapeFunc(reshape); + glutMouseFunc(mouse); + glutKeyboardFunc(key); + glutMainLoop(); + return 0; /* ANSI C requires main to return int. */ +} diff --git a/progs/redbook/drawf.c b/progs/redbook/drawf.c new file mode 100644 index 00000000000..5bcccb6aeac --- /dev/null +++ b/progs/redbook/drawf.c @@ -0,0 +1,103 @@ +/* + * Copyright (c) 1993-1997, 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(R) is a registered trademark of Silicon Graphics, Inc. + */ + +/* + * drawf.c + * Draws the bitmapped letter F on the screen (several times). + * This demonstrates use of the glBitmap() call. + */ +#include +#include + +GLubyte rasters[24] = { + 0xc0, 0x00, 0xc0, 0x00, 0xc0, 0x00, 0xc0, 0x00, 0xc0, 0x00, + 0xff, 0x00, 0xff, 0x00, 0xc0, 0x00, 0xc0, 0x00, 0xc0, 0x00, + 0xff, 0xc0, 0xff, 0xc0}; + +void init(void) +{ + glPixelStorei (GL_UNPACK_ALIGNMENT, 1); + glClearColor (0.0, 0.0, 0.0, 0.0); +} + +void display(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + glColor3f (1.0, 1.0, 1.0); + glRasterPos2i (20, 20); + glBitmap (10, 12, 0.0, 0.0, 11.0, 0.0, rasters); + glBitmap (10, 12, 0.0, 0.0, 11.0, 0.0, rasters); + glBitmap (10, 12, 0.0, 0.0, 11.0, 0.0, rasters); + glFlush(); +} + +void reshape(int w, int h) +{ + glViewport(0, 0, (GLsizei) w, (GLsizei) h); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho (0, w, 0, h, -1.0, 1.0); + glMatrixMode(GL_MODELVIEW); +} + +/* ARGSUSED1 */ +void keyboard(unsigned char key, int x, int y) +{ + switch (key) { + case 27: + exit(0); + } +} + +/* Main Loop + * Open window with initial window size, title bar, + * RGBA display mode, and handle input events. + */ +int main(int argc, char** argv) +{ + glutInit(&argc, argv); + glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); + glutInitWindowSize(100, 100); + glutInitWindowPosition(100, 100); + glutCreateWindow(argv[0]); + init(); + glutReshapeFunc(reshape); + glutKeyboardFunc(keyboard); + glutDisplayFunc(display); + glutMainLoop(); + return 0; +} diff --git a/progs/redbook/feedback.c b/progs/redbook/feedback.c new file mode 100644 index 00000000000..cc685d55d34 --- /dev/null +++ b/progs/redbook/feedback.c @@ -0,0 +1,173 @@ +/* + * Copyright (c) 1993-1997, 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(R) is a registered trademark of Silicon Graphics, Inc. + */ + +/* + * feedback.c + * This program demonstrates use of OpenGL feedback. First, + * a lighting environment is set up and a few lines are drawn. + * Then feedback mode is entered, and the same lines are + * drawn. The results in the feedback buffer are printed. + */ +#include +#include +#include + +/* Initialize lighting. + */ +void init(void) +{ + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); +} + +/* Draw a few lines and two points, one of which will + * be clipped. If in feedback mode, a passthrough token + * is issued between the each primitive. + */ +void drawGeometry (GLenum mode) +{ + glBegin (GL_LINE_STRIP); + glNormal3f (0.0, 0.0, 1.0); + glVertex3f (30.0, 30.0, 0.0); + glVertex3f (50.0, 60.0, 0.0); + glVertex3f (70.0, 40.0, 0.0); + glEnd (); + if (mode == GL_FEEDBACK) + glPassThrough (1.0); + glBegin (GL_POINTS); + glVertex3f (-100.0, -100.0, -100.0); /* will be clipped */ + glEnd (); + if (mode == GL_FEEDBACK) + glPassThrough (2.0); + glBegin (GL_POINTS); + glNormal3f (0.0, 0.0, 1.0); + glVertex3f (50.0, 50.0, 0.0); + glEnd (); +} + +/* Write contents of one vertex to stdout. */ +void print3DcolorVertex (GLint size, GLint *count, + GLfloat *buffer) +{ + int i; + + printf (" "); + for (i = 0; i < 7; i++) { + printf ("%4.2f ", buffer[size-(*count)]); + *count = *count - 1; + } + printf ("\n"); +} + +/* Write contents of entire buffer. (Parse tokens!) */ +void printBuffer(GLint size, GLfloat *buffer) +{ + GLint count; + GLfloat token; + + count = size; + while (count) { + token = buffer[size-count]; count--; + if (token == GL_PASS_THROUGH_TOKEN) { + printf ("GL_PASS_THROUGH_TOKEN\n"); + printf (" %4.2f\n", buffer[size-count]); + count--; + } + else if (token == GL_POINT_TOKEN) { + printf ("GL_POINT_TOKEN\n"); + print3DcolorVertex (size, &count, buffer); + } + else if (token == GL_LINE_TOKEN) { + printf ("GL_LINE_TOKEN\n"); + print3DcolorVertex (size, &count, buffer); + print3DcolorVertex (size, &count, buffer); + } + else if (token == GL_LINE_RESET_TOKEN) { + printf ("GL_LINE_RESET_TOKEN\n"); + print3DcolorVertex (size, &count, buffer); + print3DcolorVertex (size, &count, buffer); + } + } +} + +void display(void) +{ + GLfloat feedBuffer[1024]; + GLint size; + + glMatrixMode (GL_PROJECTION); + glLoadIdentity (); + glOrtho (0.0, 100.0, 0.0, 100.0, 0.0, 1.0); + + glClearColor (0.0, 0.0, 0.0, 0.0); + glClear(GL_COLOR_BUFFER_BIT); + drawGeometry (GL_RENDER); + + glFeedbackBuffer (1024, GL_3D_COLOR, feedBuffer); + (void) glRenderMode (GL_FEEDBACK); + drawGeometry (GL_FEEDBACK); + + size = glRenderMode (GL_RENDER); + printBuffer (size, feedBuffer); + + glFinish(); +} + +/* ARGSUSED1 */ +void keyboard(unsigned char key, int x, int y) +{ + switch (key) { + case 27: + exit(0); + break; + } +} + +/* Main Loop */ +int main(int argc, char** argv) +{ + glutInit(&argc, argv); + glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); + glutInitWindowSize (100, 100); + glutInitWindowPosition (100, 100); + glutCreateWindow(argv[0]); + init(); + glutDisplayFunc(display); + glutKeyboardFunc (keyboard); + glutMainLoop(); + return 0; +} diff --git a/progs/redbook/fog.c b/progs/redbook/fog.c new file mode 100644 index 00000000000..14c7700eccf --- /dev/null +++ b/progs/redbook/fog.c @@ -0,0 +1,200 @@ + +/* 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. + */ +/* + * fog.c + * This program draws 5 red teapots, each at a different + * z distance from the eye, in different types of fog. + * Pressing the left mouse button chooses between 3 types of + * fog: exponential, exponential squared, and linear. + * In this program, there is a fixed density value, as well + * as fixed start and end values for the linear fog. + */ +#include +#include +#include + +GLint fogMode; + +void +selectFog(int mode) +{ + switch(mode) { + case GL_LINEAR: + glFogf(GL_FOG_START, 1.0); + glFogf(GL_FOG_END, 5.0); + /* falls through */ + case GL_EXP2: + case GL_EXP: + glFogi(GL_FOG_MODE, mode); + glutPostRedisplay(); + break; + case 0: + exit(0); + } +} + +/* Initialize z-buffer, projection matrix, light source, + * and lighting model. Do not specify a material property here. + */ +void +myinit(void) +{ + GLfloat position[] = + {0.0, 3.0, 3.0, 0.0}; + GLfloat local_view[] = + {0.0}; + + glEnable(GL_DEPTH_TEST); + glDepthFunc(GL_LESS); + + glLightfv(GL_LIGHT0, GL_POSITION, position); + glLightModelfv(GL_LIGHT_MODEL_LOCAL_VIEWER, local_view); + + glFrontFace(GL_CW); + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + glEnable(GL_AUTO_NORMAL); + glEnable(GL_NORMALIZE); + glEnable(GL_FOG); + { + GLfloat fogColor[4] = + {0.5, 0.5, 0.5, 1.0}; + + fogMode = GL_EXP; + glFogi(GL_FOG_MODE, fogMode); + glFogfv(GL_FOG_COLOR, fogColor); + glFogf(GL_FOG_DENSITY, 0.35); + glHint(GL_FOG_HINT, GL_DONT_CARE); + glClearColor(0.5, 0.5, 0.5, 1.0); + } +} + +void +renderRedTeapot(GLfloat x, GLfloat y, GLfloat z) +{ + float mat[4]; + + glPushMatrix(); + glTranslatef(x, y, z); + mat[0] = 0.1745; + mat[1] = 0.01175; + mat[2] = 0.01175; + mat[3] = 1.0; + glMaterialfv(GL_FRONT, GL_AMBIENT, mat); + mat[0] = 0.61424; + mat[1] = 0.04136; + mat[2] = 0.04136; + glMaterialfv(GL_FRONT, GL_DIFFUSE, mat); + mat[0] = 0.727811; + mat[1] = 0.626959; + mat[2] = 0.626959; + glMaterialfv(GL_FRONT, GL_SPECULAR, mat); + glMaterialf(GL_FRONT, GL_SHININESS, 0.6 * 128.0); + glutSolidTeapot(1.0); + glPopMatrix(); +} + +/* display() draws 5 teapots at different z positions. + */ +void +display(void) +{ + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + renderRedTeapot(-4.0, -0.5, -1.0); + renderRedTeapot(-2.0, -0.5, -2.0); + renderRedTeapot(0.0, -0.5, -3.0); + renderRedTeapot(2.0, -0.5, -4.0); + renderRedTeapot(4.0, -0.5, -5.0); + glFlush(); +} + +void +myReshape(int w, int h) +{ + glViewport(0, 0, w, h); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + if (w <= (h * 3)) + glOrtho(-6.0, 6.0, -2.0 * ((GLfloat) h * 3) / (GLfloat) w, + 2.0 * ((GLfloat) h * 3) / (GLfloat) w, 0.0, 10.0); + else + glOrtho(-6.0 * (GLfloat) w / ((GLfloat) h * 3), + 6.0 * (GLfloat) w / ((GLfloat) h * 3), -2.0, 2.0, 0.0, 10.0); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); +} + +static void +key(unsigned char k, int x, int y) +{ + switch (k) { + case 27: /* Escape */ + exit(0); + break; + default: + return; + } + glutPostRedisplay(); +} + +/* Main Loop + * Open window with initial window size, title bar, + * RGBA display mode, depth buffer, and handle input events. + */ +int +main(int argc, char **argv) +{ + glutInit(&argc, argv); + glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH); + glutInitWindowSize(450, 150); + glutCreateWindow(argv[0]); + myinit(); + glutReshapeFunc(myReshape); + glutDisplayFunc(display); + glutCreateMenu(selectFog); + glutAddMenuEntry("Fog EXP", GL_EXP); + glutAddMenuEntry("Fog EXP2", GL_EXP2); + glutAddMenuEntry("Fog LINEAR", GL_LINEAR); + glutAddMenuEntry("Quit", 0); + glutAttachMenu(GLUT_RIGHT_BUTTON); + glutKeyboardFunc(key); + glutMainLoop(); + return 0; /* ANSI C requires main to return int. */ +} diff --git a/progs/redbook/fogindex.c b/progs/redbook/fogindex.c new file mode 100644 index 00000000000..b8bb691e288 --- /dev/null +++ b/progs/redbook/fogindex.c @@ -0,0 +1,152 @@ + +/* 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. + */ +/* + * fogindex.c + * This program demonstrates fog in color index mode. + * Three cones are drawn at different z values in a linear + * fog. 32 contiguous colors (from 16 to 47) are loaded + * with a color ramp. + */ +#include +#include + +/* Initialize color map and fog. Set screen clear color + * to end of color ramp. + */ +#define NUM_COLORS 32 +#define RAMPSTART 16 + +void +myinit(void) +{ + int i; + + glEnable(GL_DEPTH_TEST); + glDepthFunc(GL_LESS); + for (i = 0; i < NUM_COLORS; i++) { + GLfloat shade; + shade = (GLfloat) (NUM_COLORS - i) / (GLfloat) NUM_COLORS; + glutSetColor(16 + i, shade, shade, shade); + } + glEnable(GL_FOG); + + glFogi(GL_FOG_MODE, GL_LINEAR); + glFogi(GL_FOG_INDEX, NUM_COLORS); + glFogf(GL_FOG_START, 0.0); + glFogf(GL_FOG_END, 4.0); + glHint(GL_FOG_HINT, GL_NICEST); + glClearIndex((GLfloat) (NUM_COLORS + RAMPSTART - 1)); +} + +/* display() renders 3 cones at different z positions. + */ +void +display(void) +{ + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glPushMatrix(); + glTranslatef(-1.0, -1.0, -1.0); + glRotatef(-90.0, 1.0, 0.0, 0.0); + glIndexi(RAMPSTART); + glutSolidCone(1.0, 2.0, 10, 10); + glPopMatrix(); + + glPushMatrix(); + glTranslatef(0.0, -1.0, -2.25); + glRotatef(-90.0, 1.0, 0.0, 0.0); + glIndexi(RAMPSTART); + glutSolidCone(1.0, 2.0, 10, 10); + glPopMatrix(); + + glPushMatrix(); + glTranslatef(1.0, -1.0, -3.5); + glRotatef(-90.0, 1.0, 0.0, 0.0); + glIndexi(RAMPSTART); + glutSolidCone(1.0, 2.0, 10, 10); + glPopMatrix(); + glFlush(); +} + +void +myReshape(int w, int h) +{ + glViewport(0, 0, w, h); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + if (w <= h) + glOrtho(-2.0, 2.0, -2.0 * (GLfloat) h / (GLfloat) w, + 2.0 * (GLfloat) h / (GLfloat) w, 0.0, 10.0); + else + glOrtho(-2.0 * (GLfloat) w / (GLfloat) h, + 2.0 * (GLfloat) w / (GLfloat) h, -2.0, 2.0, 0.0, 10.0); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); +} + +static void +key(unsigned char k, int x, int y) +{ + switch (k) { + case 27: /* Escape */ + exit(0); + break; + default: + return; + } + glutPostRedisplay(); +} + +/* Main Loop + * Open window with initial window size, title bar, + * RGBA display mode, depth buffer, and handle input events. + */ +int +main(int argc, char **argv) +{ + glutInit(&argc, argv); + glutInitDisplayMode(GLUT_SINGLE | GLUT_INDEX | GLUT_DEPTH); + glutCreateWindow(argv[0]); + myinit(); + glutReshapeFunc(myReshape); + glutDisplayFunc(display); + glutKeyboardFunc(key); + glutMainLoop(); + return 0; /* ANSI C requires main to return int. */ +} diff --git a/progs/redbook/font.c b/progs/redbook/font.c new file mode 100644 index 00000000000..2d92e9b6003 --- /dev/null +++ b/progs/redbook/font.c @@ -0,0 +1,167 @@ +/* + * Copyright (c) 1993-1997, 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(R) is a registered trademark of Silicon Graphics, Inc. + */ + +/* + * font.c + * + * Draws some text in a bitmapped font. Uses glBitmap() + * and other pixel routines. Also demonstrates use of + * display lists. + */ +#include +#include +#include + +GLubyte space[] = +{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + +GLubyte letters[][13] = { +{0x00, 0x00, 0xc3, 0xc3, 0xc3, 0xc3, 0xff, 0xc3, 0xc3, 0xc3, 0x66, 0x3c, 0x18}, +{0x00, 0x00, 0xfe, 0xc7, 0xc3, 0xc3, 0xc7, 0xfe, 0xc7, 0xc3, 0xc3, 0xc7, 0xfe}, +{0x00, 0x00, 0x7e, 0xe7, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xe7, 0x7e}, +{0x00, 0x00, 0xfc, 0xce, 0xc7, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc7, 0xce, 0xfc}, +{0x00, 0x00, 0xff, 0xc0, 0xc0, 0xc0, 0xc0, 0xfc, 0xc0, 0xc0, 0xc0, 0xc0, 0xff}, +{0x00, 0x00, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xfc, 0xc0, 0xc0, 0xc0, 0xff}, +{0x00, 0x00, 0x7e, 0xe7, 0xc3, 0xc3, 0xcf, 0xc0, 0xc0, 0xc0, 0xc0, 0xe7, 0x7e}, +{0x00, 0x00, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xff, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3}, +{0x00, 0x00, 0x7e, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x7e}, +{0x00, 0x00, 0x7c, 0xee, 0xc6, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06}, +{0x00, 0x00, 0xc3, 0xc6, 0xcc, 0xd8, 0xf0, 0xe0, 0xf0, 0xd8, 0xcc, 0xc6, 0xc3}, +{0x00, 0x00, 0xff, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0}, +{0x00, 0x00, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xdb, 0xff, 0xff, 0xe7, 0xc3}, +{0x00, 0x00, 0xc7, 0xc7, 0xcf, 0xcf, 0xdf, 0xdb, 0xfb, 0xf3, 0xf3, 0xe3, 0xe3}, +{0x00, 0x00, 0x7e, 0xe7, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xe7, 0x7e}, +{0x00, 0x00, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xfe, 0xc7, 0xc3, 0xc3, 0xc7, 0xfe}, +{0x00, 0x00, 0x3f, 0x6e, 0xdf, 0xdb, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0x66, 0x3c}, +{0x00, 0x00, 0xc3, 0xc6, 0xcc, 0xd8, 0xf0, 0xfe, 0xc7, 0xc3, 0xc3, 0xc7, 0xfe}, +{0x00, 0x00, 0x7e, 0xe7, 0x03, 0x03, 0x07, 0x7e, 0xe0, 0xc0, 0xc0, 0xe7, 0x7e}, +{0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xff}, +{0x00, 0x00, 0x7e, 0xe7, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3}, +{0x00, 0x00, 0x18, 0x3c, 0x3c, 0x66, 0x66, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3}, +{0x00, 0x00, 0xc3, 0xe7, 0xff, 0xff, 0xdb, 0xdb, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3}, +{0x00, 0x00, 0xc3, 0x66, 0x66, 0x3c, 0x3c, 0x18, 0x3c, 0x3c, 0x66, 0x66, 0xc3}, +{0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x3c, 0x66, 0x66, 0xc3}, +{0x00, 0x00, 0xff, 0xc0, 0xc0, 0x60, 0x30, 0x7e, 0x0c, 0x06, 0x03, 0x03, 0xff} +}; + +GLuint fontOffset; + +void makeRasterFont(void) +{ + GLuint i, j; + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + + fontOffset = glGenLists (128); + for (i = 0,j = 'A'; i < 26; i++,j++) { + glNewList(fontOffset + j, GL_COMPILE); + glBitmap(8, 13, 0.0, 2.0, 10.0, 0.0, letters[i]); + glEndList(); + } + glNewList(fontOffset + ' ', GL_COMPILE); + glBitmap(8, 13, 0.0, 2.0, 10.0, 0.0, space); + glEndList(); +} + +void init(void) +{ + glShadeModel (GL_FLAT); + makeRasterFont(); +} + +void printString(char *s) +{ + glPushAttrib (GL_LIST_BIT); + glListBase(fontOffset); + glCallLists((GLsizei) strlen(s), GL_UNSIGNED_BYTE, (GLubyte *) s); + glPopAttrib (); +} + +/* Everything above this line could be in a library + * that defines a font. To make it work, you've got + * to call makeRasterFont() before you start making + * calls to printString(). + */ +void display(void) +{ + GLfloat white[3] = { 1.0, 1.0, 1.0 }; + + glClear(GL_COLOR_BUFFER_BIT); + glColor3fv(white); + + glRasterPos2i(20, 60); + printString("THE QUICK BROWN FOX JUMPS"); + glRasterPos2i(20, 40); + printString("OVER A LAZY DOG"); + glFlush (); +} + +void reshape(int w, int h) +{ + glViewport(0, 0, (GLsizei) w, (GLsizei) h); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho (0.0, w, 0.0, h, -1.0, 1.0); + glMatrixMode(GL_MODELVIEW); +} + +/* ARGSUSED1 */ +void keyboard(unsigned char key, int x, int y) +{ + switch (key) { + case 27: + exit(0); + } +} + +/* Main Loop + * Open window with initial window size, title bar, + * RGBA display mode, and handle input events. + */ +int main(int argc, char** argv) +{ + glutInit(&argc, argv); + glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); + glutInitWindowSize(300, 100); + glutInitWindowPosition (100, 100); + glutCreateWindow(argv[0]); + init(); + glutReshapeFunc(reshape); + glutKeyboardFunc(keyboard); + glutDisplayFunc(display); + glutMainLoop(); + return 0; +} diff --git a/progs/redbook/hello.c b/progs/redbook/hello.c new file mode 100644 index 00000000000..fb3dae13252 --- /dev/null +++ b/progs/redbook/hello.c @@ -0,0 +1,110 @@ +/* + * Copyright (c) 1993-1997, 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(R) is a registered trademark of Silicon Graphics, Inc. + */ + +/* + * hello.c + * This is a simple, introductory OpenGL program. + */ +#include +#include + +void display(void) +{ +/* clear all pixels */ + glClear (GL_COLOR_BUFFER_BIT); + +/* draw white polygon (rectangle) with corners at + * (0.25, 0.25, 0.0) and (0.75, 0.75, 0.0) + */ + glColor3f (1.0, 1.0, 1.0); + glBegin(GL_POLYGON); + glVertex3f (0.25, 0.25, 0.0); + glVertex3f (0.75, 0.25, 0.0); + glVertex3f (0.75, 0.75, 0.0); + glVertex3f (0.25, 0.75, 0.0); + glEnd(); + +/* don't wait! + * start processing buffered OpenGL routines + */ + glFlush (); +} + +void init (void) +{ +/* select clearing color */ + glClearColor (0.0, 0.0, 0.0, 0.0); + +/* initialize viewing values */ + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0); +} + +static void +key(unsigned char k, int x, int y) +{ + switch (k) { + case 27: /* Escape */ + exit(0); + break; + default: + return; + } + glutPostRedisplay(); +} + +/* + * Declare initial window size, position, and display mode + * (single buffer and RGBA). Open window with "hello" + * in its title bar. Call initialization routines. + * Register callback function to display graphics. + * Enter main loop and process events. + */ +int main(int argc, char** argv) +{ + glutInit(&argc, argv); + glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); + glutInitWindowSize (250, 250); + glutInitWindowPosition (100, 100); + glutCreateWindow ("hello"); + init (); + glutDisplayFunc(display); + glutKeyboardFunc(key); + glutMainLoop(); + return 0; /* ANSI C requires main to return int. */ +} diff --git a/progs/redbook/image.c b/progs/redbook/image.c new file mode 100644 index 00000000000..dc1a7246eba --- /dev/null +++ b/progs/redbook/image.c @@ -0,0 +1,159 @@ +/* + * Copyright (c) 1993-1997, 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(R) is a registered trademark of Silicon Graphics, Inc. + */ + +/* image.c + * This program demonstrates drawing pixels and shows the effect + * of glDrawPixels(), glCopyPixels(), and glPixelZoom(). + * Interaction: moving the mouse while pressing the mouse button + * will copy the image in the lower-left corner of the window + * to the mouse position, using the current pixel zoom factors. + * There is no attempt to prevent you from drawing over the original + * image. If you press the 'r' key, the original image and zoom + * factors are reset. If you press the 'z' or 'Z' keys, you change + * the zoom factors. + */ +#include +#include +#include + +/* Create checkerboard image */ +#define checkImageWidth 64 +#define checkImageHeight 64 +GLubyte checkImage[checkImageHeight][checkImageWidth][3]; + +static GLdouble zoomFactor = 1.0; +static GLint height; + +void makeCheckImage(void) +{ + int i, j, c; + + for (i = 0; i < checkImageHeight; i++) { + for (j = 0; j < checkImageWidth; j++) { + c = (((i&0x8)==0)^((j&0x8)==0))*255; + checkImage[i][j][0] = (GLubyte) c; + checkImage[i][j][1] = (GLubyte) c; + checkImage[i][j][2] = (GLubyte) c; + } + } +} + +void init(void) +{ + glClearColor (0.0, 0.0, 0.0, 0.0); + glShadeModel(GL_FLAT); + makeCheckImage(); + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); +} + +void display(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + glRasterPos2i(0, 0); + glDrawPixels(checkImageWidth, checkImageHeight, GL_RGB, + GL_UNSIGNED_BYTE, checkImage); + glFlush(); +} + +void reshape(int w, int h) +{ + glViewport(0, 0, (GLsizei) w, (GLsizei) h); + height = (GLint) h; + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluOrtho2D(0.0, (GLdouble) w, 0.0, (GLdouble) h); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); +} + +void motion(int x, int y) +{ + static GLint screeny; + + screeny = height - (GLint) y; + glRasterPos2i (x, screeny); + glPixelZoom (zoomFactor, zoomFactor); + glCopyPixels (0, 0, checkImageWidth, checkImageHeight, GL_COLOR); + glPixelZoom (1.0, 1.0); + glFlush (); +} + +/* ARGSUSED1 */ +void keyboard(unsigned char key, int x, int y) +{ + switch (key) { + case 'r': + case 'R': + zoomFactor = 1.0; + glutPostRedisplay(); + printf ("zoomFactor reset to 1.0\n"); + break; + case 'z': + zoomFactor += 0.5; + if (zoomFactor >= 3.0) + zoomFactor = 3.0; + printf ("zoomFactor is now %4.1f\n", zoomFactor); + break; + case 'Z': + zoomFactor -= 0.5; + if (zoomFactor <= 0.5) + zoomFactor = 0.5; + printf ("zoomFactor is now %4.1f\n", zoomFactor); + break; + case 27: + exit(0); + break; + default: + break; + } +} + +int main(int argc, char** argv) +{ + glutInit(&argc, argv); + glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); + glutInitWindowSize(250, 250); + glutInitWindowPosition(100, 100); + glutCreateWindow(argv[0]); + init(); + glutDisplayFunc(display); + glutReshapeFunc(reshape); + glutKeyboardFunc(keyboard); + glutMotionFunc(motion); + glutMainLoop(); + return 0; +} diff --git a/progs/redbook/jitter.h b/progs/redbook/jitter.h new file mode 100644 index 00000000000..1ec08c87fd4 --- /dev/null +++ b/progs/redbook/jitter.h @@ -0,0 +1,222 @@ +/* + * (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. + */ +/* +jitter.h + +This file contains jitter point arrays for 2,3,4,8,15,24 and 66 jitters. + +The arrays are named j2, j3, etc. Each element in the array has the form, +for example, j8[0].x and j8[0].y + +Values are floating point in the range -.5 < x < .5, -.5 < y < .5, and +have a gaussian distribution around the origin. + +Use these to do model jittering for scene anti-aliasing and view volume +jittering for depth of field effects. Use in conjunction with the +accwindow() routine. +*/ + +typedef struct +{ + GLfloat x, y; +} jitter_point; + +#define MAX_SAMPLES 66 + + +/* 2 jitter points */ +jitter_point j2[] = +{ + { 0.246490, 0.249999}, + {-0.246490, -0.249999} +}; + + +/* 3 jitter points */ +jitter_point j3[] = +{ + {-0.373411, -0.250550}, + { 0.256263, 0.368119}, + { 0.117148, -0.117570} +}; + + +/* 4 jitter points */ +jitter_point j4[] = +{ + {-0.208147, 0.353730}, + { 0.203849, -0.353780}, + {-0.292626, -0.149945}, + { 0.296924, 0.149994} +}; + + +/* 8 jitter points */ +jitter_point j8[] = +{ + {-0.334818, 0.435331}, + { 0.286438, -0.393495}, + { 0.459462, 0.141540}, + {-0.414498, -0.192829}, + {-0.183790, 0.082102}, + {-0.079263, -0.317383}, + { 0.102254, 0.299133}, + { 0.164216, -0.054399} +}; + + +/* 15 jitter points */ +jitter_point j15[] = +{ + { 0.285561, 0.188437}, + { 0.360176, -0.065688}, + {-0.111751, 0.275019}, + {-0.055918, -0.215197}, + {-0.080231, -0.470965}, + { 0.138721, 0.409168}, + { 0.384120, 0.458500}, + {-0.454968, 0.134088}, + { 0.179271, -0.331196}, + {-0.307049, -0.364927}, + { 0.105354, -0.010099}, + {-0.154180, 0.021794}, + {-0.370135, -0.116425}, + { 0.451636, -0.300013}, + {-0.370610, 0.387504} +}; + + +/* 24 jitter points */ +jitter_point j24[] = +{ + { 0.030245, 0.136384}, + { 0.018865, -0.348867}, + {-0.350114, -0.472309}, + { 0.222181, 0.149524}, + {-0.393670, -0.266873}, + { 0.404568, 0.230436}, + { 0.098381, 0.465337}, + { 0.462671, 0.442116}, + { 0.400373, -0.212720}, + {-0.409988, 0.263345}, + {-0.115878, -0.001981}, + { 0.348425, -0.009237}, + {-0.464016, 0.066467}, + {-0.138674, -0.468006}, + { 0.144932, -0.022780}, + {-0.250195, 0.150161}, + {-0.181400, -0.264219}, + { 0.196097, -0.234139}, + {-0.311082, -0.078815}, + { 0.268379, 0.366778}, + {-0.040601, 0.327109}, + {-0.234392, 0.354659}, + {-0.003102, -0.154402}, + { 0.297997, -0.417965} +}; + + +/* 66 jitter points */ +jitter_point j66[] = +{ + { 0.266377, -0.218171}, + {-0.170919, -0.429368}, + { 0.047356, -0.387135}, + {-0.430063, 0.363413}, + {-0.221638, -0.313768}, + { 0.124758, -0.197109}, + {-0.400021, 0.482195}, + { 0.247882, 0.152010}, + {-0.286709, -0.470214}, + {-0.426790, 0.004977}, + {-0.361249, -0.104549}, + {-0.040643, 0.123453}, + {-0.189296, 0.438963}, + {-0.453521, -0.299889}, + { 0.408216, -0.457699}, + { 0.328973, -0.101914}, + {-0.055540, -0.477952}, + { 0.194421, 0.453510}, + { 0.404051, 0.224974}, + { 0.310136, 0.419700}, + {-0.021743, 0.403898}, + {-0.466210, 0.248839}, + { 0.341369, 0.081490}, + { 0.124156, -0.016859}, + {-0.461321, -0.176661}, + { 0.013210, 0.234401}, + { 0.174258, -0.311854}, + { 0.294061, 0.263364}, + {-0.114836, 0.328189}, + { 0.041206, -0.106205}, + { 0.079227, 0.345021}, + {-0.109319, -0.242380}, + { 0.425005, -0.332397}, + { 0.009146, 0.015098}, + {-0.339084, -0.355707}, + {-0.224596, -0.189548}, + { 0.083475, 0.117028}, + { 0.295962, -0.334699}, + { 0.452998, 0.025397}, + { 0.206511, -0.104668}, + { 0.447544, -0.096004}, + {-0.108006, -0.002471}, + {-0.380810, 0.130036}, + {-0.242440, 0.186934}, + {-0.200363, 0.070863}, + {-0.344844, -0.230814}, + { 0.408660, 0.345826}, + {-0.233016, 0.305203}, + { 0.158475, -0.430762}, + { 0.486972, 0.139163}, + {-0.301610, 0.009319}, + { 0.282245, -0.458671}, + { 0.482046, 0.443890}, + {-0.121527, 0.210223}, + {-0.477606, -0.424878}, + {-0.083941, -0.121440}, + {-0.345773, 0.253779}, + { 0.234646, 0.034549}, + { 0.394102, -0.210901}, + {-0.312571, 0.397656}, + { 0.200906, 0.333293}, + { 0.018703, -0.261792}, + {-0.209349, -0.065383}, + { 0.076248, 0.478538}, + {-0.073036, -0.355064}, + { 0.145087, 0.221726} +}; diff --git a/progs/redbook/light.c b/progs/redbook/light.c new file mode 100644 index 00000000000..0eed85e10c2 --- /dev/null +++ b/progs/redbook/light.c @@ -0,0 +1,113 @@ +/* + * Copyright (c) 1993-1997, 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(R) is a registered trademark of Silicon Graphics, Inc. + */ + +/* + * light.c + * This program demonstrates the use of the OpenGL lighting + * model. A sphere is drawn using a grey material characteristic. + * A single light source illuminates the object. + */ +#include +#include + +/* Initialize material property, light source, lighting model, + * and depth buffer. + */ +void init(void) +{ + GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 }; + GLfloat mat_shininess[] = { 50.0 }; + GLfloat light_position[] = { 1.0, 1.0, 1.0, 0.0 }; + + glClearColor (0.0, 0.0, 0.0, 0.0); + glShadeModel (GL_SMOOTH); + + glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); + glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess); + glLightfv(GL_LIGHT0, GL_POSITION, light_position); + + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + glEnable(GL_DEPTH_TEST); +} + +void display(void) +{ + glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glutSolidSphere (1.0, 20, 16); + glFlush (); +} + +void reshape (int w, int h) +{ + glViewport (0, 0, (GLsizei) w, (GLsizei) h); + glMatrixMode (GL_PROJECTION); + glLoadIdentity(); + if (w <= h) + glOrtho (-1.5, 1.5, -1.5*(GLfloat)h/(GLfloat)w, + 1.5*(GLfloat)h/(GLfloat)w, -10.0, 10.0); + else + glOrtho (-1.5*(GLfloat)w/(GLfloat)h, + 1.5*(GLfloat)w/(GLfloat)h, -1.5, 1.5, -10.0, 10.0); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); +} + +/* ARGSUSED1 */ +void keyboard(unsigned char key, int x, int y) +{ + switch (key) { + case 27: + exit(0); + break; + } +} + +int main(int argc, char** argv) +{ + glutInit(&argc, argv); + glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH); + glutInitWindowSize (500, 500); + glutInitWindowPosition (100, 100); + glutCreateWindow (argv[0]); + init (); + glutDisplayFunc(display); + glutReshapeFunc(reshape); + glutKeyboardFunc(keyboard); + glutMainLoop(); + return 0; +} diff --git a/progs/redbook/lines.c b/progs/redbook/lines.c new file mode 100644 index 00000000000..b34d4c418c6 --- /dev/null +++ b/progs/redbook/lines.c @@ -0,0 +1,138 @@ +/* + * Copyright (c) 1993-1997, 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(R) is a registered trademark of Silicon Graphics, Inc. + */ + +/* + * lines.c + * This program demonstrates geometric primitives and + * their attributes. + */ +#include +#include + +#define drawOneLine(x1,y1,x2,y2) glBegin(GL_LINES); \ + glVertex2f ((x1),(y1)); glVertex2f ((x2),(y2)); glEnd(); + +void init(void) +{ + glClearColor (0.0, 0.0, 0.0, 0.0); + glShadeModel (GL_FLAT); +} + +void display(void) +{ + int i; + + glClear (GL_COLOR_BUFFER_BIT); + +/* select white for all lines */ + glColor3f (1.0, 1.0, 1.0); + +/* in 1st row, 3 lines, each with a different stipple */ + glEnable (GL_LINE_STIPPLE); + + glLineStipple (1, 0x0101); /* dotted */ + drawOneLine (50.0, 125.0, 150.0, 125.0); + glLineStipple (1, 0x00FF); /* dashed */ + drawOneLine (150.0, 125.0, 250.0, 125.0); + glLineStipple (1, 0x1C47); /* dash/dot/dash */ + drawOneLine (250.0, 125.0, 350.0, 125.0); + +/* in 2nd row, 3 wide lines, each with different stipple */ + glLineWidth (5.0); + glLineStipple (1, 0x0101); /* dotted */ + drawOneLine (50.0, 100.0, 150.0, 100.0); + glLineStipple (1, 0x00FF); /* dashed */ + drawOneLine (150.0, 100.0, 250.0, 100.0); + glLineStipple (1, 0x1C47); /* dash/dot/dash */ + drawOneLine (250.0, 100.0, 350.0, 100.0); + glLineWidth (1.0); + +/* in 3rd row, 6 lines, with dash/dot/dash stipple */ +/* as part of a single connected line strip */ + glLineStipple (1, 0x1C47); /* dash/dot/dash */ + glBegin (GL_LINE_STRIP); + for (i = 0; i < 7; i++) + glVertex2f (50.0 + ((GLfloat) i * 50.0), 75.0); + glEnd (); + +/* in 4th row, 6 independent lines with same stipple */ + for (i = 0; i < 6; i++) { + drawOneLine (50.0 + ((GLfloat) i * 50.0), 50.0, + 50.0 + ((GLfloat)(i+1) * 50.0), 50.0); + } + +/* in 5th row, 1 line, with dash/dot/dash stipple */ +/* and a stipple repeat factor of 5 */ + glLineStipple (5, 0x1C47); /* dash/dot/dash */ + drawOneLine (50.0, 25.0, 350.0, 25.0); + + glDisable (GL_LINE_STIPPLE); + glFlush (); +} + +void reshape (int w, int h) +{ + glViewport (0, 0, (GLsizei) w, (GLsizei) h); + glMatrixMode (GL_PROJECTION); + glLoadIdentity (); + gluOrtho2D (0.0, (GLdouble) w, 0.0, (GLdouble) h); +} + +/* ARGSUSED1 */ +void keyboard(unsigned char key, int x, int y) +{ + switch (key) { + case 27: + exit(0); + break; + } +} + +int main(int argc, char** argv) +{ + glutInit(&argc, argv); + glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); + glutInitWindowSize (400, 150); + glutInitWindowPosition (100, 100); + glutCreateWindow (argv[0]); + init (); + glutDisplayFunc(display); + glutReshapeFunc(reshape); + glutKeyboardFunc(keyboard); + glutMainLoop(); + return 0; +} diff --git a/progs/redbook/list.c b/progs/redbook/list.c new file mode 100644 index 00000000000..3b4f44bd6da --- /dev/null +++ b/progs/redbook/list.c @@ -0,0 +1,125 @@ +/* + * Copyright (c) 1993-1997, 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(R) is a registered trademark of Silicon Graphics, Inc. + */ + +/* + * list.c + * This program demonstrates how to make and execute a + * display list. Note that attributes, such as current + * color and matrix, are changed. + */ +#include +#include + +GLuint listName; + +static void init (void) +{ + listName = glGenLists (1); + glNewList (listName, GL_COMPILE); + glColor3f (1.0, 0.0, 0.0); /* current color red */ + glBegin (GL_TRIANGLES); + glVertex2f (0.0, 0.0); + glVertex2f (1.0, 0.0); + glVertex2f (0.0, 1.0); + glEnd (); + glTranslatef (1.5, 0.0, 0.0); /* move position */ + glEndList (); + glShadeModel (GL_FLAT); +} + +static void drawLine (void) +{ + glBegin (GL_LINES); + glVertex2f (0.0, 0.5); + glVertex2f (15.0, 0.5); + glEnd (); +} + +void display(void) +{ + GLuint i; + + glClear (GL_COLOR_BUFFER_BIT); + glColor3f (0.0, 1.0, 0.0); /* current color green */ + for (i = 0; i < 10; i++) /* draw 10 triangles */ + glCallList (listName); + drawLine (); /* is this line green? NO! */ + /* where is the line drawn? */ + glFlush (); +} + +void reshape(int w, int h) +{ + glViewport(0, 0, w, h); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + if (w <= h) + gluOrtho2D (0.0, 2.0, -0.5 * (GLfloat) h/(GLfloat) w, + 1.5 * (GLfloat) h/(GLfloat) w); + else + gluOrtho2D (0.0, 2.0 * (GLfloat) w/(GLfloat) h, -0.5, 1.5); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); +} + +/* ARGSUSED1 */ +void keyboard(unsigned char key, int x, int y) +{ + switch (key) { + case 27: + exit(0); + break; + } +} + +/* Main Loop + * Open window with initial window size, title bar, + * RGBA display mode, and handle input events. + */ +int main(int argc, char** argv) +{ + glutInit(&argc, argv); + glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); + glutInitWindowSize(650, 50); + glutCreateWindow(argv[0]); + init (); + glutReshapeFunc (reshape); + glutDisplayFunc (display); + glutKeyboardFunc (keyboard); + glutMainLoop(); + return 0; +} diff --git a/progs/redbook/material.c b/progs/redbook/material.c new file mode 100644 index 00000000000..f9a4fc59288 --- /dev/null +++ b/progs/redbook/material.c @@ -0,0 +1,306 @@ + +/* 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. + */ +/* + * material.c + * This program demonstrates the use of the GL lighting model. + * Several objects are drawn using different material characteristics. + * A single light source illuminates the objects. + */ +#include +#include + +/* Initialize z-buffer, projection matrix, light source, + * and lighting model. Do not specify a material property here. + */ +void myinit(void) +{ + GLfloat ambient[] = { 0.0, 0.0, 0.0, 1.0 }; + GLfloat diffuse[] = { 1.0, 1.0, 1.0, 1.0 }; + GLfloat position[] = { 0.0, 3.0, 2.0, 0.0 }; + GLfloat lmodel_ambient[] = { 0.4, 0.4, 0.4, 1.0 }; + GLfloat local_view[] = { 0.0 }; + + glEnable(GL_DEPTH_TEST); + glDepthFunc(GL_LESS); + + glLightfv(GL_LIGHT0, GL_AMBIENT, ambient); + glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse); + glLightfv(GL_LIGHT0, GL_POSITION, position); + glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient); + glLightModelfv(GL_LIGHT_MODEL_LOCAL_VIEWER, local_view); + + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + + glClearColor(0.0, 0.1, 0.1, 0.0); +} + +/* Draw twelve spheres in 3 rows with 4 columns. + * The spheres in the first row have materials with no ambient reflection. + * The second row has materials with significant ambient reflection. + * The third row has materials with colored ambient reflection. + * + * The first column has materials with blue, diffuse reflection only. + * The second column has blue diffuse reflection, as well as specular + * reflection with a low shininess exponent. + * The third column has blue diffuse reflection, as well as specular + * reflection with a high shininess exponent (a more concentrated highlight). + * The fourth column has materials which also include an emissive component. + * + * glTranslatef() is used to move spheres to their appropriate locations. + */ + +void display(void) +{ + GLfloat no_mat[] = { 0.0, 0.0, 0.0, 1.0 }; + GLfloat mat_ambient[] = { 0.7, 0.7, 0.7, 1.0 }; + GLfloat mat_ambient_color[] = { 0.8, 0.8, 0.2, 1.0 }; + GLfloat mat_diffuse[] = { 0.1, 0.5, 0.8, 1.0 }; + GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 }; + GLfloat no_shininess[] = { 0.0 }; + GLfloat low_shininess[] = { 5.0 }; + GLfloat high_shininess[] = { 100.0 }; + GLfloat mat_emission[] = {0.3, 0.2, 0.2, 0.0}; + + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + +/* draw sphere in first row, first column + * diffuse reflection only; no ambient or specular + */ + glPushMatrix(); + glTranslatef (-3.75, 3.0, 0.0); + glMaterialfv(GL_FRONT, GL_AMBIENT, no_mat); + glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); + glMaterialfv(GL_FRONT, GL_SPECULAR, no_mat); + glMaterialfv(GL_FRONT, GL_SHININESS, no_shininess); + glMaterialfv(GL_FRONT, GL_EMISSION, no_mat); + glutSolidSphere(1.0, 16, 16); + glPopMatrix(); + +/* draw sphere in first row, second column + * diffuse and specular reflection; low shininess; no ambient + */ + glPushMatrix(); + glTranslatef (-1.25, 3.0, 0.0); + glMaterialfv(GL_FRONT, GL_AMBIENT, no_mat); + glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); + glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); + glMaterialfv(GL_FRONT, GL_SHININESS, low_shininess); + glMaterialfv(GL_FRONT, GL_EMISSION, no_mat); + glutSolidSphere(1.0, 16, 16); + glPopMatrix(); + +/* draw sphere in first row, third column + * diffuse and specular reflection; high shininess; no ambient + */ + glPushMatrix(); + glTranslatef (1.25, 3.0, 0.0); + glMaterialfv(GL_FRONT, GL_AMBIENT, no_mat); + glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); + glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); + glMaterialfv(GL_FRONT, GL_SHININESS, high_shininess); + glMaterialfv(GL_FRONT, GL_EMISSION, no_mat); + glutSolidSphere(1.0, 16, 16); + glPopMatrix(); + +/* draw sphere in first row, fourth column + * diffuse reflection; emission; no ambient or specular reflection + */ + glPushMatrix(); + glTranslatef (3.75, 3.0, 0.0); + glMaterialfv(GL_FRONT, GL_AMBIENT, no_mat); + glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); + glMaterialfv(GL_FRONT, GL_SPECULAR, no_mat); + glMaterialfv(GL_FRONT, GL_SHININESS, no_shininess); + glMaterialfv(GL_FRONT, GL_EMISSION, mat_emission); + glutSolidSphere(1.0, 16, 16); + glPopMatrix(); + +/* draw sphere in second row, first column + * ambient and diffuse reflection; no specular + */ + glPushMatrix(); + glTranslatef (-3.75, 0.0, 0.0); + glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient); + glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); + glMaterialfv(GL_FRONT, GL_SPECULAR, no_mat); + glMaterialfv(GL_FRONT, GL_SHININESS, no_shininess); + glMaterialfv(GL_FRONT, GL_EMISSION, no_mat); + glutSolidSphere(1.0, 16, 16); + glPopMatrix(); + +/* draw sphere in second row, second column + * ambient, diffuse and specular reflection; low shininess + */ + glPushMatrix(); + glTranslatef (-1.25, 0.0, 0.0); + glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient); + glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); + glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); + glMaterialfv(GL_FRONT, GL_SHININESS, low_shininess); + glMaterialfv(GL_FRONT, GL_EMISSION, no_mat); + glutSolidSphere(1.0, 16, 16); + glPopMatrix(); + +/* draw sphere in second row, third column + * ambient, diffuse and specular reflection; high shininess + */ + glPushMatrix(); + glTranslatef (1.25, 0.0, 0.0); + glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient); + glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); + glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); + glMaterialfv(GL_FRONT, GL_SHININESS, high_shininess); + glMaterialfv(GL_FRONT, GL_EMISSION, no_mat); + glutSolidSphere(1.0, 16, 16); + glPopMatrix(); + +/* draw sphere in second row, fourth column + * ambient and diffuse reflection; emission; no specular + */ + glPushMatrix(); + glTranslatef (3.75, 0.0, 0.0); + glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient); + glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); + glMaterialfv(GL_FRONT, GL_SPECULAR, no_mat); + glMaterialfv(GL_FRONT, GL_SHININESS, no_shininess); + glMaterialfv(GL_FRONT, GL_EMISSION, mat_emission); + glutSolidSphere(1.0, 16, 16); + glPopMatrix(); + +/* draw sphere in third row, first column + * colored ambient and diffuse reflection; no specular + */ + glPushMatrix(); + glTranslatef (-3.75, -3.0, 0.0); + glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient_color); + glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); + glMaterialfv(GL_FRONT, GL_SPECULAR, no_mat); + glMaterialfv(GL_FRONT, GL_SHININESS, no_shininess); + glMaterialfv(GL_FRONT, GL_EMISSION, no_mat); + glutSolidSphere(1.0, 16, 16); + glPopMatrix(); + +/* draw sphere in third row, second column + * colored ambient, diffuse and specular reflection; low shininess + */ + glPushMatrix(); + glTranslatef (-1.25, -3.0, 0.0); + glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient_color); + glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); + glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); + glMaterialfv(GL_FRONT, GL_SHININESS, low_shininess); + glMaterialfv(GL_FRONT, GL_EMISSION, no_mat); + glutSolidSphere(1.0, 16, 16); + glPopMatrix(); + +/* draw sphere in third row, third column + * colored ambient, diffuse and specular reflection; high shininess + */ + glPushMatrix(); + glTranslatef (1.25, -3.0, 0.0); + glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient_color); + glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); + glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); + glMaterialfv(GL_FRONT, GL_SHININESS, high_shininess); + glMaterialfv(GL_FRONT, GL_EMISSION, no_mat); + glutSolidSphere(1.0, 16, 16); + glPopMatrix(); + +/* draw sphere in third row, fourth column + * colored ambient and diffuse reflection; emission; no specular + */ + glPushMatrix(); + glTranslatef (3.75, -3.0, 0.0); + glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient_color); + glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); + glMaterialfv(GL_FRONT, GL_SPECULAR, no_mat); + glMaterialfv(GL_FRONT, GL_SHININESS, no_shininess); + glMaterialfv(GL_FRONT, GL_EMISSION, mat_emission); + glutSolidSphere(1.0, 16, 16); + glPopMatrix(); + + glFlush(); +} + +void myReshape(int w, int h) +{ + glViewport(0, 0, w, h); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + if (w <= (h * 2)) + glOrtho (-6.0, 6.0, -3.0*((GLfloat)h*2)/(GLfloat)w, + 3.0*((GLfloat)h*2)/(GLfloat)w, -10.0, 10.0); + else + glOrtho (-6.0*(GLfloat)w/((GLfloat)h*2), + 6.0*(GLfloat)w/((GLfloat)h*2), -3.0, 3.0, -10.0, 10.0); + glMatrixMode(GL_MODELVIEW); +} + +static void +key(unsigned char k, int x, int y) +{ + switch (k) { + case 27: /* Escape */ + exit(0); + break; + default: + return; + } + glutPostRedisplay(); +} + +/* Main Loop + * Open window with initial window size, title bar, + * RGBA display mode, and handle input events. + */ +int main(int argc, char** argv) +{ + glutInit(&argc, argv); + glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH); + glutInitWindowSize (600, 450); + glutCreateWindow(argv[0]); + myinit(); + glutReshapeFunc(myReshape); + glutDisplayFunc(display); + glutKeyboardFunc(key); + glutMainLoop(); + return 0; /* ANSI C requires main to return int. */ +} diff --git a/progs/redbook/mipmap.c b/progs/redbook/mipmap.c new file mode 100644 index 00000000000..d32dd725f4b --- /dev/null +++ b/progs/redbook/mipmap.c @@ -0,0 +1,178 @@ + +/* Copyright (c) Mark J. Kilgard, 1994. */ + +/* + * (c) Copyright 1993, Silicon Graphics, Inc. + * ALL RIGHTS RESERVED + * Permission to use, copy, modify, and distribute this software for + * any purpose and without fee is hereby granted, provided that the above + * copyright notice appear in all copies and that both the copyright notice + * and this permission notice appear in supporting documentation, and that + * the name of Silicon Graphics, Inc. not be used in advertising + * or publicity pertaining to distribution of the software without specific, + * written prior permission. + * + * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS" + * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR + * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON + * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, + * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY + * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, + * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF + * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN + * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE + * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE. + * + * US Government Users Restricted Rights + * Use, duplication, or disclosure by the Government is subject to + * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph + * (c)(1)(ii) of the Rights in Technical Data and Computer Software + * clause at DFARS 252.227-7013 and/or in similar or successor + * clauses in the FAR or the DOD or NASA FAR Supplement. + * Unpublished-- rights reserved under the copyright laws of the + * United States. Contractor/manufacturer is Silicon Graphics, + * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. + * + * OpenGL(TM) is a trademark of Silicon Graphics, Inc. + */ +/* mipmap.c + * This program demonstrates using mipmaps for texture maps. + * To overtly show the effect of mipmaps, each mipmap reduction + * level has a solidly colored, contrasting texture image. + * Thus, the quadrilateral which is drawn is drawn with several + * different colors. + */ +#include +#include + +GLubyte mipmapImage32[32][32][3]; +GLubyte mipmapImage16[16][16][3]; +GLubyte mipmapImage8[8][8][3]; +GLubyte mipmapImage4[4][4][3]; +GLubyte mipmapImage2[2][2][3]; +GLubyte mipmapImage1[1][1][3]; + +void makeImages(void) +{ + int i, j; + + for (i = 0; i < 32; i++) { + for (j = 0; j < 32; j++) { + mipmapImage32[i][j][0] = 255; + mipmapImage32[i][j][1] = 255; + mipmapImage32[i][j][2] = 0; + } + } + for (i = 0; i < 16; i++) { + for (j = 0; j < 16; j++) { + mipmapImage16[i][j][0] = 255; + mipmapImage16[i][j][1] = 0; + mipmapImage16[i][j][2] = 255; + } + } + for (i = 0; i < 8; i++) { + for (j = 0; j < 8; j++) { + mipmapImage8[i][j][0] = 255; + mipmapImage8[i][j][1] = 0; + mipmapImage8[i][j][2] = 0; + } + } + for (i = 0; i < 4; i++) { + for (j = 0; j < 4; j++) { + mipmapImage4[i][j][0] = 0; + mipmapImage4[i][j][1] = 255; + mipmapImage4[i][j][2] = 0; + } + } + for (i = 0; i < 2; i++) { + for (j = 0; j < 2; j++) { + mipmapImage2[i][j][0] = 0; + mipmapImage2[i][j][1] = 0; + mipmapImage2[i][j][2] = 255; + } + } + mipmapImage1[0][0][0] = 255; + mipmapImage1[0][0][1] = 255; + mipmapImage1[0][0][2] = 255; +} + +void myinit(void) +{ + glEnable(GL_DEPTH_TEST); + glDepthFunc(GL_LESS); + glShadeModel(GL_FLAT); + + glTranslatef(0.0, 0.0, -3.6); + makeImages(); + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + glTexImage2D(GL_TEXTURE_2D, 0, 3, 32, 32, 0, + GL_RGB, GL_UNSIGNED_BYTE, &mipmapImage32[0][0][0]); + glTexImage2D(GL_TEXTURE_2D, 1, 3, 16, 16, 0, + GL_RGB, GL_UNSIGNED_BYTE, &mipmapImage16[0][0][0]); + glTexImage2D(GL_TEXTURE_2D, 2, 3, 8, 8, 0, + GL_RGB, GL_UNSIGNED_BYTE, &mipmapImage8[0][0][0]); + glTexImage2D(GL_TEXTURE_2D, 3, 3, 4, 4, 0, + GL_RGB, GL_UNSIGNED_BYTE, &mipmapImage4[0][0][0]); + glTexImage2D(GL_TEXTURE_2D, 4, 3, 2, 2, 0, + GL_RGB, GL_UNSIGNED_BYTE, &mipmapImage2[0][0][0]); + glTexImage2D(GL_TEXTURE_2D, 5, 3, 1, 1, 0, + GL_RGB, GL_UNSIGNED_BYTE, &mipmapImage1[0][0][0]); + 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_MAG_FILTER, GL_NEAREST); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, + GL_NEAREST_MIPMAP_NEAREST); + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); + glEnable(GL_TEXTURE_2D); +} + +void display(void) +{ + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glBegin(GL_QUADS); + glTexCoord2f(0.0, 0.0); glVertex3f(-2.0, -1.0, 0.0); + glTexCoord2f(0.0, 8.0); glVertex3f(-2.0, 1.0, 0.0); + glTexCoord2f(8.0, 8.0); glVertex3f(2000.0, 1.0, -6000.0); + glTexCoord2f(8.0, 0.0); glVertex3f(2000.0, -1.0, -6000.0); + glEnd(); + glFlush(); +} + +void myReshape(int w, int h) +{ + glViewport(0, 0, w, h); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluPerspective(60.0, 1.0*(GLfloat)w/(GLfloat)h, 1.0, 30000.0); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); +} + +static void +key(unsigned char k, int x, int y) +{ + switch (k) { + case 27: /* Escape */ + exit(0); + break; + default: + return; + } + glutPostRedisplay(); +} + +int main(int argc, char** argv) +{ + glutInit(&argc, argv); + glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH); + glutInitWindowSize (500, 500); + glutCreateWindow (argv[0]); + myinit(); + glutReshapeFunc (myReshape); + glutDisplayFunc(display); + glutKeyboardFunc(key); + glutMainLoop(); + return 0; /* ANSI C requires main to return int. */ +} diff --git a/progs/redbook/model.c b/progs/redbook/model.c new file mode 100644 index 00000000000..8411ef355f1 --- /dev/null +++ b/progs/redbook/model.c @@ -0,0 +1,126 @@ +/* + * Copyright (c) 1993-1997, 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(R) is a registered trademark of Silicon Graphics, Inc. + */ + +/* + * model.c + * This program demonstrates modeling transformations + */ +#include +#include + +void init(void) +{ + glClearColor (0.0, 0.0, 0.0, 0.0); + glShadeModel (GL_FLAT); +} + +void draw_triangle(void) +{ + glBegin (GL_LINE_LOOP); + glVertex2f(0.0, 25.0); + glVertex2f(25.0, -25.0); + glVertex2f(-25.0, -25.0); + glEnd(); +} + +void display(void) +{ + glClear (GL_COLOR_BUFFER_BIT); + glColor3f (1.0, 1.0, 1.0); + + glLoadIdentity (); + glColor3f (1.0, 1.0, 1.0); + draw_triangle (); + + glEnable (GL_LINE_STIPPLE); + glLineStipple (1, 0xF0F0); + glLoadIdentity (); + glTranslatef (-20.0, 0.0, 0.0); + draw_triangle (); + + glLineStipple (1, 0xF00F); + glLoadIdentity (); + glScalef (1.5, 0.5, 1.0); + draw_triangle (); + + glLineStipple (1, 0x8888); + glLoadIdentity (); + glRotatef (90.0, 0.0, 0.0, 1.0); + draw_triangle (); + glDisable (GL_LINE_STIPPLE); + + glFlush (); +} + +void reshape (int w, int h) +{ + glViewport (0, 0, (GLsizei) w, (GLsizei) h); + glMatrixMode (GL_PROJECTION); + glLoadIdentity (); + if (w <= h) + glOrtho (-50.0, 50.0, -50.0*(GLfloat)h/(GLfloat)w, + 50.0*(GLfloat)h/(GLfloat)w, -1.0, 1.0); + else + glOrtho (-50.0*(GLfloat)w/(GLfloat)h, + 50.0*(GLfloat)w/(GLfloat)h, -50.0, 50.0, -1.0, 1.0); + glMatrixMode(GL_MODELVIEW); +} + +/* ARGSUSED1 */ +void keyboard(unsigned char key, int x, int y) +{ + switch (key) { + case 27: + exit(0); + break; + } +} + +int main(int argc, char** argv) +{ + glutInit(&argc, argv); + glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); + glutInitWindowSize (500, 500); + glutInitWindowPosition (100, 100); + glutCreateWindow (argv[0]); + init (); + glutDisplayFunc(display); + glutReshapeFunc(reshape); + glutKeyboardFunc (keyboard); + glutMainLoop(); + return 0; +} diff --git a/progs/redbook/movelight.c b/progs/redbook/movelight.c new file mode 100644 index 00000000000..a108cad439a --- /dev/null +++ b/progs/redbook/movelight.c @@ -0,0 +1,148 @@ +/* + * Copyright (c) 1993-1997, 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(R) is a registered trademark of Silicon Graphics, Inc. + */ + +/* + * movelight.c + * This program demonstrates when to issue lighting and + * transformation commands to render a model with a light + * which is moved by a modeling transformation (rotate or + * translate). The light position is reset after the modeling + * transformation is called. The eye position does not change. + * + * A sphere is drawn using a grey material characteristic. + * A single light source illuminates the object. + * + * Interaction: pressing the left mouse button alters + * the modeling transformation (x rotation) by 30 degrees. + * The scene is then redrawn with the light in a new position. + */ +#include +#include + +static int spin = 0; + +/* Initialize material property, light source, lighting model, + * and depth buffer. + */ +void init(void) +{ + glClearColor (0.0, 0.0, 0.0, 0.0); + glShadeModel (GL_SMOOTH); + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + glEnable(GL_DEPTH_TEST); +} + +/* Here is where the light position is reset after the modeling + * transformation (glRotated) is called. This places the + * light at a new position in world coordinates. The cube + * represents the position of the light. + */ +void display(void) +{ + GLfloat position[] = { 0.0, 0.0, 1.5, 1.0 }; + + glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glPushMatrix (); + gluLookAt (0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); + + glPushMatrix (); + glRotated ((GLdouble) spin, 1.0, 0.0, 0.0); + glLightfv (GL_LIGHT0, GL_POSITION, position); + + glTranslated (0.0, 0.0, 1.5); + glDisable (GL_LIGHTING); + glColor3f (0.0, 1.0, 1.0); + glutWireCube (0.1); + glEnable (GL_LIGHTING); + glPopMatrix (); + + glutSolidTorus (0.275, 0.85, 8, 15); + glPopMatrix (); + glFlush (); +} + +void reshape (int w, int h) +{ + glViewport (0, 0, (GLsizei) w, (GLsizei) h); + glMatrixMode (GL_PROJECTION); + glLoadIdentity(); + gluPerspective(40.0, (GLfloat) w/(GLfloat) h, 1.0, 20.0); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); +} + +/* ARGSUSED2 */ +void mouse(int button, int state, int x, int y) +{ + switch (button) { + case GLUT_LEFT_BUTTON: + if (state == GLUT_DOWN) { + spin = (spin + 30) % 360; + glutPostRedisplay(); + } + break; + default: + break; + } +} + +/* ARGSUSED1 */ +void keyboard(unsigned char key, int x, int y) +{ + switch (key) { + case 27: + exit(0); + break; + } +} + +int main(int argc, char** argv) +{ + glutInit(&argc, argv); + glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH); + glutInitWindowSize (500, 500); + glutInitWindowPosition (100, 100); + glutCreateWindow (argv[0]); + init (); + glutDisplayFunc(display); + glutReshapeFunc(reshape); + glutMouseFunc(mouse); + glutKeyboardFunc(keyboard); + glutMainLoop(); + return 0; +} diff --git a/progs/redbook/nurbs.c b/progs/redbook/nurbs.c new file mode 100644 index 00000000000..a7c6f0c696e --- /dev/null +++ b/progs/redbook/nurbs.c @@ -0,0 +1,190 @@ + +/* 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. + */ +/* + * nurbs.c + * This program shows a NURBS (Non-uniform rational B-splines) + * surface, shaped like a heart. + */ +#include +#include + +#define S_NUMPOINTS 13 +#define S_ORDER 3 +#define S_NUMKNOTS (S_NUMPOINTS + S_ORDER) +#define T_NUMPOINTS 3 +#define T_ORDER 3 +#define T_NUMKNOTS (T_NUMPOINTS + T_ORDER) +#define SQRT2 1.41421356237309504880 + +/* initialized local data */ + +GLfloat sknots[S_NUMKNOTS] = + {-1.0, -1.0, -1.0, 0.0, 1.0, 2.0, 3.0, 4.0, + 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 9.0, 9.0}; +GLfloat tknots[T_NUMKNOTS] = {1.0, 1.0, 1.0, 2.0, 2.0, 2.0}; + +GLfloat ctlpoints[S_NUMPOINTS][T_NUMPOINTS][4] = { +{ {4.,2.,2.,1.},{4.,1.6,2.5,1.},{4.,2.,3.0,1.} }, +{ {5.,4.,2.,1.},{5.,4.,2.5,1.},{5.,4.,3.0,1.} }, +{ {6.,5.,2.,1.},{6.,5.,2.5,1.},{6.,5.,3.0,1.} }, +{ {SQRT2*6.,SQRT2*6.,SQRT2*2.,SQRT2}, + {SQRT2*6.,SQRT2*6.,SQRT2*2.5,SQRT2}, + {SQRT2*6.,SQRT2*6.,SQRT2*3.0,SQRT2} }, +{ {5.2,6.7,2.,1.},{5.2,6.7,2.5,1.},{5.2,6.7,3.0,1.} }, +{ {SQRT2*4.,SQRT2*6.,SQRT2*2.,SQRT2}, + {SQRT2*4.,SQRT2*6.,SQRT2*2.5,SQRT2}, + {SQRT2*4.,SQRT2*6.,SQRT2*3.0,SQRT2} }, +{ {4.,5.2,2.,1.},{4.,4.6,2.5,1.},{4.,5.2,3.0,1.} }, +{ {SQRT2*4.,SQRT2*6.,SQRT2*2.,SQRT2}, + {SQRT2*4.,SQRT2*6.,SQRT2*2.5,SQRT2}, + {SQRT2*4.,SQRT2*6.,SQRT2*3.0,SQRT2} }, +{ {2.8,6.7,2.,1.},{2.8,6.7,2.5,1.},{2.8,6.7,3.0,1.} }, +{ {SQRT2*2.,SQRT2*6.,SQRT2*2.,SQRT2}, + {SQRT2*2.,SQRT2*6.,SQRT2*2.5,SQRT2}, + {SQRT2*2.,SQRT2*6.,SQRT2*3.0,SQRT2} }, +{ {2.,5.,2.,1.},{2.,5.,2.5,1.},{2.,5.,3.0,1.} }, +{ {3.,4.,2.,1.},{3.,4.,2.5,1.},{3.,4.,3.0,1.} }, +{ {4.,2.,2.,1.},{4.,1.6,2.5,1.},{4.,2.,3.0,1.} } +}; + +GLUnurbsObj *theNurb; + +/* Initialize material property, light source, lighting model, + * and depth buffer. + */ +void myinit(void) +{ + GLfloat mat_ambient[] = { 1.0, 1.0, 1.0, 1.0 }; + GLfloat mat_diffuse[] = { 1.0, 0.2, 1.0, 1.0 }; + GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 }; + GLfloat mat_shininess[] = { 50.0 }; + + GLfloat light0_position[] = { 1.0, 0.1, 1.0, 0.0 }; + GLfloat light1_position[] = { -1.0, 0.1, 1.0, 0.0 }; + + GLfloat lmodel_ambient[] = { 0.3, 0.3, 0.3, 1.0 }; + + glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient); + glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); + glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); + glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess); + glLightfv(GL_LIGHT0, GL_POSITION, light0_position); + glLightfv(GL_LIGHT1, GL_POSITION, light1_position); + glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient); + + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + glEnable(GL_LIGHT1); + glDepthFunc(GL_LESS); + glEnable(GL_DEPTH_TEST); + glEnable(GL_AUTO_NORMAL); + + theNurb = gluNewNurbsRenderer(); + + gluNurbsProperty(theNurb, GLU_SAMPLING_TOLERANCE, 25.0); + gluNurbsProperty(theNurb, GLU_DISPLAY_MODE, GLU_FILL); +} + +void display(void) +{ + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + glPushMatrix(); + glTranslatef (4., 4.5, 2.5); + glRotatef (220.0, 1., 0., 0.); + glRotatef (115.0, 0., 1., 0.); + glTranslatef (-4., -4.5, -2.5); + + gluBeginSurface(theNurb); + gluNurbsSurface(theNurb, + S_NUMKNOTS, sknots, + T_NUMKNOTS, tknots, + 4 * T_NUMPOINTS, + 4, + &ctlpoints[0][0][0], + S_ORDER, T_ORDER, + GL_MAP2_VERTEX_4); + gluEndSurface(theNurb); + + glPopMatrix(); + glFlush(); +} + +void myReshape(int w, int h) +{ + glViewport(0, 0, w, h); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glFrustum(-1.0, 1.0, -1.5, 0.5, 0.8, 10.0); + + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + gluLookAt(7.0,4.5,4.0, 4.5,4.5,2.0, 6.0,-3.0,2.0); +} + +static void +key(unsigned char k, int x, int y) +{ + switch (k) { + case 27: /* Escape */ + exit(0); + break; + default: + return; + } + glutPostRedisplay(); +} + +/* Main Loop + * Open window with initial window size, title bar, + * RGBA display mode, and handle input events. + */ +int main(int argc, char** argv) +{ + glutInit(&argc, argv); + glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH); + glutCreateWindow (argv[0]); + myinit(); + glutReshapeFunc (myReshape); + glutDisplayFunc(display); + glutKeyboardFunc(key); + glutMainLoop(); + return 0; /* ANSI C requires main to return int. */ +} diff --git a/progs/redbook/pickdepth.c b/progs/redbook/pickdepth.c new file mode 100644 index 00000000000..ad5bdc81994 --- /dev/null +++ b/progs/redbook/pickdepth.c @@ -0,0 +1,217 @@ + +/* 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. + */ +/* + * pickdepth.c + * Picking is demonstrated in this program. In + * rendering mode, three overlapping rectangles are + * drawn. When the left mouse button is pressed, + * selection mode is entered with the picking matrix. + * Rectangles which are drawn under the cursor position + * are "picked." Pay special attention to the depth + * value range, which is returned. + */ +#include +#include +#include + +void +myinit(void) +{ + glClearColor(0.0, 0.0, 0.0, 0.0); + glDepthFunc(GL_LESS); + glEnable(GL_DEPTH_TEST); + glShadeModel(GL_FLAT); + glDepthRange(0.0, 1.0); /* The default z mapping */ +} + +/* The three rectangles are drawn. In selection mode, + * each rectangle is given the same name. Note that + * each rectangle is drawn with a different z value. + */ +void +drawRects(GLenum mode) +{ + if (mode == GL_SELECT) + glLoadName(1); + glBegin(GL_QUADS); + glColor3f(1.0, 1.0, 0.0); + glVertex3i(2, 0, 0); + glVertex3i(2, 6, 0); + glVertex3i(6, 6, 0); + glVertex3i(6, 0, 0); + glEnd(); + if (mode == GL_SELECT) + glLoadName(2); + glBegin(GL_QUADS); + glColor3f(0.0, 1.0, 1.0); + glVertex3i(3, 2, -1); + glVertex3i(3, 8, -1); + glVertex3i(8, 8, -1); + glVertex3i(8, 2, -1); + glEnd(); + if (mode == GL_SELECT) + glLoadName(3); + glBegin(GL_QUADS); + glColor3f(1.0, 0.0, 1.0); + glVertex3i(0, 2, -2); + glVertex3i(0, 7, -2); + glVertex3i(5, 7, -2); + glVertex3i(5, 2, -2); + glEnd(); +} + +/* processHits() prints out the contents of the + * selection array. + */ +void +processHits(GLint hits, GLuint buffer[]) +{ + GLint i; + GLuint j, names, *ptr; + + printf("hits = %d\n", hits); + ptr = (GLuint *) buffer; + for (i = 0; i < hits; i++) { /* for each hit */ + names = *ptr; + printf(" number of names for hit = %d\n", names); + ptr++; + printf(" z1 is %g;", (float) *ptr/0xffffffff); + ptr++; + printf(" z2 is %g\n", (float) *ptr/0xffffffff); + ptr++; + printf(" the name is "); + for (j = 0; j < names; j++) { /* for each name */ + printf("%d ", *ptr); + ptr++; + } + printf("\n"); + } +} + +/* pickRects() sets up selection mode, name stack, + * and projection matrix for picking. Then the objects + * are drawn. + */ +#define BUFSIZE 512 + +void +pickRects(int button, int state, int x, int y) +{ + GLuint selectBuf[BUFSIZE]; + GLint hits; + GLint viewport[4]; + + if (button != GLUT_LEFT_BUTTON || state != GLUT_DOWN) + return; + + glGetIntegerv(GL_VIEWPORT, viewport); + + glSelectBuffer(BUFSIZE, selectBuf); + (void) glRenderMode(GL_SELECT); + + glInitNames(); + glPushName(-1); + + glMatrixMode(GL_PROJECTION); + glPushMatrix(); + glLoadIdentity(); +/* create 5x5 pixel picking region near cursor location */ + gluPickMatrix((GLdouble) x, (GLdouble) (viewport[3] - y), + 5.0, 5.0, viewport); + glOrtho(0.0, 8.0, 0.0, 8.0, -0.5, 2.5); + drawRects(GL_SELECT); + glPopMatrix(); + glFlush(); + + hits = glRenderMode(GL_RENDER); + processHits(hits, selectBuf); +} + +void +display(void) +{ + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + drawRects(GL_RENDER); + glutSwapBuffers(); +} + +void +myReshape(int w, int h) +{ + glViewport(0, 0, w, h); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(0.0, 8.0, 0.0, 8.0, -0.5, 2.5); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); +} + +static void +key(unsigned char k, int x, int y) +{ + switch (k) { + case 27: /* Escape */ + exit(0); + break; + default: + return; + } + glutPostRedisplay(); +} + +/* Main Loop + * Open window with initial window size, title bar, + * RGBA display mode, depth buffer, and handle input events. + */ +int +main(int argc, char **argv) +{ + glutInitWindowSize(200, 200); + glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); + glutInit(&argc, argv); + glutCreateWindow(argv[0]); + myinit(); + glutMouseFunc(pickRects); + glutReshapeFunc(myReshape); + glutDisplayFunc(display); + glutKeyboardFunc(key); + glutMainLoop(); + return 0; /* ANSI C requires main to return int. */ +} diff --git a/progs/redbook/picksquare.c b/progs/redbook/picksquare.c new file mode 100644 index 00000000000..636edc97b4b --- /dev/null +++ b/progs/redbook/picksquare.c @@ -0,0 +1,197 @@ +/* + * Copyright (c) 1993-1997, 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(R) is a registered trademark of Silicon Graphics, Inc. + */ + +/* + * picksquare.c + * Use of multiple names and picking are demonstrated. + * A 3x3 grid of squares is drawn. When the left mouse + * button is pressed, all squares under the cursor position + * have their color changed. + */ +#include +#include +#include + +int board[3][3]; /* amount of color for each square */ + +/* Clear color value for every square on the board */ +void init(void) +{ + int i, j; + for (i = 0; i < 3; i++) + for (j = 0; j < 3; j ++) + board[i][j] = 0; + glClearColor (0.0, 0.0, 0.0, 0.0); +} + +/* The nine squares are drawn. In selection mode, each + * square is given two names: one for the row and the + * other for the column on the grid. The color of each + * square is determined by its position on the grid, and + * the value in the board[][] array. + */ +void drawSquares(GLenum mode) +{ + GLuint i, j; + for (i = 0; i < 3; i++) { + if (mode == GL_SELECT) + glLoadName (i); + for (j = 0; j < 3; j ++) { + if (mode == GL_SELECT) + glPushName (j); + glColor3f ((GLfloat) i/3.0, (GLfloat) j/3.0, + (GLfloat) board[i][j]/3.0); + glRecti (i, j, i+1, j+1); + if (mode == GL_SELECT) + glPopName (); + } + } +} + +/* processHits prints out the contents of the + * selection array. + */ +void processHits (GLint hits, GLuint buffer[]) +{ + GLint i; + GLuint j, ii = 0, jj = 0, names, *ptr; + + printf ("hits = %d\n", hits); + ptr = (GLuint *) buffer; + for (i = 0; i < hits; i++) { /* for each hit */ + names = *ptr; + printf (" number of names for this hit = %d\n", names); ptr++; + printf(" z1 is %g;", (float) *ptr/0x7fffffff); ptr++; + printf(" z2 is %g\n", (float) *ptr/0x7fffffff); ptr++; + printf (" names are "); + for (j = 0; j < names; j++) { /* for each name */ + printf ("%d ", *ptr); + if (j == 0) /* set row and column */ + ii = *ptr; + else if (j == 1) + jj = *ptr; + ptr++; + } + printf ("\n"); + board[ii][jj] = (board[ii][jj] + 1) % 3; + } +} + +/* pickSquares() sets up selection mode, name stack, + * and projection matrix for picking. Then the + * objects are drawn. + */ +#define BUFSIZE 512 + +void pickSquares(int button, int state, int x, int y) +{ + GLuint selectBuf[BUFSIZE]; + GLint hits; + GLint viewport[4]; + + if (button != GLUT_LEFT_BUTTON || state != GLUT_DOWN) + return; + + glGetIntegerv (GL_VIEWPORT, viewport); + + glSelectBuffer (BUFSIZE, selectBuf); + (void) glRenderMode (GL_SELECT); + + glInitNames(); + glPushName(0); + + glMatrixMode (GL_PROJECTION); + glPushMatrix (); + glLoadIdentity (); +/* create 5x5 pixel picking region near cursor location */ + gluPickMatrix ((GLdouble) x, (GLdouble) (viewport[3] - y), + 5.0, 5.0, viewport); + gluOrtho2D (0.0, 3.0, 0.0, 3.0); + drawSquares (GL_SELECT); + + glMatrixMode (GL_PROJECTION); + glPopMatrix (); + glFlush (); + + hits = glRenderMode (GL_RENDER); + processHits (hits, selectBuf); + glutPostRedisplay(); +} + +void display(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + drawSquares (GL_RENDER); + glFlush(); +} + +void reshape(int w, int h) +{ + glViewport(0, 0, w, h); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluOrtho2D (0.0, 3.0, 0.0, 3.0); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); +} + +/* ARGSUSED1 */ +void keyboard(unsigned char key, int x, int y) +{ + switch (key) { + case 27: + exit(0); + break; + } +} + +/* Main Loop */ +int main(int argc, char** argv) +{ + glutInit(&argc, argv); + glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); + glutInitWindowSize (100, 100); + glutInitWindowPosition (100, 100); + glutCreateWindow (argv[0]); + init (); + glutReshapeFunc (reshape); + glutDisplayFunc(display); + glutMouseFunc (pickSquares); + glutKeyboardFunc (keyboard); + glutMainLoop(); + return 0; +} diff --git a/progs/redbook/plane.c b/progs/redbook/plane.c new file mode 100644 index 00000000000..dc17f7b2386 --- /dev/null +++ b/progs/redbook/plane.c @@ -0,0 +1,171 @@ + +/* 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. + */ +/* + * plane.c + * This program demonstrates the use of local versus + * infinite lighting on a flat plane. + */ +#include +#include + +/* Initialize material property, light source, and lighting model. + */ +void myinit(void) +{ + GLfloat mat_ambient[] = { 0.0, 0.0, 0.0, 1.0 }; +/* mat_specular and mat_shininess are NOT default values */ + GLfloat mat_diffuse[] = { 0.4, 0.4, 0.4, 1.0 }; + GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 }; + GLfloat mat_shininess[] = { 15.0 }; + + GLfloat light_ambient[] = { 0.0, 0.0, 0.0, 1.0 }; + GLfloat light_diffuse[] = { 1.0, 1.0, 1.0, 1.0 }; + GLfloat light_specular[] = { 1.0, 1.0, 1.0, 1.0 }; + GLfloat lmodel_ambient[] = { 0.2, 0.2, 0.2, 1.0 }; + + glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient); + glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); + glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); + glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess); + glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient); + glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse); + glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular); + glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient); + + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + glDepthFunc(GL_LESS); + glEnable(GL_DEPTH_TEST); +} + +void drawPlane(void) +{ + glBegin (GL_QUADS); + glNormal3f (0.0, 0.0, 1.0); + glVertex3f (-1.0, -1.0, 0.0); + glVertex3f (0.0, -1.0, 0.0); + glVertex3f (0.0, 0.0, 0.0); + glVertex3f (-1.0, 0.0, 0.0); + + glNormal3f (0.0, 0.0, 1.0); + glVertex3f (0.0, -1.0, 0.0); + glVertex3f (1.0, -1.0, 0.0); + glVertex3f (1.0, 0.0, 0.0); + glVertex3f (0.0, 0.0, 0.0); + + glNormal3f (0.0, 0.0, 1.0); + glVertex3f (0.0, 0.0, 0.0); + glVertex3f (1.0, 0.0, 0.0); + glVertex3f (1.0, 1.0, 0.0); + glVertex3f (0.0, 1.0, 0.0); + + glNormal3f (0.0, 0.0, 1.0); + glVertex3f (0.0, 0.0, 0.0); + glVertex3f (0.0, 1.0, 0.0); + glVertex3f (-1.0, 1.0, 0.0); + glVertex3f (-1.0, 0.0, 0.0); + glEnd(); +} + +void display (void) +{ + GLfloat infinite_light[] = { 1.0, 1.0, 1.0, 0.0 }; + GLfloat local_light[] = { 1.0, 1.0, 1.0, 1.0 }; + + glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + glPushMatrix (); + glTranslatef (-1.5, 0.0, 0.0); + glLightfv (GL_LIGHT0, GL_POSITION, infinite_light); + drawPlane (); + glPopMatrix (); + + glPushMatrix (); + glTranslatef (1.5, 0.0, 0.0); + glLightfv (GL_LIGHT0, GL_POSITION, local_light); + drawPlane (); + glPopMatrix (); + glFlush (); +} + +void myReshape(int w, int h) +{ + glViewport (0, 0, w, h); + glMatrixMode (GL_PROJECTION); + glLoadIdentity (); + if (w <= h) + glOrtho (-1.5, 1.5, -1.5*(GLdouble)h/(GLdouble)w, + 1.5*(GLdouble)h/(GLdouble)w, -10.0, 10.0); + else + glOrtho (-1.5*(GLdouble)w/(GLdouble)h, + 1.5*(GLdouble)w/(GLdouble)h, -1.5, 1.5, -10.0, 10.0); + glMatrixMode (GL_MODELVIEW); +} + +static void +key(unsigned char k, int x, int y) +{ + switch (k) { + case 27: /* Escape */ + exit(0); + break; + default: + return; + } + glutPostRedisplay(); +} + +/* Main Loop + * Open window with initial window size, title bar, + * RGBA display mode, and handle input events. + */ +int main(int argc, char** argv) +{ + glutInit(&argc, argv); + glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH); + glutInitWindowSize (500, 200); + glutCreateWindow (argv[0]); + myinit(); + glutReshapeFunc (myReshape); + glutDisplayFunc(display); + glutKeyboardFunc(key); + glutMainLoop(); + return 0; /* ANSI C requires main to return int. */ +} diff --git a/progs/redbook/planet.c b/progs/redbook/planet.c new file mode 100644 index 00000000000..e13672d3f63 --- /dev/null +++ b/progs/redbook/planet.c @@ -0,0 +1,123 @@ +/* + * Copyright (c) 1993-1997, 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(R) is a registered trademark of Silicon Graphics, Inc. + */ + +/* + * planet.c + * This program shows how to composite modeling transformations + * to draw translated and rotated models. + * Interaction: pressing the d and y keys (day and year) + * alters the rotation of the planet around the sun. + */ +#include +#include + +static int year = 0, day = 0; + +void init(void) +{ + glClearColor (0.0, 0.0, 0.0, 0.0); + glShadeModel (GL_FLAT); +} + +void display(void) +{ + glClear (GL_COLOR_BUFFER_BIT); + glColor3f (1.0, 1.0, 1.0); + + glPushMatrix(); + glutWireSphere(1.0, 20, 16); /* draw sun */ + glRotatef ((GLfloat) year, 0.0, 1.0, 0.0); + glTranslatef (2.0, 0.0, 0.0); + glRotatef ((GLfloat) day, 0.0, 1.0, 0.0); + glutWireSphere(0.2, 10, 8); /* draw smaller planet */ + glPopMatrix(); + glutSwapBuffers(); +} + +void reshape (int w, int h) +{ + glViewport (0, 0, (GLsizei) w, (GLsizei) h); + glMatrixMode (GL_PROJECTION); + glLoadIdentity (); + gluPerspective(60.0, (GLfloat) w/(GLfloat) h, 1.0, 20.0); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + gluLookAt (0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); +} + +/* ARGSUSED1 */ +void keyboard (unsigned char key, int x, int y) +{ + switch (key) { + case 'd': + day = (day + 10) % 360; + glutPostRedisplay(); + break; + case 'D': + day = (day - 10) % 360; + glutPostRedisplay(); + break; + case 'y': + year = (year + 5) % 360; + glutPostRedisplay(); + break; + case 'Y': + year = (year - 5) % 360; + glutPostRedisplay(); + break; + case 27: + exit(0); + break; + default: + break; + } +} + +int main(int argc, char** argv) +{ + glutInit(&argc, argv); + glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB); + glutInitWindowSize (500, 500); + glutInitWindowPosition (100, 100); + glutCreateWindow (argv[0]); + init (); + glutDisplayFunc(display); + glutReshapeFunc(reshape); + glutKeyboardFunc(keyboard); + glutMainLoop(); + return 0; +} diff --git a/progs/redbook/polyoff.c b/progs/redbook/polyoff.c new file mode 100644 index 00000000000..2017b4d8eed --- /dev/null +++ b/progs/redbook/polyoff.c @@ -0,0 +1,333 @@ +/* + * Copyright (c) 1993-1997, 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(R) is a registered trademark of Silicon Graphics, Inc. + */ + +/* + * polyoff.c + * This program demonstrates polygon offset to draw a shaded + * polygon and its wireframe counterpart without ugly visual + * artifacts ("stitching"). + */ +#include +#include +#include +#include + +#ifdef GL_VERSION_1_1 +GLuint list; +GLint fill = 1; +GLfloat spinx = 0; +GLfloat 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. + */ +void display (void) +{ + GLfloat gray[] = { 0.8, 0.8, 0.8, 1.0 }; + GLfloat black[] = { 0.0, 0.0, 0.0, 1.0 }; + + glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glPushMatrix (); + glTranslatef (0.0, 0.0, tdist); + glRotatef ((GLfloat) spinx, 1.0, 0.0, 0.0); + glRotatef ((GLfloat) spiny, 0.0, 1.0, 0.0); + + 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); + } + + 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 + * create display list with sphere + * initialize lighting and depth buffer + */ +void gfxinit (void) +{ + GLfloat light_ambient[] = { 0.0, 0.0, 0.0, 1.0 }; + GLfloat light_diffuse[] = { 1.0, 1.0, 1.0, 1.0 }; + GLfloat light_specular[] = { 1.0, 1.0, 1.0, 1.0 }; + GLfloat light_position[] = { 1.0, 1.0, 1.0, 0.0 }; + + GLfloat global_ambient[] = { 0.2, 0.2, 0.2, 1.0 }; + + glClearColor (0.0, 0.0, 0.0, 1.0); + + list = glGenLists(1); + glNewList (list, GL_COMPILE); + glutSolidSphere(1.0, 20, 12); + glEndList (); + + glEnable(GL_DEPTH_TEST); + + glLightfv (GL_LIGHT0, GL_AMBIENT, light_ambient); + glLightfv (GL_LIGHT0, GL_DIFFUSE, light_diffuse); + glLightfv (GL_LIGHT0, GL_SPECULAR, light_specular); + glLightfv (GL_LIGHT0, GL_POSITION, light_position); + glLightModelfv (GL_LIGHT_MODEL_AMBIENT, global_ambient); +} + +/* call when window is resized */ +void reshape(int width, int height) +{ + glViewport (0, 0, width, height); + glMatrixMode (GL_PROJECTION); + glLoadIdentity (); + gluPerspective(45.0, (GLdouble)width/(GLdouble)height, + 1.0, 10.0); + glMatrixMode (GL_MODELVIEW); + glLoadIdentity (); + 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; + + 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) { + switch (button) { + case GLUT_LEFT_BUTTON: + switch (state) { + case GLUT_DOWN: + spinx += 5; + glutPostRedisplay(); + break; + default: + break; + } + break; + case GLUT_MIDDLE_BUTTON: + switch (state) { + case GLUT_DOWN: + spiny += 5; + glutPostRedisplay(); + break; + default: + break; + } + break; + case GLUT_RIGHT_BUTTON: + switch (state) { + case GLUT_UP: + exit(0); + break; + default: + break; + } + break; + default: + break; + } +} + +/* ARGSUSED1 */ +void keyboard (unsigned char key, int x, int y) +{ + switch (key) { + case 't': + if (tdist < 4.0) { + tdist = (tdist + 0.5); + glutPostRedisplay(); + } + break; + case 'T': + if (tdist > -5.0) { + tdist = (tdist - 0.5); + glutPostRedisplay(); + } + break; + case 'F': + polyfactor = polyfactor + 0.1; + printf ("polyfactor is %f\n", polyfactor); + glutPostRedisplay(); + break; + case 'f': + polyfactor = polyfactor - 0.1; + printf ("polyfactor is %f\n", polyfactor); + glutPostRedisplay(); + break; + case 'U': + polyunits = polyunits + 1.0; + printf ("polyunits is %f\n", polyunits); + glutPostRedisplay(); + break; + case 'u': + polyunits = polyunits - 1.0; + 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; + } +} + +static void +key(unsigned char k, int x, int y) +{ + switch (k) { + case 27: /* Escape */ + exit(0); + break; + default: + return; + } + 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"); + glutReshapeFunc(reshape); + glutDisplayFunc(display); + glutMouseFunc(mouse); + glutKeyboardFunc(keyboard); + gfxinit(); + glutMainLoop(); + return 0; +} +#else +int main(int argc, char** argv) +{ + fprintf (stderr, "This program demonstrates a feature which is not in OpenGL Version 1.0.\n"); + fprintf (stderr, "If your implementation of OpenGL Version 1.0 has the right extensions,\n"); + fprintf (stderr, "you may be able to modify this program to make it run.\n"); + return 0; +} +#endif diff --git a/progs/redbook/polys.c b/progs/redbook/polys.c new file mode 100644 index 00000000000..409abd17531 --- /dev/null +++ b/progs/redbook/polys.c @@ -0,0 +1,138 @@ + +/* 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. + */ +/* + * polys.c + * This program demonstrates polygon stippling. + */ +#include +#include + +void display(void) +{ + GLubyte fly[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x03, 0x80, 0x01, 0xC0, 0x06, 0xC0, 0x03, 0x60, 0x04, 0x60, 0x06, 0x20, +0x04, 0x30, 0x0C, 0x20, 0x04, 0x18, 0x18, 0x20, 0x04, 0x0C, 0x30, 0x20, +0x04, 0x06, 0x60, 0x20, 0x44, 0x03, 0xC0, 0x22, 0x44, 0x01, 0x80, 0x22, +0x44, 0x01, 0x80, 0x22, 0x44, 0x01, 0x80, 0x22, 0x44, 0x01, 0x80, 0x22, +0x44, 0x01, 0x80, 0x22, 0x44, 0x01, 0x80, 0x22, 0x66, 0x01, 0x80, 0x66, +0x33, 0x01, 0x80, 0xCC, 0x19, 0x81, 0x81, 0x98, 0x0C, 0xC1, 0x83, 0x30, +0x07, 0xe1, 0x87, 0xe0, 0x03, 0x3f, 0xfc, 0xc0, 0x03, 0x31, 0x8c, 0xc0, +0x03, 0x33, 0xcc, 0xc0, 0x06, 0x64, 0x26, 0x60, 0x0c, 0xcc, 0x33, 0x30, +0x18, 0xcc, 0x33, 0x18, 0x10, 0xc4, 0x23, 0x08, 0x10, 0x63, 0xC6, 0x08, +0x10, 0x30, 0x0c, 0x08, 0x10, 0x18, 0x18, 0x08, 0x10, 0x00, 0x00, 0x08}; + + 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}; + + glClear (GL_COLOR_BUFFER_BIT); + +/* draw all polygons in white */ + glColor3f (1.0, 1.0, 1.0); + +/* draw one solid, unstippled rectangle, */ +/* then two stippled rectangles */ + glRectf (25.0, 25.0, 125.0, 125.0); + glEnable (GL_POLYGON_STIPPLE); + glPolygonStipple (fly); + glRectf (125.0, 25.0, 225.0, 125.0); + glPolygonStipple (halftone); + glRectf (225.0, 25.0, 325.0, 125.0); + glDisable (GL_POLYGON_STIPPLE); + + glFlush (); +} + +void myinit (void) +{ +/* clear background to black */ + glClearColor (0.0, 0.0, 0.0, 0.0); + glShadeModel (GL_FLAT); +} + +static void reshape(GLsizei w, GLsizei h) +{ + 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); + glLoadIdentity(); +} + +static void +key(unsigned char k, int x, int y) +{ + switch (k) { + case 27: /* Escape */ + exit(0); + break; + default: + break; + } + glutPostRedisplay(); +} + +/* Main Loop + * Open window with initial window size, title bar, + * RGBA display mode, and handle input events. + */ +int main(int argc, char** argv) +{ + glutInit(&argc, argv); + glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); + glutInitWindowSize (350, 150); + glutCreateWindow (argv[0]); + myinit (); + glutDisplayFunc(display); + glutReshapeFunc(reshape); + glutKeyboardFunc(key); + glutMainLoop(); + return 0; /* ANSI C requires main to return int. */ +} diff --git a/progs/redbook/quadric.c b/progs/redbook/quadric.c new file mode 100644 index 00000000000..4e46c85f829 --- /dev/null +++ b/progs/redbook/quadric.c @@ -0,0 +1,189 @@ +/* + * Copyright (c) 1993-1997, 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(R) is a registered trademark of Silicon Graphics, Inc. + */ + +/* + * quadric.c + * This program demonstrates the use of some of the gluQuadric* + * routines. Quadric objects are created with some quadric + * properties and the callback routine to handle errors. + * Note that the cylinder has no top or bottom and the circle + * has a hole in it. + */ +#include +#include +#include + +/* Win32 calling conventions. */ +#ifndef CALLBACK +#define CALLBACK +#endif + +GLuint startList; + +void CALLBACK errorCallback(GLenum errorCode) +{ + const GLubyte *estring; + + estring = gluErrorString(errorCode); + fprintf(stderr, "Quadric Error: %s\n", estring); + exit(0); +} + +void init(void) +{ + GLUquadricObj *qobj; + GLfloat mat_ambient[] = { 0.5, 0.5, 0.5, 1.0 }; + GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 }; + GLfloat mat_shininess[] = { 50.0 }; + GLfloat light_position[] = { 1.0, 1.0, 1.0, 0.0 }; + GLfloat model_ambient[] = { 0.5, 0.5, 0.5, 1.0 }; + + glClearColor(0.0, 0.0, 0.0, 0.0); + + glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient); + glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); + glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess); + glLightfv(GL_LIGHT0, GL_POSITION, light_position); + glLightModelfv(GL_LIGHT_MODEL_AMBIENT, model_ambient); + + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + glEnable(GL_DEPTH_TEST); + +/* Create 4 display lists, each with a different quadric object. + * Different drawing styles and surface normal specifications + * are demonstrated. + */ + startList = glGenLists(4); + qobj = gluNewQuadric(); + gluQuadricCallback(qobj, GLU_ERROR, + (GLvoid (CALLBACK*) ()) errorCallback); + + gluQuadricDrawStyle(qobj, GLU_FILL); /* smooth shaded */ + gluQuadricNormals(qobj, GLU_SMOOTH); + glNewList(startList, GL_COMPILE); + gluSphere(qobj, 0.75, 15, 10); + glEndList(); + + gluQuadricDrawStyle(qobj, GLU_FILL); /* flat shaded */ + gluQuadricNormals(qobj, GLU_FLAT); + glNewList(startList+1, GL_COMPILE); + gluCylinder(qobj, 0.5, 0.3, 1.0, 15, 5); + glEndList(); + + gluQuadricDrawStyle(qobj, GLU_LINE); /* all polygons wireframe */ + gluQuadricNormals(qobj, GLU_NONE); + glNewList(startList+2, GL_COMPILE); + gluDisk(qobj, 0.25, 1.0, 20, 4); + glEndList(); + + gluQuadricDrawStyle(qobj, GLU_SILHOUETTE); /* boundary only */ + gluQuadricNormals(qobj, GLU_NONE); + glNewList(startList+3, GL_COMPILE); + gluPartialDisk(qobj, 0.0, 1.0, 20, 4, 0.0, 225.0); + glEndList(); +} + +void display(void) +{ + glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glPushMatrix(); + + glEnable(GL_LIGHTING); + glShadeModel (GL_SMOOTH); + glTranslatef(-1.0, -1.0, 0.0); + glCallList(startList); + + glShadeModel (GL_FLAT); + glTranslatef(0.0, 2.0, 0.0); + glPushMatrix(); + glRotatef(300.0, 1.0, 0.0, 0.0); + glCallList(startList+1); + glPopMatrix(); + + glDisable(GL_LIGHTING); + glColor3f(0.0, 1.0, 1.0); + glTranslatef(2.0, -2.0, 0.0); + glCallList(startList+2); + + glColor3f(1.0, 1.0, 0.0); + glTranslatef(0.0, 2.0, 0.0); + glCallList(startList+3); + + glPopMatrix(); + glFlush(); +} + +void reshape (int w, int h) +{ + glViewport(0, 0, (GLsizei) w, (GLsizei) h); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + if (w <= h) + glOrtho(-2.5, 2.5, -2.5*(GLfloat)h/(GLfloat)w, + 2.5*(GLfloat)h/(GLfloat)w, -10.0, 10.0); + else + glOrtho(-2.5*(GLfloat)w/(GLfloat)h, + 2.5*(GLfloat)w/(GLfloat)h, -2.5, 2.5, -10.0, 10.0); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); +} + +/* ARGSUSED1 */ +void keyboard(unsigned char key, int x, int y) +{ + switch (key) { + case 27: + exit(0); + break; + } +} + +int main(int argc, char** argv) +{ + glutInit(&argc, argv); + glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH); + glutInitWindowSize(500, 500); + glutInitWindowPosition(100, 100); + glutCreateWindow(argv[0]); + init(); + glutDisplayFunc(display); + glutReshapeFunc(reshape); + glutKeyboardFunc(keyboard); + glutMainLoop(); + return 0; +} diff --git a/progs/redbook/robot.c b/progs/redbook/robot.c new file mode 100644 index 00000000000..94e20ac71eb --- /dev/null +++ b/progs/redbook/robot.c @@ -0,0 +1,132 @@ +/* + * Copyright (c) 1993-1997, 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(R) is a registered trademark of Silicon Graphics, Inc. + */ + +/* + * robot.c + * This program shows how to composite modeling transformations + * to draw translated and rotated hierarchical models. + * Interaction: pressing the s and e keys (shoulder and elbow) + * alters the rotation of the robot arm. + */ +#include +#include + +static int shoulder = 0, elbow = 0; + +void init(void) +{ + glClearColor (0.0, 0.0, 0.0, 0.0); + glShadeModel (GL_FLAT); +} + +void display(void) +{ + glClear (GL_COLOR_BUFFER_BIT); + glPushMatrix(); + glTranslatef (-1.0, 0.0, 0.0); + glRotatef ((GLfloat) shoulder, 0.0, 0.0, 1.0); + glTranslatef (1.0, 0.0, 0.0); + glPushMatrix(); + glScalef (2.0, 0.4, 1.0); + glutWireCube (1.0); + glPopMatrix(); + + glTranslatef (1.0, 0.0, 0.0); + glRotatef ((GLfloat) elbow, 0.0, 0.0, 1.0); + glTranslatef (1.0, 0.0, 0.0); + glPushMatrix(); + glScalef (2.0, 0.4, 1.0); + glutWireCube (1.0); + glPopMatrix(); + + glPopMatrix(); + glutSwapBuffers(); +} + +void reshape (int w, int h) +{ + glViewport (0, 0, (GLsizei) w, (GLsizei) h); + glMatrixMode (GL_PROJECTION); + glLoadIdentity (); + gluPerspective(65.0, (GLfloat) w/(GLfloat) h, 1.0, 20.0); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTranslatef (0.0, 0.0, -5.0); +} + +/* ARGSUSED1 */ +void keyboard (unsigned char key, int x, int y) +{ + switch (key) { + case 's': + shoulder = (shoulder + 5) % 360; + glutPostRedisplay(); + break; + case 'S': + shoulder = (shoulder - 5) % 360; + glutPostRedisplay(); + break; + case 'e': + elbow = (elbow + 5) % 360; + glutPostRedisplay(); + break; + case 'E': + elbow = (elbow - 5) % 360; + glutPostRedisplay(); + break; + case 27: + exit(0); + break; + default: + break; + } +} + +int main(int argc, char** argv) +{ + glutInit(&argc, argv); + glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB); + glutInitWindowSize (500, 500); + glutInitWindowPosition (100, 100); + glutCreateWindow (argv[0]); + init (); + glutDisplayFunc(display); + glutReshapeFunc(reshape); + glutKeyboardFunc(keyboard); + glutMainLoop(); + return 0; +} diff --git a/progs/redbook/sccolorlight.c b/progs/redbook/sccolorlight.c new file mode 100644 index 00000000000..0ea750e5846 --- /dev/null +++ b/progs/redbook/sccolorlight.c @@ -0,0 +1,141 @@ + +/* 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. + */ +/* + * sccolorlight.c + * This program demonstrates the use of a colored + * (magenta, in this example) light source. Objects + * are drawn using a grey material characteristic. + * A single light source illuminates the objects. + */ +#include +#include + +/* Initialize material property and light source. + */ +void myinit(void) +{ + GLfloat light_ambient[] = { 0.0, 0.0, 0.0, 1.0 }; + GLfloat light_diffuse[] = { 1.0, 0.0, 1.0, 1.0 }; + GLfloat light_specular[] = { 1.0, 0.0, 1.0, 1.0 }; +/* light_position is NOT default value */ + GLfloat light_position[] = { 1.0, 1.0, 1.0, 0.0 }; + + glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient); + glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse); + glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular); + glLightfv(GL_LIGHT0, GL_POSITION, light_position); + + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + glDepthFunc(GL_LESS); + glEnable(GL_DEPTH_TEST); +} + +void display(void) +{ + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glPushMatrix (); + glRotatef (20.0, 1.0, 0.0, 0.0); + + glPushMatrix (); + glTranslatef (-0.75, 0.5, 0.0); + glRotatef (90.0, 1.0, 0.0, 0.0); + glutSolidTorus (0.275, 0.85, 20, 20); + glPopMatrix (); + + glPushMatrix (); + glTranslatef (-0.75, -0.5, 0.0); + glRotatef (270.0, 1.0, 0.0, 0.0); + glutSolidCone (1.0, 2.0, 20, 20); + glPopMatrix (); + + glPushMatrix (); + glTranslatef (0.75, 0.0, -1.0); + glutSolidSphere (1.0, 20, 20); + glPopMatrix (); + + glPopMatrix (); + glFlush(); +} + +void myReshape(int w, int h) +{ + glViewport(0, 0, w, h); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + if (w <= h) + glOrtho (-2.5, 2.5, -2.5*(GLfloat)h/(GLfloat)w, + 2.5*(GLfloat)h/(GLfloat)w, -10.0, 10.0); + else + glOrtho (-2.5*(GLfloat)w/(GLfloat)h, + 2.5*(GLfloat)w/(GLfloat)h, -2.5, 2.5, -10.0, 10.0); + glMatrixMode(GL_MODELVIEW); +} + +static void +key(unsigned char k, int x, int y) +{ + switch (k) { + case 27: /* Escape */ + exit(0); + break; + default: + return; + } + glutPostRedisplay(); +} + +/* Main Loop + * Open window with initial window size, title bar, + * RGBA display mode, and handle input events. + */ +int main(int argc, char** argv) +{ + glutInit(&argc, argv); + glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH); + glutInitWindowSize (500, 500); + glutCreateWindow (argv[0]); + myinit(); + glutReshapeFunc (myReshape); + glutDisplayFunc(display); + glutKeyboardFunc(key); + glutMainLoop(); + return 0; /* ANSI C requires main to return int. */ +} diff --git a/progs/redbook/scene.c b/progs/redbook/scene.c new file mode 100644 index 00000000000..c3abc727b78 --- /dev/null +++ b/progs/redbook/scene.c @@ -0,0 +1,141 @@ + +/* 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. + */ +/* + * scene.c + * This program demonstrates the use of the GL lighting model. + * Objects are drawn using a grey material characteristic. + * A single light source illuminates the objects. + */ +#include +#include + +/* Initialize material property and light source. + */ +void myinit (void) +{ + GLfloat light_ambient[] = { 0.0, 0.0, 0.0, 1.0 }; + GLfloat light_diffuse[] = { 1.0, 1.0, 1.0, 1.0 }; + GLfloat light_specular[] = { 1.0, 1.0, 1.0, 1.0 }; +/* light_position is NOT default value */ + GLfloat light_position[] = { 1.0, 1.0, 1.0, 0.0 }; + + glLightfv (GL_LIGHT0, GL_AMBIENT, light_ambient); + glLightfv (GL_LIGHT0, GL_DIFFUSE, light_diffuse); + glLightfv (GL_LIGHT0, GL_SPECULAR, light_specular); + glLightfv (GL_LIGHT0, GL_POSITION, light_position); + + glEnable (GL_LIGHTING); + glEnable (GL_LIGHT0); + glDepthFunc(GL_LESS); + glEnable(GL_DEPTH_TEST); +} + +void display (void) +{ + glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + glPushMatrix (); + glRotatef (20.0, 1.0, 0.0, 0.0); + + glPushMatrix (); + glTranslatef (-0.75, 0.5, 0.0); + glRotatef (90.0, 1.0, 0.0, 0.0); + glutSolidTorus (0.275, 0.85, 15, 15); + glPopMatrix (); + + glPushMatrix (); + glTranslatef (-0.75, -0.5, 0.0); + glRotatef (270.0, 1.0, 0.0, 0.0); + glutSolidCone (1.0, 2.0, 15, 15); + glPopMatrix (); + + glPushMatrix (); + glTranslatef (0.75, 0.0, -1.0); + glutSolidSphere (1.0, 15, 15); + glPopMatrix (); + + glPopMatrix (); + glFlush (); +} + +void myReshape(int w, int h) +{ + glViewport (0, 0, w, h); + glMatrixMode (GL_PROJECTION); + glLoadIdentity (); + if (w <= h) + glOrtho (-2.5, 2.5, -2.5*(GLfloat)h/(GLfloat)w, + 2.5*(GLfloat)h/(GLfloat)w, -10.0, 10.0); + else + glOrtho (-2.5*(GLfloat)w/(GLfloat)h, + 2.5*(GLfloat)w/(GLfloat)h, -2.5, 2.5, -10.0, 10.0); + glMatrixMode (GL_MODELVIEW); +} + +static void +key(unsigned char k, int x, int y) +{ + switch (k) { + case 27: /* Escape */ + exit(0); + break; + default: + return; + } + glutPostRedisplay(); +} + +/* Main Loop + * Open window with initial window size, title bar, + * RGBA display mode, and handle input events. + */ +int main(int argc, char** argv) +{ + glutInit(&argc, argv); + glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH); + glutInitWindowSize (500, 500); + glutCreateWindow (argv[0]); + myinit (); + glutReshapeFunc (myReshape); + glutDisplayFunc(display); + glutKeyboardFunc(key); + glutMainLoop(); + return 0; /* ANSI C requires main to return int. */ +} diff --git a/progs/redbook/scenebamb.c b/progs/redbook/scenebamb.c new file mode 100644 index 00000000000..e7264d2003f --- /dev/null +++ b/progs/redbook/scenebamb.c @@ -0,0 +1,140 @@ + +/* 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. + */ +/* + * scenebamb.c + * This program demonstrates use of a blue ambient light + * source. + */ +#include +#include + +/* Initialize light source and lighting. + */ +void myinit(void) +{ + GLfloat light_ambient[] = { 0.0, 0.0, 1.0, 1.0 }; + GLfloat light_diffuse[] = { 1.0, 1.0, 1.0, 1.0 }; + GLfloat light_specular[] = { 1.0, 1.0, 1.0, 1.0 }; +/* light_position is NOT default value */ + GLfloat light_position[] = { 1.0, 1.0, 1.0, 0.0 }; + + glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient); + glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse); + glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular); + glLightfv(GL_LIGHT0, GL_POSITION, light_position); + + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + glDepthFunc(GL_LESS); + glEnable(GL_DEPTH_TEST); +} + +void display(void) +{ + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + glPushMatrix (); + glRotatef (20.0, 1.0, 0.0, 0.0); + + glPushMatrix (); + glTranslatef (-0.75, 0.5, 0.0); + glRotatef (90.0, 1.0, 0.0, 0.0); + glutSolidTorus (0.275, 0.85, 15, 15); + glPopMatrix (); + + glPushMatrix (); + glTranslatef (-0.75, -0.5, 0.0); + glRotatef (270.0, 1.0, 0.0, 0.0); + glutSolidCone (1.0, 2.0, 15, 15); + glPopMatrix (); + + glPushMatrix (); + glTranslatef (0.75, 0.0, -1.0); + glutSolidSphere (1.0, 15, 15); + glPopMatrix (); + + glPopMatrix (); + glFlush(); +} + +void myReshape(int w, int h) +{ + glViewport(0, 0, w, h); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + if (w <= h) + glOrtho (-2.5, 2.5, -2.5*(GLfloat)h/(GLfloat)w, + 2.5*(GLfloat)h/(GLfloat)w, -10.0, 10.0); + else + glOrtho (-2.5*(GLfloat)w/(GLfloat)h, + 2.5*(GLfloat)w/(GLfloat)h, -2.5, 2.5, -10.0, 10.0); + glMatrixMode(GL_MODELVIEW); +} + +static void +key(unsigned char k, int x, int y) +{ + switch (k) { + case 27: /* Escape */ + exit(0); + break; + default: + return; + } + glutPostRedisplay(); +} + +/* Main Loop + * Open window with initial window size, title bar, + * RGBA display mode, and handle input events. + */ +int main(int argc, char** argv) +{ + glutInit(&argc, argv); + glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH); + glutInitWindowSize (500, 500); + glutCreateWindow (argv[0]); + myinit(); + glutReshapeFunc (myReshape); + glutDisplayFunc(display); + glutKeyboardFunc(key); + glutMainLoop(); + return 0; /* ANSI C requires main to return int. */ +} diff --git a/progs/redbook/sceneflat.c b/progs/redbook/sceneflat.c new file mode 100644 index 00000000000..10891fb9977 --- /dev/null +++ b/progs/redbook/sceneflat.c @@ -0,0 +1,140 @@ + +/* 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. + */ +/* + * sceneflat.c + * This program draws lighted objects with flat shading. + */ +#include +#include + +/* Initialize light source and shading model (GL_FLAT). + */ +void myinit(void) +{ + GLfloat light_ambient[] = { 0.0, 0.0, 0.0, 1.0 }; + GLfloat light_diffuse[] = { 1.0, 1.0, 1.0, 1.0 }; + GLfloat light_specular[] = { 1.0, 1.0, 1.0, 1.0 }; +/* light_position is NOT default value */ + GLfloat light_position[] = { 1.0, 1.0, 1.0, 0.0 }; + + glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient); + glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse); + glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular); + glLightfv(GL_LIGHT0, GL_POSITION, light_position); + + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + glDepthFunc(GL_LESS); + glEnable(GL_DEPTH_TEST); + glShadeModel (GL_FLAT); +} + +void display(void) +{ + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + glPushMatrix (); + glRotatef (20.0, 1.0, 0.0, 0.0); + + glPushMatrix (); + glTranslatef (-0.75, 0.5, 0.0); + glRotatef (90.0, 1.0, 0.0, 0.0); + glutSolidTorus (0.275, 0.85, 15, 15); + glPopMatrix (); + + glPushMatrix (); + glTranslatef (-0.75, -0.5, 0.0); + glRotatef (270.0, 1.0, 0.0, 0.0); + glutSolidCone (1.0, 2.0, 15, 15); + glPopMatrix (); + + glPushMatrix (); + glTranslatef (0.75, 0.0, -1.0); + glutSolidSphere (1.0, 15, 15); + glPopMatrix (); + + glPopMatrix (); + glFlush(); +} + +void myReshape(int w, int h) +{ + glViewport(0, 0, w, h); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + if (w <= h) + glOrtho (-2.5, 2.5, -2.5*(GLfloat)h/(GLfloat)w, + 2.5*(GLfloat)h/(GLfloat)w, -10.0, 10.0); + else + glOrtho (-2.5*(GLfloat)w/(GLfloat)h, + 2.5*(GLfloat)w/(GLfloat)h, -2.5, 2.5, -10.0, 10.0); + glMatrixMode(GL_MODELVIEW); +} + +static void +key(unsigned char k, int x, int y) +{ + switch (k) { + case 27: /* Escape */ + exit(0); + break; + default: + return; + } + glutPostRedisplay(); +} + +/* Main Loop + * Open window with initial window size, title bar, + * RGBA display mode, and handle input events. + */ +int main(int argc, char** argv) +{ + glutInit(&argc, argv); + glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH); + glutInitWindowSize (500, 500); + glutCreateWindow (argv[0]); + myinit(); + glutReshapeFunc (myReshape); + glutDisplayFunc(display); + glutKeyboardFunc(key); + glutMainLoop(); + return 0; /* ANSI C requires main to return int. */ +} diff --git a/progs/redbook/select.c b/progs/redbook/select.c new file mode 100644 index 00000000000..928373b8796 --- /dev/null +++ b/progs/redbook/select.c @@ -0,0 +1,222 @@ +/* + * Copyright (c) 1993-1997, 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(R) is a registered trademark of Silicon Graphics, Inc. + */ + +/* + * select.c + * This is an illustration of the selection mode and + * name stack, which detects whether objects which collide + * with a viewing volume. First, four triangles and a + * rectangular box representing a viewing volume are drawn + * (drawScene routine). The green triangle and yellow + * triangles appear to lie within the viewing volume, but + * the red triangle appears to lie outside it. Then the + * selection mode is entered (selectObjects routine). + * Drawing to the screen ceases. To see if any collisions + * occur, the four triangles are called. In this example, + * the green triangle causes one hit with the name 1, and + * the yellow triangles cause one hit with the name 3. + */ +#include +#include +#include + +/* draw a triangle with vertices at (x1, y1), (x2, y2) + * and (x3, y3) at z units away from the origin. + */ +void drawTriangle (GLfloat x1, GLfloat y1, GLfloat x2, + GLfloat y2, GLfloat x3, GLfloat y3, GLfloat z) +{ + glBegin (GL_TRIANGLES); + glVertex3f (x1, y1, z); + glVertex3f (x2, y2, z); + glVertex3f (x3, y3, z); + glEnd (); +} + +/* draw a rectangular box with these outer x, y, and z values */ +void drawViewVolume (GLfloat x1, GLfloat x2, GLfloat y1, + GLfloat y2, GLfloat z1, GLfloat z2) +{ + glColor3f (1.0, 1.0, 1.0); + glBegin (GL_LINE_LOOP); + glVertex3f (x1, y1, -z1); + glVertex3f (x2, y1, -z1); + glVertex3f (x2, y2, -z1); + glVertex3f (x1, y2, -z1); + glEnd (); + + glBegin (GL_LINE_LOOP); + glVertex3f (x1, y1, -z2); + glVertex3f (x2, y1, -z2); + glVertex3f (x2, y2, -z2); + glVertex3f (x1, y2, -z2); + glEnd (); + + glBegin (GL_LINES); /* 4 lines */ + glVertex3f (x1, y1, -z1); + glVertex3f (x1, y1, -z2); + glVertex3f (x1, y2, -z1); + glVertex3f (x1, y2, -z2); + glVertex3f (x2, y1, -z1); + glVertex3f (x2, y1, -z2); + glVertex3f (x2, y2, -z1); + glVertex3f (x2, y2, -z2); + glEnd (); +} + +/* drawScene draws 4 triangles and a wire frame + * which represents the viewing volume. + */ +void drawScene (void) +{ + glMatrixMode (GL_PROJECTION); + glLoadIdentity (); + gluPerspective (40.0, 4.0/3.0, 1.0, 100.0); + + glMatrixMode (GL_MODELVIEW); + glLoadIdentity (); + gluLookAt (7.5, 7.5, 12.5, 2.5, 2.5, -5.0, 0.0, 1.0, 0.0); + glColor3f (0.0, 1.0, 0.0); /* green triangle */ + drawTriangle (2.0, 2.0, 3.0, 2.0, 2.5, 3.0, -5.0); + glColor3f (1.0, 0.0, 0.0); /* red triangle */ + drawTriangle (2.0, 7.0, 3.0, 7.0, 2.5, 8.0, -5.0); + glColor3f (1.0, 1.0, 0.0); /* yellow triangles */ + drawTriangle (2.0, 2.0, 3.0, 2.0, 2.5, 3.0, 0.0); + drawTriangle (2.0, 2.0, 3.0, 2.0, 2.5, 3.0, -10.0); + drawViewVolume (0.0, 5.0, 0.0, 5.0, 0.0, 10.0); +} + +/* processHits prints out the contents of the selection array + */ +void processHits (GLint hits, GLuint buffer[]) +{ + GLint i; + GLuint j, names, *ptr; + + printf ("hits = %d\n", hits); + ptr = (GLuint *) buffer; + for (i = 0; i < hits; i++) { /* for each hit */ + names = *ptr; + printf (" number of names for hit = %d\n", names); ptr++; + printf(" z1 is %g;", (float) *ptr/0x7fffffff); ptr++; + printf(" z2 is %g\n", (float) *ptr/0x7fffffff); ptr++; + printf (" the name is "); + for (j = 0; j < names; j++) { /* for each name */ + printf ("%d ", *ptr); ptr++; + } + printf ("\n"); + } +} + +/* selectObjects "draws" the triangles in selection mode, + * assigning names for the triangles. Note that the third + * and fourth triangles share one name, so that if either + * or both triangles intersects the viewing/clipping volume, + * only one hit will be registered. + */ +#define BUFSIZE 512 + +void selectObjects(void) +{ + GLuint selectBuf[BUFSIZE]; + GLint hits; + + glSelectBuffer (BUFSIZE, selectBuf); + (void) glRenderMode (GL_SELECT); + + glInitNames(); + glPushName(0); + + glPushMatrix (); + glMatrixMode (GL_PROJECTION); + glLoadIdentity (); + glOrtho (0.0, 5.0, 0.0, 5.0, 0.0, 10.0); + glMatrixMode (GL_MODELVIEW); + glLoadIdentity (); + glLoadName(1); + drawTriangle (2.0, 2.0, 3.0, 2.0, 2.5, 3.0, -5.0); + glLoadName(2); + drawTriangle (2.0, 7.0, 3.0, 7.0, 2.5, 8.0, -5.0); + glLoadName(3); + drawTriangle (2.0, 2.0, 3.0, 2.0, 2.5, 3.0, 0.0); + drawTriangle (2.0, 2.0, 3.0, 2.0, 2.5, 3.0, -10.0); + glPopMatrix (); + glFlush (); + + hits = glRenderMode (GL_RENDER); + processHits (hits, selectBuf); +} + +void init (void) +{ + glEnable(GL_DEPTH_TEST); + glShadeModel(GL_FLAT); +} + +void display(void) +{ + glClearColor (0.0, 0.0, 0.0, 0.0); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + drawScene (); + selectObjects (); + glFlush(); +} + +/* ARGSUSED1 */ +void keyboard(unsigned char key, int x, int y) +{ + switch (key) { + case 27: + exit(0); + break; + } +} + +/* Main Loop */ +int main(int argc, char** argv) +{ + glutInit(&argc, argv); + glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH); + glutInitWindowSize (200, 200); + glutInitWindowPosition (100, 100); + glutCreateWindow (argv[0]); + init(); + glutDisplayFunc(display); + glutKeyboardFunc(keyboard); + glutMainLoop(); + return 0; +} diff --git a/progs/redbook/smooth.c b/progs/redbook/smooth.c new file mode 100644 index 00000000000..9d22fc90251 --- /dev/null +++ b/progs/redbook/smooth.c @@ -0,0 +1,106 @@ +/* + * Copyright (c) 1993-1997, 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(R) is a registered trademark of Silicon Graphics, Inc. + */ + +/* + * smooth.c + * This program demonstrates smooth shading. + * A smooth shaded polygon is drawn in a 2-D projection. + */ +#include +#include + +void init(void) +{ + glClearColor (0.0, 0.0, 0.0, 0.0); + glShadeModel (GL_SMOOTH); +} + +void triangle(void) +{ + glBegin (GL_TRIANGLES); + glColor3f (1.0, 0.0, 0.0); + glVertex2f (5.0, 5.0); + glColor3f (0.0, 1.0, 0.0); + glVertex2f (25.0, 5.0); + glColor3f (0.0, 0.0, 1.0); + glVertex2f (5.0, 25.0); + glEnd(); +} + +void display(void) +{ + glClear (GL_COLOR_BUFFER_BIT); + triangle (); + glFlush (); +} + +void reshape (int w, int h) +{ + glViewport (0, 0, (GLsizei) w, (GLsizei) h); + glMatrixMode (GL_PROJECTION); + glLoadIdentity (); + if (w <= h) + gluOrtho2D (0.0, 30.0, 0.0, 30.0 * (GLfloat) h/(GLfloat) w); + else + gluOrtho2D (0.0, 30.0 * (GLfloat) w/(GLfloat) h, 0.0, 30.0); + glMatrixMode(GL_MODELVIEW); +} + +/* ARGSUSED1 */ +void keyboard(unsigned char key, int x, int y) +{ + switch (key) { + case 27: + exit(0); + break; + } +} + +int main(int argc, char** argv) +{ + glutInit(&argc, argv); + glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); + glutInitWindowSize (500, 500); + glutInitWindowPosition (100, 100); + glutCreateWindow (argv[0]); + init (); + glutDisplayFunc(display); + glutReshapeFunc(reshape); + glutKeyboardFunc (keyboard); + glutMainLoop(); + return 0; +} diff --git a/progs/redbook/stencil.c b/progs/redbook/stencil.c new file mode 100644 index 00000000000..b33e40a0307 --- /dev/null +++ b/progs/redbook/stencil.c @@ -0,0 +1,193 @@ + +/* 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. + */ +/* stencil.c + * This program draws two rotated tori in a window. + * A diamond in the center of the window masks out part + * of the scene. Within this mask, a different model + * (a sphere) is drawn in a different color. + */ + +/* + * !!! NOTE !!! + * + * This demo is poorly written. The stencil buffer should be + * redrawn in display(), not in the myReshape() function. + * The reason is if the window gets "damaged" then the stencil buffer + * contents will be in an undefined state (myReshape is not called when + * a window is damaged and needs to be redrawn). If the stencil buffer + * contents are undefined, the results of display() are unpredictable. + * + * -Brian + */ + + +#include +#include + +#define YELLOWMAT 1 +#define BLUEMAT 2 + +void myinit (void) +{ + GLfloat yellow_diffuse[] = { 0.7, 0.7, 0.0, 1.0 }; + GLfloat yellow_specular[] = { 1.0, 1.0, 1.0, 1.0 }; + + GLfloat blue_diffuse[] = { 0.1, 0.1, 0.7, 1.0 }; + GLfloat blue_specular[] = { 0.1, 1.0, 1.0, 1.0 }; + + GLfloat position_one[] = { 1.0, 1.0, 1.0, 0.0 }; + + glNewList(YELLOWMAT, GL_COMPILE); + glMaterialfv(GL_FRONT, GL_DIFFUSE, yellow_diffuse); + glMaterialfv(GL_FRONT, GL_SPECULAR, yellow_specular); + glMaterialf(GL_FRONT, GL_SHININESS, 64.0); + glEndList(); + + glNewList(BLUEMAT, GL_COMPILE); + glMaterialfv(GL_FRONT, GL_DIFFUSE, blue_diffuse); + glMaterialfv(GL_FRONT, GL_SPECULAR, blue_specular); + glMaterialf(GL_FRONT, GL_SHININESS, 45.0); + glEndList(); + + glLightfv(GL_LIGHT0, GL_POSITION, position_one); + + glEnable(GL_LIGHT0); + glEnable(GL_LIGHTING); + glDepthFunc(GL_LESS); + glEnable(GL_DEPTH_TEST); + + glClearStencil(0x0); + glEnable(GL_STENCIL_TEST); + +} + +/* Draw a sphere in a diamond-shaped section in the + * middle of a window with 2 tori. + */ +void display(void) +{ + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + glStencilOp (GL_KEEP, GL_KEEP, GL_KEEP); + +/* draw blue sphere where the stencil is 1 */ + glStencilFunc (GL_EQUAL, 0x1, 0x1); + glCallList (BLUEMAT); + glutSolidSphere (0.5, 15, 15); + +/* draw the tori where the stencil is not 1 */ + glStencilFunc (GL_NOTEQUAL, 0x1, 0x1); + glPushMatrix(); + glRotatef (45.0, 0.0, 0.0, 1.0); + glRotatef (45.0, 0.0, 1.0, 0.0); + glCallList (YELLOWMAT); + glutSolidTorus (0.275, 0.85, 15, 15); + glPushMatrix(); + glRotatef (90.0, 1.0, 0.0, 0.0); + glutSolidTorus (0.275, 0.85, 15, 15); + glPopMatrix(); + glPopMatrix(); + + glFlush(); + glutSwapBuffers(); +} + +/* Whenever the window is reshaped, redefine the + * coordinate system and redraw the stencil area. + */ +void myReshape(int w, int h) +{ + glViewport(0, 0, w, h); + + glClear(GL_STENCIL_BUFFER_BIT); +/* create a diamond shaped stencil area */ + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-3.0, 3.0, -3.0, 3.0, -1.0, 1.0); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + + glStencilFunc (GL_ALWAYS, 0x1, 0x1); + glStencilOp (GL_REPLACE, GL_REPLACE, GL_REPLACE); + glBegin(GL_QUADS); + glVertex3f (-1.0, 0.0, 0.0); + glVertex3f (0.0, 1.0, 0.0); + glVertex3f (1.0, 0.0, 0.0); + glVertex3f (0.0, -1.0, 0.0); + glEnd(); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluPerspective(45.0, (GLfloat) w/(GLfloat) h, 3.0, 7.0); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTranslatef(0.0, 0.0, -5.0); +} + +static void +key(unsigned char k, int x, int y) +{ + switch (k) { + case 27: /* Escape */ + exit(0); + break; + default: + return; + } + glutPostRedisplay(); +} + +/* Main Loop + * Open window with initial window size, title bar, + * RGBA display mode, and handle input events. + */ +int main(int argc, char** argv) +{ + glutInit(&argc, argv); + glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH | GLUT_STENCIL); + glutInitWindowSize (400, 400); + glutCreateWindow (argv[0]); + myinit (); + glutReshapeFunc (myReshape); + glutDisplayFunc(display); + glutKeyboardFunc(key); + glutMainLoop(); + return 0; /* ANSI C requires main to return int. */ +} diff --git a/progs/redbook/stroke.c b/progs/redbook/stroke.c new file mode 100644 index 00000000000..19b0391cbae --- /dev/null +++ b/progs/redbook/stroke.c @@ -0,0 +1,195 @@ + +/* 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. + */ +/* + * stroke.c + * This program demonstrates some characters of a + * stroke (vector) font. The characters are represented + * by display lists, which are given numbers which + * correspond to the ASCII values of the characters. + * Use of glCallLists() is demonstrated. + */ +#include +#include +#include + +#define PT 1 +#define STROKE 2 +#define END 3 + +typedef struct charpoint { + GLfloat x, y; + int type; +} CP; + +CP Adata[] = { + { 0, 0, PT}, {0, 9, PT}, {1, 10, PT}, {4, 10, PT}, + {5, 9, PT}, {5, 0, STROKE}, {0, 5, PT}, {5, 5, END} +}; + +CP Edata[] = { + {5, 0, PT}, {0, 0, PT}, {0, 10, PT}, {5, 10, STROKE}, + {0, 5, PT}, {4, 5, END} +}; + +CP Pdata[] = { + {0, 0, PT}, {0, 10, PT}, {4, 10, PT}, {5, 9, PT}, {5, 6, PT}, + {4, 5, PT}, {0, 5, END} +}; + +CP Rdata[] = { + {0, 0, PT}, {0, 10, PT}, {4, 10, PT}, {5, 9, PT}, {5, 6, PT}, + {4, 5, PT}, {0, 5, STROKE}, {3, 5, PT}, {5, 0, END} +}; + +CP Sdata[] = { + {0, 1, PT}, {1, 0, PT}, {4, 0, PT}, {5, 1, PT}, {5, 4, PT}, + {4, 5, PT}, {1, 5, PT}, {0, 6, PT}, {0, 9, PT}, {1, 10, PT}, + {4, 10, PT}, {5, 9, END} +}; + +/* drawLetter() interprets the instructions from the array + * for that letter and renders the letter with line segments. + */ +void drawLetter(CP *l) +{ + glBegin(GL_LINE_STRIP); + for (;;) { + switch (l->type) { + case PT: + glVertex2fv(&l->x); + break; + case STROKE: + glVertex2fv(&l->x); + glEnd(); + glBegin(GL_LINE_STRIP); + break; + case END: + glVertex2fv(&l->x); + glEnd(); + glTranslatef(8.0, 0.0, 0.0); + return; + } + l++; + } +} + +/* Create a display list for each of 6 characters */ +void myinit (void) +{ + GLuint base; + + glShadeModel (GL_FLAT); + + base = glGenLists (128); + glListBase(base); + glNewList(base+'A', GL_COMPILE); drawLetter(Adata); glEndList(); + glNewList(base+'E', GL_COMPILE); drawLetter(Edata); glEndList(); + glNewList(base+'P', GL_COMPILE); drawLetter(Pdata); glEndList(); + glNewList(base+'R', GL_COMPILE); drawLetter(Rdata); glEndList(); + glNewList(base+'S', GL_COMPILE); drawLetter(Sdata); glEndList(); + glNewList(base+' ', GL_COMPILE); glTranslatef(8.0, 0.0, 0.0); glEndList(); +} + +char *test1 = "A SPARE SERAPE APPEARS AS"; +char *test2 = "APES PREPARE RARE PEPPERS"; + +void printStrokedString(char *s) +{ + GLsizei len = (GLsizei) strlen(s); + glCallLists(len, GL_BYTE, (GLbyte *)s); +} + +void display(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + glColor3f(1.0, 1.0, 1.0); + glPushMatrix(); + glScalef(2.0, 2.0, 2.0); + glTranslatef(10.0, 30.0, 0.0); + printStrokedString(test1); + glPopMatrix(); + glPushMatrix(); + glScalef(2.0, 2.0, 2.0); + glTranslatef(10.0, 13.0, 0.0); + printStrokedString(test2); + glPopMatrix(); + glFlush(); +} + +static void reshape(GLsizei w, GLsizei h) +{ + 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); + glLoadIdentity(); +} + +static void +key(unsigned char k, int x, int y) +{ + switch (k) { + case 27: /* Escape */ + exit(0); + break; + default: + return; + } + glutPostRedisplay(); +} + +/* Main Loop + * Open window with initial window size, title bar, + * RGBA display mode, and handle input events. + */ +int main(int argc, char** argv) +{ + glutInit(&argc, argv); + glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); + glutInitWindowSize (440, 120); + glutCreateWindow (argv[0]); + myinit (); + glutDisplayFunc(display); + glutReshapeFunc(reshape); + glutKeyboardFunc(key); + glutMainLoop(); + return 0; /* ANSI C requires main to return int. */ +} diff --git a/progs/redbook/surface.c b/progs/redbook/surface.c new file mode 100644 index 00000000000..e33ce14f4fc --- /dev/null +++ b/progs/redbook/surface.c @@ -0,0 +1,232 @@ +/* aux2glut conversion Copyright (c) Mark J. Kilgard, 1994, 1995 */ + +/** + * (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. + */ +/** + * surface.c + * This program draws a NURBS surface in the shape of a + * symmetrical hill. + */ +#include +#include + +GLfloat ctlpoints[4][4][3]; +int showPoints = 0; + +GLUnurbsObj *theNurb; + +/* + * Initializes the control points of the surface to a small hill. + * The control points range from -3 to +3 in x, y, and z + */ +void init_surface(void) +{ + int u, v; + for (u = 0; u < 4; u++) { + for (v = 0; v < 4; v++) { + ctlpoints[u][v][0] = 2.0*((GLfloat)u - 1.5); + ctlpoints[u][v][1] = 2.0*((GLfloat)v - 1.5); + + if ( (u == 1 || u == 2) && (v == 1 || v == 2)) + ctlpoints[u][v][2] = 7.0; + else + ctlpoints[u][v][2] = -3.0; + } + } +} + +/* Initialize material property and depth buffer. + */ +void myinit(void) +{ + GLfloat mat_diffuse[] = { 0.7, 0.7, 0.7, 1.0 }; + GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 }; + GLfloat mat_shininess[] = { 100.0 }; + + glClearColor (0.0, 0.0, 0.0, 1.0); + glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); + glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); + glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess); + + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + glDepthFunc(GL_LESS); + glEnable(GL_DEPTH_TEST); + glEnable(GL_AUTO_NORMAL); + glEnable(GL_NORMALIZE); + + init_surface(); + + theNurb = gluNewNurbsRenderer(); + gluNurbsProperty(theNurb, GLU_SAMPLING_TOLERANCE, 25.0); + gluNurbsProperty(theNurb, GLU_DISPLAY_MODE, GLU_FILL); + + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTranslatef (0.0, 0.0, -5.0); +} + +void display(void) +{ + GLfloat knots[8] = {0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0}; + int i, j; + + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + glPushMatrix(); + glRotatef(330.0, 1.,0.,0.); + glScalef (0.25, 0.25, 0.25); + + gluBeginSurface(theNurb); + gluNurbsSurface(theNurb, + 8, knots, + 8, knots, + 4 * 3, + 3, + &ctlpoints[0][0][0], + 4, 4, + GL_MAP2_VERTEX_3); + gluEndSurface(theNurb); + + if(showPoints) { + glPointSize(5.0); + glDisable(GL_LIGHTING); + glColor3f(1.0, 1.0, 0.0); + glBegin(GL_POINTS); + for(i=0;i<4;i++) { + for(j=0;j<4;j++) { + glVertex3f(ctlpoints[i][j][0], ctlpoints[i][j][1], ctlpoints[i][j][2]); + } + } + glEnd(); + glEnable(GL_LIGHTING); + } + + glPopMatrix(); + glutSwapBuffers(); +} + +void reshape(int w, int h) +{ + glViewport(0, 0, w, h); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluPerspective (45.0, (GLdouble)w/(GLdouble)h, 3.0, 8.0); + + glMatrixMode(GL_MODELVIEW); +} + +void +menu(int value) +{ + switch (value) { + case 0: + case 1: + showPoints = value; + break; + case 2: + gluNurbsProperty(theNurb, GLU_DISPLAY_MODE, GLU_FILL); + break; + case 3: + gluNurbsProperty(theNurb, GLU_DISPLAY_MODE, GLU_OUTLINE_POLYGON); + break; + } + glutPostRedisplay(); +} + +int down = 0, lastx; + +/* ARGSUSED1 */ +void +motion(int x, int y) +{ + if (down) { + glRotatef(lastx - x, 0, 1, 0); + lastx = x; + glutPostRedisplay(); + } +} + +/* ARGSUSED3 */ +void +mouse(int button, int state, int x, int y) +{ + if (button == GLUT_LEFT_BUTTON) { + if (state == GLUT_DOWN) { + lastx = x; + down = 1; + } else { + down = 0; + } + } +} + +static void +key(unsigned char k, int x, int y) +{ + switch (k) { + case 27: /* Escape */ + exit(0); + break; + default: + return; + } + glutPostRedisplay(); +} + +/* Main Loop */ +int +main(int argc, char** argv) +{ + glutInit(&argc, argv); + glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGB); + glutCreateWindow(argv[0]); + myinit(); + glutReshapeFunc(reshape); + glutDisplayFunc(display); + glutCreateMenu(menu); + glutAddMenuEntry("Show control points", 1); + glutAddMenuEntry("Hide control points", 0); + glutAddMenuEntry("Solid", 2); + glutAddMenuEntry("Wireframe", 3); + glutAttachMenu(GLUT_RIGHT_BUTTON); + glutMouseFunc(mouse); + glutMotionFunc(motion); + glutKeyboardFunc(key); + glutMainLoop(); + return 0; /* ANSI C requires main to return int. */ +} diff --git a/progs/redbook/teaambient.c b/progs/redbook/teaambient.c new file mode 100644 index 00000000000..53b5111752f --- /dev/null +++ b/progs/redbook/teaambient.c @@ -0,0 +1,162 @@ + +/* 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. + */ +/** + * teaambient.c + * This program renders three lighted, shaded teapots, with + * different ambient values. + */ +#include +#include + +/* Initialize light source and lighting model. + */ +void +myinit(void) +{ + GLfloat light_ambient[] = + {0.0, 0.0, 0.0, 1.0}; + GLfloat light_diffuse[] = + {1.0, 1.0, 1.0, 1.0}; + GLfloat light_specular[] = + {1.0, 1.0, 1.0, 1.0}; +/* light_position is NOT default value */ + GLfloat light_position[] = + {1.0, 0.0, 0.0, 0.0}; + GLfloat global_ambient[] = + {0.75, 0.75, 0.75, 1.0}; + + glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient); + glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse); + glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular); + glLightfv(GL_LIGHT0, GL_POSITION, light_position); + + glLightModelfv(GL_LIGHT_MODEL_AMBIENT, global_ambient); + + glFrontFace(GL_CW); + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + glEnable(GL_AUTO_NORMAL); + glEnable(GL_NORMALIZE); + glDepthFunc(GL_LESS); + glEnable(GL_DEPTH_TEST); +} + +void +display(void) +{ + GLfloat low_ambient[] = + {0.1, 0.1, 0.1, 1.0}; + GLfloat more_ambient[] = + {0.4, 0.4, 0.4, 1.0}; + GLfloat most_ambient[] = + {1.0, 1.0, 1.0, 1.0}; + + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + /* material has small ambient reflection */ + glMaterialfv(GL_FRONT, GL_AMBIENT, low_ambient); + glMaterialf(GL_FRONT, GL_SHININESS, 40.0); + glPushMatrix(); + glTranslatef(0.0, 2.0, 0.0); + glutSolidTeapot(1.0); + glPopMatrix(); + + /* material has moderate ambient reflection */ + glMaterialfv(GL_FRONT, GL_AMBIENT, more_ambient); + glPushMatrix(); + glTranslatef(0.0, 0.0, 0.0); + glutSolidTeapot(1.0); + glPopMatrix(); + + /* material has large ambient reflection */ + glMaterialfv(GL_FRONT, GL_AMBIENT, most_ambient); + glPushMatrix(); + glTranslatef(0.0, -2.0, 0.0); + glutSolidTeapot(1.0); + glPopMatrix(); + glFlush(); +} + +void +myReshape(int w, int h) +{ + glViewport(0, 0, w, h); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + if (w <= h) + glOrtho(-4.0, 4.0, -4.0 * (GLfloat) h / (GLfloat) w, + 4.0 * (GLfloat) h / (GLfloat) w, -10.0, 10.0); + else + glOrtho(-4.0 * (GLfloat) w / (GLfloat) h, + 4.0 * (GLfloat) w / (GLfloat) h, -4.0, 4.0, -10.0, 10.0); + glMatrixMode(GL_MODELVIEW); +} + +static void +key(unsigned char k, int x, int y) +{ + switch (k) { + case 27: /* Escape */ + exit(0); + break; + default: + return; + } + glutPostRedisplay(); +} + +/* Main Loop + * Open window with initial window size, title bar, + * RGBA display mode, and handle input events. + */ +int +main(int argc, char **argv) +{ + glutInit(&argc, argv); + glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH); + glutInitWindowSize(500, 500); + glutCreateWindow(argv[0]); + myinit(); + glutReshapeFunc(myReshape); + glutDisplayFunc(display); + glutKeyboardFunc(key); + glutMainLoop(); + return 0; /* ANSI C requires main to return int. */ +} diff --git a/progs/redbook/teapots.c b/progs/redbook/teapots.c new file mode 100644 index 00000000000..fb7aed380eb --- /dev/null +++ b/progs/redbook/teapots.c @@ -0,0 +1,220 @@ + +/* 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. + */ +/** + * teapots.c + * This program demonstrates lots of material properties. + * A single light source illuminates the objects. + */ +#include +#include + +/* + * Initialize depth buffer, projection matrix, light source, and lighting + * model. Do not specify a material property here. + */ +void +myinit(void) +{ + GLfloat ambient[] = + {0.0, 0.0, 0.0, 1.0}; + GLfloat diffuse[] = + {1.0, 1.0, 1.0, 1.0}; + GLfloat position[] = + {0.0, 3.0, 3.0, 0.0}; + + GLfloat lmodel_ambient[] = + {0.2, 0.2, 0.2, 1.0}; + GLfloat local_view[] = + {0.0}; + + glLightfv(GL_LIGHT0, GL_AMBIENT, ambient); + glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse); + glLightfv(GL_LIGHT0, GL_POSITION, position); + glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient); + glLightModelfv(GL_LIGHT_MODEL_LOCAL_VIEWER, local_view); + + glFrontFace(GL_CW); + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + glEnable(GL_AUTO_NORMAL); + glEnable(GL_NORMALIZE); + glEnable(GL_DEPTH_TEST); + glDepthFunc(GL_LESS); +} + +/* + * Move object into position. Use 3rd through 12th parameters to specify the + * material property. Draw a teapot. + */ +void +renderTeapot(GLfloat x, GLfloat y, + GLfloat ambr, GLfloat ambg, GLfloat ambb, + GLfloat difr, GLfloat difg, GLfloat difb, + GLfloat specr, GLfloat specg, GLfloat specb, GLfloat shine) +{ + float mat[4]; + + glPushMatrix(); + glTranslatef(x, y, 0.0); + mat[0] = ambr; + mat[1] = ambg; + mat[2] = ambb; + mat[3] = 1.0; + glMaterialfv(GL_FRONT, GL_AMBIENT, mat); + mat[0] = difr; + mat[1] = difg; + mat[2] = difb; + glMaterialfv(GL_FRONT, GL_DIFFUSE, mat); + mat[0] = specr; + mat[1] = specg; + mat[2] = specb; + glMaterialfv(GL_FRONT, GL_SPECULAR, mat); + glMaterialf(GL_FRONT, GL_SHININESS, shine * 128.0); + glutSolidTeapot(1.0); + glPopMatrix(); +} + +/** + * First column: emerald, jade, obsidian, pearl, ruby, turquoise + * 2nd column: brass, bronze, chrome, copper, gold, silver + * 3rd column: black, cyan, green, red, white, yellow plastic + * 4th column: black, cyan, green, red, white, yellow rubber + */ +void +display(void) +{ + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + renderTeapot(2.0, 17.0, 0.0215, 0.1745, 0.0215, + 0.07568, 0.61424, 0.07568, 0.633, 0.727811, 0.633, 0.6); + renderTeapot(2.0, 14.0, 0.135, 0.2225, 0.1575, + 0.54, 0.89, 0.63, 0.316228, 0.316228, 0.316228, 0.1); + renderTeapot(2.0, 11.0, 0.05375, 0.05, 0.06625, + 0.18275, 0.17, 0.22525, 0.332741, 0.328634, 0.346435, 0.3); + renderTeapot(2.0, 8.0, 0.25, 0.20725, 0.20725, + 1, 0.829, 0.829, 0.296648, 0.296648, 0.296648, 0.088); + renderTeapot(2.0, 5.0, 0.1745, 0.01175, 0.01175, + 0.61424, 0.04136, 0.04136, 0.727811, 0.626959, 0.626959, 0.6); + renderTeapot(2.0, 2.0, 0.1, 0.18725, 0.1745, + 0.396, 0.74151, 0.69102, 0.297254, 0.30829, 0.306678, 0.1); + renderTeapot(6.0, 17.0, 0.329412, 0.223529, 0.027451, + 0.780392, 0.568627, 0.113725, 0.992157, 0.941176, 0.807843, + 0.21794872); + renderTeapot(6.0, 14.0, 0.2125, 0.1275, 0.054, + 0.714, 0.4284, 0.18144, 0.393548, 0.271906, 0.166721, 0.2); + renderTeapot(6.0, 11.0, 0.25, 0.25, 0.25, + 0.4, 0.4, 0.4, 0.774597, 0.774597, 0.774597, 0.6); + renderTeapot(6.0, 8.0, 0.19125, 0.0735, 0.0225, + 0.7038, 0.27048, 0.0828, 0.256777, 0.137622, 0.086014, 0.1); + renderTeapot(6.0, 5.0, 0.24725, 0.1995, 0.0745, + 0.75164, 0.60648, 0.22648, 0.628281, 0.555802, 0.366065, 0.4); + renderTeapot(6.0, 2.0, 0.19225, 0.19225, 0.19225, + 0.50754, 0.50754, 0.50754, 0.508273, 0.508273, 0.508273, 0.4); + renderTeapot(10.0, 17.0, 0.0, 0.0, 0.0, 0.01, 0.01, 0.01, + 0.50, 0.50, 0.50, .25); + renderTeapot(10.0, 14.0, 0.0, 0.1, 0.06, 0.0, 0.50980392, 0.50980392, + 0.50196078, 0.50196078, 0.50196078, .25); + renderTeapot(10.0, 11.0, 0.0, 0.0, 0.0, + 0.1, 0.35, 0.1, 0.45, 0.55, 0.45, .25); + renderTeapot(10.0, 8.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0, + 0.7, 0.6, 0.6, .25); + renderTeapot(10.0, 5.0, 0.0, 0.0, 0.0, 0.55, 0.55, 0.55, + 0.70, 0.70, 0.70, .25); + renderTeapot(10.0, 2.0, 0.0, 0.0, 0.0, 0.5, 0.5, 0.0, + 0.60, 0.60, 0.50, .25); + renderTeapot(14.0, 17.0, 0.02, 0.02, 0.02, 0.01, 0.01, 0.01, + 0.4, 0.4, 0.4, .078125); + renderTeapot(14.0, 14.0, 0.0, 0.05, 0.05, 0.4, 0.5, 0.5, + 0.04, 0.7, 0.7, .078125); + renderTeapot(14.0, 11.0, 0.0, 0.05, 0.0, 0.4, 0.5, 0.4, + 0.04, 0.7, 0.04, .078125); + renderTeapot(14.0, 8.0, 0.05, 0.0, 0.0, 0.5, 0.4, 0.4, + 0.7, 0.04, 0.04, .078125); + renderTeapot(14.0, 5.0, 0.05, 0.05, 0.05, 0.5, 0.5, 0.5, + 0.7, 0.7, 0.7, .078125); + renderTeapot(14.0, 2.0, 0.05, 0.05, 0.0, 0.5, 0.5, 0.4, + 0.7, 0.7, 0.04, .078125); + glFlush(); +} + +void +myReshape(int w, int h) +{ + glViewport(0, 0, w, h); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + if (w <= h) + glOrtho(0.0, 16.0, 0.0, 18.0 * (GLfloat) h / (GLfloat) w, + -10.0, 10.0); + else + glOrtho(0.0, 16.0 * (GLfloat) w / (GLfloat) h, 0.0, 18.0, + -10.0, 10.0); + glMatrixMode(GL_MODELVIEW); +} + +static void +key(unsigned char k, int x, int y) +{ + switch (k) { + case 27: /* Escape */ + exit(0); + break; + default: + return; + } + glutPostRedisplay(); +} + +/* + * Main Loop Open window with initial window size, title bar, RGBA display + * mode, and handle input events. + */ +int +main(int argc, char **argv) +{ + glutInit(&argc, argv); + glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH); + glutCreateWindow(argv[0]); + myinit(); + glutReshapeFunc(myReshape); + glutDisplayFunc(display); + glutKeyboardFunc(key); + glutMainLoop(); + return 0; /* ANSI C requires main to return int. */ +} diff --git a/progs/redbook/tess.c b/progs/redbook/tess.c new file mode 100644 index 00000000000..238a469aff2 --- /dev/null +++ b/progs/redbook/tess.c @@ -0,0 +1,241 @@ +/* + * Copyright (c) 1993-1997, 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(R) is a registered trademark of Silicon Graphics, Inc. + */ + +/* + * tess.c + * This program demonstrates polygon tessellation. + * Two tesselated objects are drawn. The first is a + * rectangle with a triangular hole. The second is a + * smooth shaded, self-intersecting star. + * + * Note the exterior rectangle is drawn with its vertices + * in counter-clockwise order, but its interior clockwise. + * Note the combineCallback is needed for the self-intersecting + * star. Also note that removing the TessProperty for the + * star will make the interior unshaded (WINDING_ODD). + */ +#include +#include +#include + +#ifdef GLU_VERSION_1_2 + +/* Win32 calling conventions. */ +#ifndef CALLBACK +#define CALLBACK +#endif + +GLuint startList; + +void display (void) { + glClear(GL_COLOR_BUFFER_BIT); + glColor3f(1.0, 1.0, 1.0); + glCallList(startList); + glCallList(startList + 1); + glFlush(); +} + +void CALLBACK beginCallback(GLenum which) +{ + glBegin(which); +} + +void CALLBACK errorCallback(GLenum errorCode) +{ + const GLubyte *estring; + + estring = gluErrorString(errorCode); + fprintf(stderr, "Tessellation Error: %s\n", (char *) estring); + exit(0); +} + +void CALLBACK endCallback(void) +{ + glEnd(); +} + +void CALLBACK vertexCallback(GLvoid *vertex) +{ + const GLdouble *pointer; + + pointer = (GLdouble *) vertex; + glColor3dv(pointer+3); + glVertex3dv(pointer); +} + +/* combineCallback is used to create a new vertex when edges + * intersect. coordinate location is trivial to calculate, + * but weight[4] may be used to average color, normal, or texture + * coordinate data. In this program, color is weighted. + */ +void CALLBACK combineCallback(GLdouble coords[3], + GLdouble *vertex_data[4], + GLfloat weight[4], GLdouble **dataOut ) +{ + GLdouble *vertex; + int i; + + vertex = (GLdouble *) malloc(6 * sizeof(GLdouble)); + + vertex[0] = coords[0]; + vertex[1] = coords[1]; + vertex[2] = coords[2]; + for (i = 3; i < 6; i++) + vertex[i] = weight[0] * vertex_data[0][i] + + weight[1] * vertex_data[1][i] + + weight[2] * vertex_data[2][i] + + weight[3] * vertex_data[3][i]; + *dataOut = vertex; +} + +void init (void) +{ + GLUtesselator *tobj; + GLdouble rect[4][3] = {{50.0, 50.0, 0.0}, + {200.0, 50.0, 0.0}, + {200.0, 200.0, 0.0}, + {50.0, 200.0, 0.0}}; + GLdouble tri[3][3] = {{75.0, 75.0, 0.0}, + {125.0, 175.0, 0.0}, + {175.0, 75.0, 0.0}}; + GLdouble star[5][6] = {{250.0, 50.0, 0.0, 1.0, 0.0, 1.0}, + {325.0, 200.0, 0.0, 1.0, 1.0, 0.0}, + {400.0, 50.0, 0.0, 0.0, 1.0, 1.0}, + {250.0, 150.0, 0.0, 1.0, 0.0, 0.0}, + {400.0, 150.0, 0.0, 0.0, 1.0, 0.0}}; + + glClearColor(0.0, 0.0, 0.0, 0.0); + + startList = glGenLists(2); + + tobj = gluNewTess(); + gluTessCallback(tobj, GLU_TESS_VERTEX, + (GLvoid (CALLBACK*) ()) &glVertex3dv); + gluTessCallback(tobj, GLU_TESS_BEGIN, + (GLvoid (CALLBACK*) ()) &beginCallback); + gluTessCallback(tobj, GLU_TESS_END, + (GLvoid (CALLBACK*) ()) &endCallback); + gluTessCallback(tobj, GLU_TESS_ERROR, + (GLvoid (CALLBACK*) ()) &errorCallback); + + /* rectangle with triangular hole inside */ + glNewList(startList, GL_COMPILE); + glShadeModel(GL_FLAT); + gluTessBeginPolygon(tobj, NULL); + gluTessBeginContour(tobj); + gluTessVertex(tobj, rect[0], rect[0]); + gluTessVertex(tobj, rect[1], rect[1]); + gluTessVertex(tobj, rect[2], rect[2]); + gluTessVertex(tobj, rect[3], rect[3]); + gluTessEndContour(tobj); + gluTessBeginContour(tobj); + gluTessVertex(tobj, tri[0], tri[0]); + gluTessVertex(tobj, tri[1], tri[1]); + gluTessVertex(tobj, tri[2], tri[2]); + gluTessEndContour(tobj); + gluTessEndPolygon(tobj); + glEndList(); + + gluTessCallback(tobj, GLU_TESS_VERTEX, + (GLvoid (CALLBACK*) ()) &vertexCallback); + gluTessCallback(tobj, GLU_TESS_BEGIN, + (GLvoid (CALLBACK*) ()) &beginCallback); + gluTessCallback(tobj, GLU_TESS_END, + (GLvoid (CALLBACK*) ()) &endCallback); + gluTessCallback(tobj, GLU_TESS_ERROR, + (GLvoid (CALLBACK*) ()) &errorCallback); + gluTessCallback(tobj, GLU_TESS_COMBINE, + (GLvoid (CALLBACK*) ()) &combineCallback); + + /* smooth shaded, self-intersecting star */ + glNewList(startList + 1, GL_COMPILE); + glShadeModel(GL_SMOOTH); + gluTessProperty(tobj, GLU_TESS_WINDING_RULE, + GLU_TESS_WINDING_POSITIVE); + gluTessBeginPolygon(tobj, NULL); + gluTessBeginContour(tobj); + gluTessVertex(tobj, star[0], star[0]); + gluTessVertex(tobj, star[1], star[1]); + gluTessVertex(tobj, star[2], star[2]); + gluTessVertex(tobj, star[3], star[3]); + gluTessVertex(tobj, star[4], star[4]); + gluTessEndContour(tobj); + gluTessEndPolygon(tobj); + glEndList(); + gluDeleteTess(tobj); +} + +void reshape (int w, int h) +{ + glViewport(0, 0, (GLsizei) w, (GLsizei) h); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluOrtho2D(0.0, (GLdouble) w, 0.0, (GLdouble) h); +} + +/* ARGSUSED1 */ +void keyboard(unsigned char key, int x, int y) +{ + switch (key) { + case 27: + exit(0); + break; + } +} + +int main(int argc, char** argv) +{ + glutInit(&argc, argv); + glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); + glutInitWindowSize(500, 500); + glutCreateWindow(argv[0]); + init(); + glutDisplayFunc(display); + glutReshapeFunc(reshape); + glutKeyboardFunc(keyboard); + glutMainLoop(); + return 0; +} + +#else +int main(int argc, char** argv) +{ + fprintf (stderr, "This program demonstrates the new tesselator API in GLU 1.2.\n"); + fprintf (stderr, "Your GLU library does not support this new interface, sorry.\n"); + return 0; +} +#endif diff --git a/progs/redbook/tesswind.c b/progs/redbook/tesswind.c new file mode 100644 index 00000000000..7d00c9f907d --- /dev/null +++ b/progs/redbook/tesswind.c @@ -0,0 +1,290 @@ +/* + * Copyright (c) 1993-1997, 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(R) is a registered trademark of Silicon Graphics, Inc. + */ + +/* + * tesswind.c + * This program demonstrates the winding rule polygon + * tessellation property. Four tessellated objects are drawn, + * each with very different contours. When the w key is pressed, + * the objects are drawn with a different winding rule. + */ +#include +#include +#include + +#ifdef GLU_VERSION_1_2 + +/* Win32 calling conventions. */ +#ifndef CALLBACK +#define CALLBACK +#endif + +GLdouble currentWinding = GLU_TESS_WINDING_ODD; +int currentShape = 0; +GLUtesselator *tobj; +GLuint list; + +/* Make four display lists, + * each with a different tessellated object. + */ +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}}; + 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}}; + 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}}; + 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}}; + static GLdouble tri[3][3] = + {{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); + + glNewList(list, GL_COMPILE); + gluTessBeginPolygon(tobj, NULL); + gluTessBeginContour(tobj); + for (i = 0; i < 4; i++) + gluTessVertex(tobj, rects[i], rects[i]); + gluTessEndContour(tobj); + gluTessBeginContour(tobj); + for (i = 4; i < 8; i++) + gluTessVertex(tobj, rects[i], rects[i]); + gluTessEndContour(tobj); + gluTessBeginContour(tobj); + for (i = 8; i < 12; i++) + gluTessVertex(tobj, rects[i], rects[i]); + gluTessEndContour(tobj); + gluTessEndPolygon(tobj); + glEndList(); + + glNewList(list+1, GL_COMPILE); + gluTessBeginPolygon(tobj, NULL); + gluTessBeginContour(tobj); + for (i = 0; i < 4; i++) + gluTessVertex(tobj, rects[i], rects[i]); + gluTessEndContour(tobj); + gluTessBeginContour(tobj); + for (i = 7; i >= 4; i--) + gluTessVertex(tobj, rects[i], rects[i]); + gluTessEndContour(tobj); + gluTessBeginContour(tobj); + for (i = 11; i >= 8; i--) + gluTessVertex(tobj, rects[i], rects[i]); + gluTessEndContour(tobj); + gluTessEndPolygon(tobj); + glEndList(); + + glNewList(list+2, GL_COMPILE); + gluTessBeginPolygon(tobj, NULL); + gluTessBeginContour(tobj); + for (i = 0; i < 16; i++) + gluTessVertex(tobj, spiral[i], spiral[i]); + gluTessEndContour(tobj); + gluTessEndPolygon(tobj); + glEndList(); + + glNewList(list+3, GL_COMPILE); + gluTessBeginPolygon(tobj, NULL); + gluTessBeginContour(tobj); + for (i = 0; i < 4; i++) + gluTessVertex(tobj, quad1[i], quad1[i]); + gluTessEndContour(tobj); + gluTessBeginContour(tobj); + for (i = 0; i < 4; i++) + gluTessVertex(tobj, quad2[i], quad2[i]); + gluTessEndContour(tobj); + gluTessBeginContour(tobj); + for (i = 0; i < 3; i++) + gluTessVertex(tobj, tri[i], tri[i]); + gluTessEndContour(tobj); + gluTessEndPolygon(tobj); + glEndList(); +} + +void display (void) { + glClear(GL_COLOR_BUFFER_BIT); + glColor3f(1.0, 1.0, 1.0); + glPushMatrix(); + glCallList(list); + glTranslatef(0.0, 500.0, 0.0); + glCallList(list+1); + glTranslatef(500.0, -500.0, 0.0); + glCallList(list+2); + glTranslatef(0.0, 500.0, 0.0); + glCallList(list+3); + glPopMatrix(); + glFlush(); +} + +void CALLBACK beginCallback(GLenum which) +{ + glBegin(which); +} + +void CALLBACK errorCallback(GLenum errorCode) +{ + const GLubyte *estring; + + estring = gluErrorString(errorCode); + fprintf(stderr, "Tessellation Error: %s\n", (char *) estring); + exit(0); +} + +void CALLBACK endCallback(void) +{ + glEnd(); +} + +/* combineCallback is used to create a new vertex when edges + * intersect. coordinate location is trivial to calculate, + * but weight[4] may be used to average color, normal, or texture + * coordinate data. + */ +/* ARGSUSED */ +void CALLBACK combineCallback(GLdouble coords[3], GLdouble *data[4], + GLfloat weight[4], GLdouble **dataOut ) +{ + GLdouble *vertex; + vertex = (GLdouble *) malloc(3 * sizeof(GLdouble)); + + vertex[0] = coords[0]; + vertex[1] = coords[1]; + vertex[2] = coords[2]; + *dataOut = vertex; +} + +void init(void) +{ + glClearColor(0.0, 0.0, 0.0, 0.0); + glShadeModel(GL_FLAT); + + tobj = gluNewTess(); + gluTessCallback(tobj, GLU_TESS_VERTEX, + (GLvoid (CALLBACK*) ()) &glVertex3dv); + gluTessCallback(tobj, GLU_TESS_BEGIN, + (GLvoid (CALLBACK*) ()) &beginCallback); + gluTessCallback(tobj, GLU_TESS_END, + (GLvoid (CALLBACK*) ()) &endCallback); + gluTessCallback(tobj, GLU_TESS_ERROR, + (GLvoid (CALLBACK*) ()) &errorCallback); + gluTessCallback(tobj, GLU_TESS_COMBINE, + (GLvoid (CALLBACK*) ()) &combineCallback); + + list = glGenLists(4); + makeNewLists(); +} + +void reshape(int w, int h) +{ + glViewport(0, 0, (GLsizei) w, (GLsizei) h); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + if (w <= h) + gluOrtho2D(0.0, 1000.0, 0.0, 1000.0 * (GLdouble)h/(GLdouble)w); + else + gluOrtho2D(0.0, 1000.0 * (GLdouble)w/(GLdouble)h, 0.0, 1000.0); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); +} + +/* ARGSUSED1 */ +void keyboard(unsigned char key, int x, int y) +{ + switch (key) { + case 'w': + case 'W': + if (currentWinding == GLU_TESS_WINDING_ODD) + currentWinding = GLU_TESS_WINDING_NONZERO; + else if (currentWinding == GLU_TESS_WINDING_NONZERO) + currentWinding = GLU_TESS_WINDING_POSITIVE; + else if (currentWinding == GLU_TESS_WINDING_POSITIVE) + currentWinding = GLU_TESS_WINDING_NEGATIVE; + else if (currentWinding == GLU_TESS_WINDING_NEGATIVE) + currentWinding = GLU_TESS_WINDING_ABS_GEQ_TWO; + else if (currentWinding == GLU_TESS_WINDING_ABS_GEQ_TWO) + currentWinding = GLU_TESS_WINDING_ODD; + makeNewLists(); + glutPostRedisplay(); + break; + case 27: + exit(0); + break; + default: + break; + } +} + +int main(int argc, char** argv) +{ + glutInit(&argc, argv); + glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); + glutInitWindowSize(500, 500); + glutCreateWindow(argv[0]); + init(); + glutDisplayFunc(display); + glutReshapeFunc(reshape); + glutKeyboardFunc(keyboard); + glutMainLoop(); + return 0; +} + +#else +int main(int argc, char** argv) +{ + fprintf (stderr, "This program demonstrates the new tesselator API in GLU 1.2.\n"); + fprintf (stderr, "Your GLU library does not support this new interface, sorry.\n"); + return 0; +} +#endif diff --git a/progs/redbook/texbind.c b/progs/redbook/texbind.c new file mode 100644 index 00000000000..6a828ab2bdf --- /dev/null +++ b/progs/redbook/texbind.c @@ -0,0 +1,171 @@ +/* + * Copyright (c) 1993-1997, 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(R) is a registered trademark of Silicon Graphics, Inc. + */ + +/* texbind.c + * This program demonstrates using glBindTexture() by + * creating and managing two textures. + */ +#include +#include +#include + +#ifdef GL_VERSION_1_1 +/* Create checkerboard texture */ +#define checkImageWidth 64 +#define checkImageHeight 64 +static GLubyte checkImage[checkImageHeight][checkImageWidth][4]; +static GLubyte otherImage[checkImageHeight][checkImageWidth][4]; + +static GLuint texName[2]; + +void makeCheckImages(void) +{ + int i, j, c; + + for (i = 0; i < checkImageHeight; i++) { + for (j = 0; j < checkImageWidth; j++) { + c = ((((i&0x8)==0)^((j&0x8)==0)))*255; + checkImage[i][j][0] = (GLubyte) c; + checkImage[i][j][1] = (GLubyte) c; + checkImage[i][j][2] = (GLubyte) c; + checkImage[i][j][3] = (GLubyte) 255; + c = ((((i&0x10)==0)^((j&0x10)==0)))*255; + otherImage[i][j][0] = (GLubyte) c; + otherImage[i][j][1] = (GLubyte) 0; + otherImage[i][j][2] = (GLubyte) 0; + otherImage[i][j][3] = (GLubyte) 255; + } + } +} + +void init(void) +{ + glClearColor (0.0, 0.0, 0.0, 0.0); + glShadeModel(GL_FLAT); + glEnable(GL_DEPTH_TEST); + + makeCheckImages(); + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + + glGenTextures(2, texName); + glBindTexture(GL_TEXTURE_2D, texName[0]); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, + GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, + GL_NEAREST); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, checkImageWidth, + checkImageHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, + checkImage); + + glBindTexture(GL_TEXTURE_2D, texName[1]); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, checkImageWidth, + checkImageHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, + otherImage); + glEnable(GL_TEXTURE_2D); +} + +void display(void) +{ + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glBindTexture(GL_TEXTURE_2D, texName[0]); + glBegin(GL_QUADS); + glTexCoord2f(0.0, 0.0); glVertex3f(-2.0, -1.0, 0.0); + glTexCoord2f(0.0, 1.0); glVertex3f(-2.0, 1.0, 0.0); + glTexCoord2f(1.0, 1.0); glVertex3f(0.0, 1.0, 0.0); + glTexCoord2f(1.0, 0.0); glVertex3f(0.0, -1.0, 0.0); + glEnd(); + glBindTexture(GL_TEXTURE_2D, texName[1]); + glBegin(GL_QUADS); + glTexCoord2f(0.0, 0.0); glVertex3f(1.0, -1.0, 0.0); + glTexCoord2f(0.0, 1.0); glVertex3f(1.0, 1.0, 0.0); + glTexCoord2f(1.0, 1.0); glVertex3f(2.41421, 1.0, -1.41421); + glTexCoord2f(1.0, 0.0); glVertex3f(2.41421, -1.0, -1.41421); + glEnd(); + glFlush(); +} + +void reshape(int w, int h) +{ + glViewport(0, 0, (GLsizei) w, (GLsizei) h); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluPerspective(60.0, (GLfloat) w/(GLfloat) h, 1.0, 30.0); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTranslatef(0.0, 0.0, -3.6); +} + +/* ARGSUSED1 */ +void keyboard(unsigned char key, int x, int y) +{ + switch (key) { + case 27: + exit(0); + break; + } +} + +int main(int argc, char** argv) +{ + glutInit(&argc, argv); + glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH); + glutInitWindowSize(250, 250); + glutInitWindowPosition(100, 100); + glutCreateWindow(argv[0]); + init(); + glutReshapeFunc(reshape); + glutDisplayFunc(display); + glutKeyboardFunc (keyboard); + glutMainLoop(); + return 0; +} +#else +int main(int argc, char** argv) +{ + fprintf (stderr, "This program demonstrates a feature which is not in OpenGL Version 1.0.\n"); + fprintf (stderr, "If your implementation of OpenGL Version 1.0 has the right extensions,\n"); + fprintf (stderr, "you may be able to modify this program to make it run.\n"); + return 0; +} +#endif diff --git a/progs/redbook/texgen.c b/progs/redbook/texgen.c new file mode 100644 index 00000000000..7c1802a3be9 --- /dev/null +++ b/progs/redbook/texgen.c @@ -0,0 +1,207 @@ +/* + * Copyright (c) 1993-1997, 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(R) is a registered trademark of Silicon Graphics, Inc. + */ + +/* texgen.c + * This program draws a texture mapped teapot with + * automatically generated texture coordinates. The + * texture is rendered as stripes on the teapot. + * Initially, the object is drawn with texture coordinates + * based upon the object coordinates of the vertex + * and distance from the plane x = 0. Pressing the 'e' + * key changes the coordinate generation to eye coordinates + * of the vertex. Pressing the 'o' key switches it back + * to the object coordinates. Pressing the 's' key + * changes the plane to a slanted one (x + y + z = 0). + * Pressing the 'x' key switches it back to x = 0. + */ + +#include +#include +#include + +#define stripeImageWidth 32 +GLubyte stripeImage[4*stripeImageWidth]; + +#ifdef GL_VERSION_1_1 +static GLuint texName; +#endif + +void makeStripeImage(void) +{ + int j; + + for (j = 0; j < stripeImageWidth; j++) { + stripeImage[4*j] = (GLubyte) ((j<=4) ? 255 : 0); + stripeImage[4*j+1] = (GLubyte) ((j>4) ? 255 : 0); + stripeImage[4*j+2] = (GLubyte) 0; + stripeImage[4*j+3] = (GLubyte) 255; + } +} + +/* planes for texture coordinate generation */ +static GLfloat xequalzero[] = {1.0, 0.0, 0.0, 0.0}; +static GLfloat slanted[] = {1.0, 1.0, 1.0, 0.0}; +static GLfloat *currentCoeff; +static GLenum currentPlane; +static GLint currentGenMode; + +void init(void) +{ + glClearColor (0.0, 0.0, 0.0, 0.0); + glEnable(GL_DEPTH_TEST); + glShadeModel(GL_SMOOTH); + + makeStripeImage(); + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + +#ifdef GL_VERSION_1_1 + glGenTextures(1, &texName); + glBindTexture(GL_TEXTURE_1D, texName); +#endif + glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, GL_REPEAT); + glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); +#ifdef GL_VERSION_1_1 + glTexImage1D(GL_TEXTURE_1D, 0, GL_RGBA, stripeImageWidth, 0, + GL_RGBA, GL_UNSIGNED_BYTE, stripeImage); +#else + glTexImage1D(GL_TEXTURE_1D, 0, 4, stripeImageWidth, 0, + GL_RGBA, GL_UNSIGNED_BYTE, stripeImage); +#endif + + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + currentCoeff = xequalzero; + currentGenMode = GL_OBJECT_LINEAR; + currentPlane = GL_OBJECT_PLANE; + glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, currentGenMode); + glTexGenfv(GL_S, currentPlane, currentCoeff); + + glEnable(GL_TEXTURE_GEN_S); + glEnable(GL_TEXTURE_1D); + glEnable(GL_CULL_FACE); + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + glEnable(GL_AUTO_NORMAL); + glEnable(GL_NORMALIZE); + glFrontFace(GL_CW); + glCullFace(GL_BACK); + glMaterialf (GL_FRONT, GL_SHININESS, 64.0); +} + +void display(void) +{ + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + glPushMatrix (); + glRotatef(45.0, 0.0, 0.0, 1.0); +#ifdef GL_VERSION_1_1 + glBindTexture(GL_TEXTURE_1D, texName); +#endif + glutSolidTeapot(2.0); + glPopMatrix (); + glFlush(); +} + +void reshape(int w, int h) +{ + glViewport(0, 0, (GLsizei) w, (GLsizei) h); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + if (w <= h) + glOrtho (-3.5, 3.5, -3.5*(GLfloat)h/(GLfloat)w, + 3.5*(GLfloat)h/(GLfloat)w, -3.5, 3.5); + else + glOrtho (-3.5*(GLfloat)w/(GLfloat)h, + 3.5*(GLfloat)w/(GLfloat)h, -3.5, 3.5, -3.5, 3.5); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); +} + +/* ARGSUSED1 */ +void keyboard (unsigned char key, int x, int y) +{ + switch (key) { + case 'e': + case 'E': + currentGenMode = GL_EYE_LINEAR; + currentPlane = GL_EYE_PLANE; + glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, currentGenMode); + glTexGenfv(GL_S, currentPlane, currentCoeff); + glutPostRedisplay(); + break; + case 'o': + case 'O': + currentGenMode = GL_OBJECT_LINEAR; + currentPlane = GL_OBJECT_PLANE; + glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, currentGenMode); + glTexGenfv(GL_S, currentPlane, currentCoeff); + glutPostRedisplay(); + break; + case 's': + case 'S': + currentCoeff = slanted; + glTexGenfv(GL_S, currentPlane, currentCoeff); + glutPostRedisplay(); + break; + case 'x': + case 'X': + currentCoeff = xequalzero; + glTexGenfv(GL_S, currentPlane, currentCoeff); + glutPostRedisplay(); + break; + case 27: + exit(0); + break; + default: + break; + } +} + +int main(int argc, char** argv) +{ + glutInit(&argc, argv); + glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH); + glutInitWindowSize(256, 256); + glutInitWindowPosition(100, 100); + glutCreateWindow (argv[0]); + init (); + glutDisplayFunc(display); + glutReshapeFunc(reshape); + glutKeyboardFunc(keyboard); + glutMainLoop(); + return 0; +} diff --git a/progs/redbook/texprox.c b/progs/redbook/texprox.c new file mode 100644 index 00000000000..6f1e853facd --- /dev/null +++ b/progs/redbook/texprox.c @@ -0,0 +1,120 @@ +/* + * Copyright (c) 1993-1997, 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(R) is a registered trademark of Silicon Graphics, Inc. + */ + +/* + * texprox.c + * The brief program illustrates use of texture proxies. + * This program only prints out some messages about whether + * certain size textures are supported and then exits. + */ +#include +#include +#include + +#ifdef GL_VERSION_1_1 + +/* Microsoft OpenGL 1.1's forgets to define + GL_TEXTURE_INTERNAL_FORMAT. */ +#ifndef GL_TEXTURE_INTERNAL_FORMAT +#define GL_TEXTURE_INTERNAL_FORMAT GL_TEXTURE_COMPONENTS +#endif + +void init(void) +{ + GLint proxyComponents; + + putchar('\n'); + + glTexImage2D(GL_PROXY_TEXTURE_2D, 0, GL_RGBA8, + 64, 64, 0, + GL_RGBA, GL_UNSIGNED_BYTE, NULL); + glGetTexLevelParameteriv(GL_PROXY_TEXTURE_2D, 0, + GL_TEXTURE_INTERNAL_FORMAT, &proxyComponents); + printf ("Proxying 64x64 level 0 RGBA8 texture (level 0)\n"); + if (proxyComponents == GL_RGBA8) + printf ("proxy allocation succeeded\n"); + else + printf ("proxy allocation failed\n"); + putchar('\n'); + + glTexImage2D(GL_PROXY_TEXTURE_2D, 0, GL_RGBA16, + 2048, 2048, 0, + GL_RGBA, GL_UNSIGNED_SHORT, NULL); + glGetTexLevelParameteriv(GL_PROXY_TEXTURE_2D, 0, + GL_TEXTURE_INTERNAL_FORMAT, &proxyComponents); + printf ("Proxying 2048x2048 level 0 RGBA16 texture (big so unlikely to be supported)\n"); + if (proxyComponents == GL_RGBA16) + printf ("proxy allocation succeeded\n"); + else + printf ("proxy allocation failed\n"); + putchar('\n'); +} + +void display(void) +{ + exit(0); +} + +void reshape (int w, int h) +{ + glViewport (0, 0, (GLsizei) w, (GLsizei) h); + glMatrixMode (GL_PROJECTION); + glLoadIdentity (); +} + +int main(int argc, char** argv) +{ + glutInit(&argc, argv); + glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); + glutInitWindowSize (500, 500); + glutInitWindowPosition (100, 100); + glutCreateWindow (argv[0]); + init (); + glutDisplayFunc(display); + glutReshapeFunc(reshape); + glutMainLoop(); + return 0; +} +#else +int main(int argc, char** argv) +{ + fprintf (stderr, "This program demonstrates a feature which is not in OpenGL Version 1.0.\n"); + fprintf (stderr, "If your implementation of OpenGL Version 1.0 has the right extensions,\n"); + fprintf (stderr, "you may be able to modify this program to make it run.\n"); + return 0; +} +#endif diff --git a/progs/redbook/texsub.c b/progs/redbook/texsub.c new file mode 100644 index 00000000000..4e829675aba --- /dev/null +++ b/progs/redbook/texsub.c @@ -0,0 +1,187 @@ +/* + * Copyright (c) 1993-1997, 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(R) is a registered trademark of Silicon Graphics, Inc. + */ + +/* texsub.c + * This program texture maps a checkerboard image onto + * two rectangles. This program clamps the texture, if + * the texture coordinates fall outside 0.0 and 1.0. + * If the s key is pressed, a texture subimage is used to + * alter the original texture. If the r key is pressed, + * the original texture is restored. + */ +#include +#include +#include + +#ifdef GL_VERSION_1_1 +/* Create checkerboard textures */ +#define checkImageWidth 64 +#define checkImageHeight 64 +#define subImageWidth 16 +#define subImageHeight 16 +static GLubyte checkImage[checkImageHeight][checkImageWidth][4]; +static GLubyte subImage[subImageHeight][subImageWidth][4]; + +static GLuint texName; + +void makeCheckImages(void) +{ + int i, j, c; + + for (i = 0; i < checkImageHeight; i++) { + for (j = 0; j < checkImageWidth; j++) { + c = ((((i&0x8)==0)^((j&0x8)==0)))*255; + checkImage[i][j][0] = (GLubyte) c; + checkImage[i][j][1] = (GLubyte) c; + checkImage[i][j][2] = (GLubyte) c; + checkImage[i][j][3] = (GLubyte) 255; + } + } + for (i = 0; i < subImageHeight; i++) { + for (j = 0; j < subImageWidth; j++) { + c = ((((i&0x4)==0)^((j&0x4)==0)))*255; + subImage[i][j][0] = (GLubyte) c; + subImage[i][j][1] = (GLubyte) 0; + subImage[i][j][2] = (GLubyte) 0; + subImage[i][j][3] = (GLubyte) 255; + } + } +} + +void init(void) +{ + glClearColor (0.0, 0.0, 0.0, 0.0); + glShadeModel(GL_FLAT); + glEnable(GL_DEPTH_TEST); + + makeCheckImages(); + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + + glGenTextures(1, &texName); + glBindTexture(GL_TEXTURE_2D, texName); + + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, checkImageWidth, checkImageHeight, + 0, GL_RGBA, GL_UNSIGNED_BYTE, checkImage); +} + +void display(void) +{ + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glEnable(GL_TEXTURE_2D); + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); + glBindTexture(GL_TEXTURE_2D, texName); + glBegin(GL_QUADS); + glTexCoord2f(0.0, 0.0); glVertex3f(-2.0, -1.0, 0.0); + glTexCoord2f(0.0, 1.0); glVertex3f(-2.0, 1.0, 0.0); + glTexCoord2f(1.0, 1.0); glVertex3f(0.0, 1.0, 0.0); + glTexCoord2f(1.0, 0.0); glVertex3f(0.0, -1.0, 0.0); + + glTexCoord2f(0.0, 0.0); glVertex3f(1.0, -1.0, 0.0); + glTexCoord2f(0.0, 1.0); glVertex3f(1.0, 1.0, 0.0); + glTexCoord2f(1.0, 1.0); glVertex3f(2.41421, 1.0, -1.41421); + glTexCoord2f(1.0, 0.0); glVertex3f(2.41421, -1.0, -1.41421); + glEnd(); + glFlush(); + glDisable(GL_TEXTURE_2D); +} + +void reshape(int w, int h) +{ + glViewport(0, 0, (GLsizei) w, (GLsizei) h); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluPerspective(60.0, (GLfloat) w/(GLfloat) h, 1.0, 30.0); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTranslatef(0.0, 0.0, -3.6); +} + +/* ARGSUSED1 */ +void keyboard (unsigned char key, int x, int y) +{ + switch (key) { + case 's': + case 'S': + glBindTexture(GL_TEXTURE_2D, texName); + glTexSubImage2D(GL_TEXTURE_2D, 0, 12, 44, subImageWidth, + subImageHeight, GL_RGBA, + GL_UNSIGNED_BYTE, subImage); + glutPostRedisplay(); + break; + case 'r': + case 'R': + glBindTexture(GL_TEXTURE_2D, texName); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, checkImageWidth, + checkImageHeight, 0, GL_RGBA, + GL_UNSIGNED_BYTE, checkImage); + glutPostRedisplay(); + break; + case 27: + exit(0); + break; + default: + break; + } +} + +int main(int argc, char** argv) +{ + glutInit(&argc, argv); + glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH); + glutInitWindowSize(250, 250); + glutInitWindowPosition(100, 100); + glutCreateWindow(argv[0]); + init(); + glutDisplayFunc(display); + glutReshapeFunc(reshape); + glutKeyboardFunc(keyboard); + glutMainLoop(); + return 0; +} +#else +int main(int argc, char** argv) +{ + fprintf (stderr, "This program demonstrates a feature which is not in OpenGL Version 1.0.\n"); + fprintf (stderr, "If your implementation of OpenGL Version 1.0 has the right extensions,\n"); + fprintf (stderr, "you may be able to modify this program to make it run.\n"); + return 0; +} +#endif diff --git a/progs/redbook/texturesurf.c b/progs/redbook/texturesurf.c new file mode 100644 index 00000000000..0170070eaa5 --- /dev/null +++ b/progs/redbook/texturesurf.c @@ -0,0 +1,155 @@ + +/* 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. + */ +/* texturesurf.c + * This program uses evaluators to generate a curved + * surface and automatically generated texture coordinates. + */ + +#include +#include +#include + +GLfloat ctrlpoints[4][4][3] = { + {{ -1.5, -1.5, 4.0}, { -0.5, -1.5, 2.0}, + {0.5, -1.5, -1.0}, {1.5, -1.5, 2.0}}, + {{ -1.5, -0.5, 1.0}, { -0.5, -0.5, 3.0}, + {0.5, -0.5, 0.0}, {1.5, -0.5, -1.0}}, + {{ -1.5, 0.5, 4.0}, { -0.5, 0.5, 0.0}, + {0.5, 0.5, 3.0}, {1.5, 0.5, 4.0}}, + {{ -1.5, 1.5, -2.0}, { -0.5, 1.5, -2.0}, + {0.5, 1.5, 0.0}, {1.5, 1.5, -1.0}} +}; + +GLfloat texpts[2][2][2] = {{{0.0, 0.0}, {0.0, 1.0}}, + {{1.0, 0.0}, {1.0, 1.0}}}; + +void display(void) +{ + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glColor3f(1.0, 1.0, 1.0); + glEvalMesh2(GL_FILL, 0, 20, 0, 20); + glFlush(); +} + +#define imageWidth 64 +#define imageHeight 64 +GLubyte image[3*imageWidth*imageHeight]; + +void makeImage(void) +{ + int i, j; + float ti, tj; + + for (i = 0; i < imageWidth; i++) { + ti = 2.0*3.14159265*i/imageWidth; + for (j = 0; j < imageHeight; j++) { + tj = 2.0*3.14159265*j/imageHeight; + + image[3*(imageHeight*i+j)] = (GLubyte) 127*(1.0+sin(ti)); + image[3*(imageHeight*i+j)+1] = (GLubyte) 127*(1.0+cos(2*tj)); + image[3*(imageHeight*i+j)+2] = (GLubyte) 127*(1.0+cos(ti+tj)); + } + } +} + +void myinit(void) +{ + glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4, + 0, 1, 12, 4, &ctrlpoints[0][0][0]); + glMap2f(GL_MAP2_TEXTURE_COORD_2, 0, 1, 2, 2, + 0, 1, 4, 2, &texpts[0][0][0]); + glEnable(GL_MAP2_TEXTURE_COORD_2); + glEnable(GL_MAP2_VERTEX_3); + glMapGrid2f(20, 0.0, 1.0, 20, 0.0, 1.0); + makeImage(); + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); + 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_MAG_FILTER, GL_NEAREST); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexImage2D(GL_TEXTURE_2D, 0, 3, imageWidth, imageHeight, 0, + GL_RGB, GL_UNSIGNED_BYTE, image); + glEnable(GL_TEXTURE_2D); + glEnable(GL_DEPTH_TEST); + glEnable(GL_NORMALIZE); + glShadeModel (GL_FLAT); +} + +void myReshape(int w, int h) +{ + glViewport(0, 0, w, h); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + if (w <= h) + glOrtho(-4.0, 4.0, -4.0*(GLfloat)h/(GLfloat)w, + 4.0*(GLfloat)h/(GLfloat)w, -4.0, 4.0); + else + glOrtho(-4.0*(GLfloat)w/(GLfloat)h, + 4.0*(GLfloat)w/(GLfloat)h, -4.0, 4.0, -4.0, 4.0); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glRotatef(85.0, 1.0, 1.0, 1.0); +} + +static void +key(unsigned char k, int x, int y) +{ + switch (k) { + case 27: /* Escape */ + exit(0); + break; + default: + return; + } + glutPostRedisplay(); +} + +int main(int argc, char** argv) +{ + glutInit(&argc, argv); + glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH); + glutCreateWindow (argv[0]); + myinit(); + glutReshapeFunc (myReshape); + glutDisplayFunc(display); + glutKeyboardFunc(key); + glutMainLoop(); + return 0; /* ANSI C requires main to return int. */ +} diff --git a/progs/redbook/torus.c b/progs/redbook/torus.c new file mode 100644 index 00000000000..7ae4d41e263 --- /dev/null +++ b/progs/redbook/torus.c @@ -0,0 +1,152 @@ +/* + * Copyright (c) 1993-1997, 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(R) is a registered trademark of Silicon Graphics, Inc. + */ + +/* + * torus.c + * This program demonstrates the creation of a display list. + */ + +#include +#include +#include +#include + +/* Some files do not define M_PI... */ +#ifndef M_PI +#define M_PI 3.14159265358979323846 +#endif + +GLuint theTorus; + +/* Draw a torus */ +static void torus(int numc, int numt) +{ + int i, j, k; + double s, t, x, y, z, twopi; + + twopi = 2 * (double)M_PI; + for (i = 0; i < numc; i++) { + glBegin(GL_QUAD_STRIP); + for (j = 0; j <= numt; j++) { + for (k = 1; k >= 0; k--) { + s = (i + k) % numc + 0.5; + t = j % numt; + + x = (1+.1*cos(s*twopi/numc))*cos(t*twopi/numt); + y = (1+.1*cos(s*twopi/numc))*sin(t*twopi/numt); + z = .1 * sin(s * twopi / numc); + glVertex3f(x, y, z); + } + } + glEnd(); + } +} + +/* Create display list with Torus and initialize state */ +static void init(void) +{ + theTorus = glGenLists (1); + glNewList(theTorus, GL_COMPILE); + torus(8, 25); + glEndList(); + + glShadeModel(GL_FLAT); + glClearColor(0.0, 0.0, 0.0, 0.0); +} + +/* Clear window and draw torus */ +void display(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + glColor3f (1.0, 1.0, 1.0); + glCallList(theTorus); + glFlush(); +} + +/* Handle window resize */ +void reshape(int w, int h) +{ + glViewport(0, 0, (GLsizei) w, (GLsizei) h); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluPerspective(30, (GLfloat) w/(GLfloat) h, 1.0, 100.0); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + gluLookAt(0, 0, 10, 0, 0, 0, 0, 1, 0); +} + +/* Rotate about x-axis when "x" typed; rotate about y-axis + when "y" typed; "i" returns torus to original view */ +/* ARGSUSED1 */ +void keyboard(unsigned char key, int x, int y) +{ + switch (key) { + case 'x': + case 'X': + glRotatef(30.,1.0,0.0,0.0); + glutPostRedisplay(); + break; + case 'y': + case 'Y': + glRotatef(30.,0.0,1.0,0.0); + glutPostRedisplay(); + break; + case 'i': + case 'I': + glLoadIdentity(); + gluLookAt(0, 0, 10, 0, 0, 0, 0, 1, 0); + glutPostRedisplay(); + break; + case 27: + exit(0); + break; + } +} + +int main(int argc, char **argv) +{ + glutInitWindowSize(200, 200); + glutInit(&argc, argv); + glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); + glutCreateWindow(argv[0]); + init(); + glutReshapeFunc(reshape); + glutKeyboardFunc(keyboard); + glutDisplayFunc(display); + glutMainLoop(); + return 0; +} diff --git a/progs/redbook/trim.c b/progs/redbook/trim.c new file mode 100644 index 00000000000..f17674f6840 --- /dev/null +++ b/progs/redbook/trim.c @@ -0,0 +1,187 @@ +/* + * Copyright (c) 1993-1997, 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(R) is a registered trademark of Silicon Graphics, Inc. + */ + +/* + * trim.c + * This program draws a NURBS surface in the shape of a + * symmetrical hill, using both a NURBS curve and pwl + * (piecewise linear) curve to trim part of the surface. + */ +#include +#include +#include + + +#ifndef CALLBACK +#define CALLBACK +#endif + + +GLfloat ctlpoints[4][4][3]; + +GLUnurbsObj *theNurb; + +/* + * Initializes the control points of the surface to a small hill. + * The control points range from -3 to +3 in x, y, and z + */ +void init_surface(void) +{ + int u, v; + for (u = 0; u < 4; u++) { + for (v = 0; v < 4; v++) { + ctlpoints[u][v][0] = 2.0*((GLfloat)u - 1.5); + ctlpoints[u][v][1] = 2.0*((GLfloat)v - 1.5); + + if ( (u == 1 || u == 2) && (v == 1 || v == 2)) + ctlpoints[u][v][2] = 3.0; + else + ctlpoints[u][v][2] = -3.0; + } + } +} + +void nurbsError(GLenum errorCode) +{ + const GLubyte *estring; + + estring = gluErrorString(errorCode); + fprintf (stderr, "Nurbs Error: %s\n", (char *) estring); + exit (0); +} + +/* Initialize material property and depth buffer. + */ +void init(void) +{ + GLfloat mat_diffuse[] = { 0.7, 0.7, 0.7, 1.0 }; + GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 }; + GLfloat mat_shininess[] = { 100.0 }; + + glClearColor (0.0, 0.0, 0.0, 0.0); + glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); + glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); + glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess); + + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + glEnable(GL_DEPTH_TEST); + glEnable(GL_AUTO_NORMAL); + glEnable(GL_NORMALIZE); + + init_surface(); + + theNurb = gluNewNurbsRenderer(); + gluNurbsProperty(theNurb, GLU_SAMPLING_TOLERANCE, 25.0); + gluNurbsProperty(theNurb, GLU_DISPLAY_MODE, GLU_FILL); + gluNurbsCallback(theNurb, GLU_ERROR, + (GLvoid (CALLBACK*) ()) nurbsError); +} + +void display(void) +{ + GLfloat knots[8] = {0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0}; + GLfloat edgePt[5][2] = /* counter clockwise */ + {{0.0, 0.0}, {1.0, 0.0}, {1.0, 1.0}, {0.0, 1.0}, {0.0, 0.0}}; + GLfloat curvePt[4][2] = /* clockwise */ + {{0.25, 0.5}, {0.25, 0.75}, {0.75, 0.75}, {0.75, 0.5}}; + GLfloat curveKnots[8] = + {0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0}; + GLfloat pwlPt[4][2] = /* clockwise */ + {{0.75, 0.5}, {0.5, 0.25}, {0.25, 0.5}}; + + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glPushMatrix(); + glRotatef(330.0, 1.,0.,0.); + glScalef (0.5, 0.5, 0.5); + + gluBeginSurface(theNurb); + gluNurbsSurface(theNurb, 8, knots, 8, knots, + 4 * 3, 3, &ctlpoints[0][0][0], + 4, 4, GL_MAP2_VERTEX_3); + gluBeginTrim (theNurb); + gluPwlCurve (theNurb, 5, &edgePt[0][0], 2, GLU_MAP1_TRIM_2); + gluEndTrim (theNurb); + gluBeginTrim (theNurb); + gluNurbsCurve (theNurb, 8, curveKnots, 2, + &curvePt[0][0], 4, GLU_MAP1_TRIM_2); + gluPwlCurve (theNurb, 3, &pwlPt[0][0], 2, GLU_MAP1_TRIM_2); + gluEndTrim (theNurb); + gluEndSurface(theNurb); + + glPopMatrix(); + glFlush(); +} + +void reshape(int w, int h) +{ + glViewport(0, 0, (GLsizei) w, (GLsizei) h); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluPerspective (45.0, (GLdouble)w/(GLdouble)h, 3.0, 8.0); + + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTranslatef (0.0, 0.0, -5.0); +} + +/* ARGSUSED1 */ +void keyboard(unsigned char key, int x, int y) +{ + switch (key) { + case 27: + exit(0); + break; + } +} + +/* Main Loop + */ +int main(int argc, char** argv) +{ + glutInit(&argc, argv); + glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH); + glutInitWindowSize (500, 500); + glutInitWindowPosition (100, 100); + glutCreateWindow(argv[0]); + init(); + glutReshapeFunc(reshape); + glutDisplayFunc(display); + glutKeyboardFunc (keyboard); + glutMainLoop(); + return 0; +} diff --git a/progs/redbook/unproject.c b/progs/redbook/unproject.c new file mode 100644 index 00000000000..134c361bac5 --- /dev/null +++ b/progs/redbook/unproject.c @@ -0,0 +1,126 @@ +/* + * Copyright (c) 1993-1997, 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(R) is a registered trademark of Silicon Graphics, Inc. + */ + +/* + * unproject.c + * When the left mouse button is pressed, this program + * reads the mouse position and determines two 3D points + * from which it was transformed. Very little is displayed. + */ +#include +#include +#include + +void display(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + glFlush(); +} + +/* Change these values for a different transformation */ +void reshape(int w, int h) +{ + glViewport (0, 0, (GLsizei) w, (GLsizei) h); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluPerspective (45.0, (GLfloat) w/(GLfloat) h, 1.0, 100.0); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); +} + +void mouse(int button, int state, int x, int y) +{ + GLint viewport[4]; + GLdouble mvmatrix[16], projmatrix[16]; + GLint realy; /* OpenGL y coordinate position */ + GLdouble wx, wy, wz; /* returned world x, y, z coords */ + + switch (button) { + case GLUT_LEFT_BUTTON: + if (state == GLUT_DOWN) { + glGetIntegerv (GL_VIEWPORT, viewport); + glGetDoublev (GL_MODELVIEW_MATRIX, mvmatrix); + glGetDoublev (GL_PROJECTION_MATRIX, projmatrix); +/* note viewport[3] is height of window in pixels */ + realy = viewport[3] - (GLint) y - 1; + printf ("Coordinates at cursor are (%4d, %4d)\n", x, realy); + gluUnProject ((GLdouble) x, (GLdouble) realy, 0.0, + mvmatrix, projmatrix, viewport, &wx, &wy, &wz); + printf ("World coords at z=0.0 are (%f, %f, %f)\n", + wx, wy, wz); + gluUnProject ((GLdouble) x, (GLdouble) realy, 1.0, + mvmatrix, projmatrix, viewport, &wx, &wy, &wz); + printf ("World coords at z=1.0 are (%f, %f, %f)\n", + wx, wy, wz); + } + break; + case GLUT_RIGHT_BUTTON: + if (state == GLUT_DOWN) + exit(0); + break; + default: + break; + } +} + +/* ARGSUSED1 */ +void keyboard(unsigned char key, int x, int y) +{ + switch (key) { + case 27: + exit(0); + break; + } +} + +/* + * Open window, register input callback functions + */ +int main(int argc, char** argv) +{ + glutInit(&argc, argv); + glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); + glutInitWindowSize (500, 500); + glutInitWindowPosition (100, 100); + glutCreateWindow (argv[0]); + glutDisplayFunc(display); + glutReshapeFunc(reshape); + glutKeyboardFunc (keyboard); + glutMouseFunc(mouse); + glutMainLoop(); + return 0; +} diff --git a/progs/redbook/varray.c b/progs/redbook/varray.c new file mode 100644 index 00000000000..b22e723e0ec --- /dev/null +++ b/progs/redbook/varray.c @@ -0,0 +1,195 @@ +/* + * Copyright (c) 1993-1997, 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(R) is a registered trademark of Silicon Graphics, Inc. + */ + +/* + * varray.c + * This program demonstrates vertex arrays. + */ +#include +#include +#include + +#ifdef GL_VERSION_1_1 +#define POINTER 1 +#define INTERLEAVED 2 + +#define DRAWARRAY 1 +#define ARRAYELEMENT 2 +#define DRAWELEMENTS 3 + +int setupMethod = POINTER; +int derefMethod = DRAWARRAY; + +void setupPointers(void) +{ + static GLint vertices[] = {25, 25, + 100, 325, + 175, 25, + 175, 325, + 250, 25, + 325, 325}; + static GLfloat colors[] = {1.0, 0.2, 0.2, + 0.2, 0.2, 1.0, + 0.8, 1.0, 0.2, + 0.75, 0.75, 0.75, + 0.35, 0.35, 0.35, + 0.5, 0.5, 0.5}; + + glEnableClientState (GL_VERTEX_ARRAY); + glEnableClientState (GL_COLOR_ARRAY); + + glVertexPointer (2, GL_INT, 0, vertices); + glColorPointer (3, GL_FLOAT, 0, colors); +} + +void setupInterleave(void) +{ + static GLfloat intertwined[] = + {1.0, 0.2, 1.0, 100.0, 100.0, 0.0, + 1.0, 0.2, 0.2, 0.0, 200.0, 0.0, + 1.0, 1.0, 0.2, 100.0, 300.0, 0.0, + 0.2, 1.0, 0.2, 200.0, 300.0, 0.0, + 0.2, 1.0, 1.0, 300.0, 200.0, 0.0, + 0.2, 0.2, 1.0, 200.0, 100.0, 0.0}; + + glInterleavedArrays (GL_C3F_V3F, 0, intertwined); +} + +void init(void) +{ + glClearColor (0.0, 0.0, 0.0, 0.0); + glShadeModel (GL_SMOOTH); + setupPointers (); +} + +void display(void) +{ + glClear (GL_COLOR_BUFFER_BIT); + + if (derefMethod == DRAWARRAY) + glDrawArrays (GL_TRIANGLES, 0, 6); + else if (derefMethod == ARRAYELEMENT) { + glBegin (GL_TRIANGLES); + glArrayElement (2); + glArrayElement (3); + glArrayElement (5); + glEnd (); + } + else if (derefMethod == DRAWELEMENTS) { + GLuint indices[4] = {0, 1, 3, 4}; + + glDrawElements (GL_POLYGON, 4, GL_UNSIGNED_INT, indices); + } + glFlush (); +} + +void reshape (int w, int h) +{ + glViewport (0, 0, (GLsizei) w, (GLsizei) h); + glMatrixMode (GL_PROJECTION); + glLoadIdentity (); + gluOrtho2D (0.0, (GLdouble) w, 0.0, (GLdouble) h); +} + +/* ARGSUSED2 */ +void mouse (int button, int state, int x, int y) +{ + switch (button) { + case GLUT_LEFT_BUTTON: + if (state == GLUT_DOWN) { + if (setupMethod == POINTER) { + setupMethod = INTERLEAVED; + setupInterleave(); + } + else if (setupMethod == INTERLEAVED) { + setupMethod = POINTER; + setupPointers(); + } + glutPostRedisplay(); + } + break; + case GLUT_MIDDLE_BUTTON: + case GLUT_RIGHT_BUTTON: + if (state == GLUT_DOWN) { + if (derefMethod == DRAWARRAY) + derefMethod = ARRAYELEMENT; + else if (derefMethod == ARRAYELEMENT) + derefMethod = DRAWELEMENTS; + else if (derefMethod == DRAWELEMENTS) + derefMethod = DRAWARRAY; + glutPostRedisplay(); + } + break; + default: + break; + } +} + +/* ARGSUSED1 */ +void keyboard(unsigned char key, int x, int y) +{ + switch (key) { + case 27: + exit(0); + break; + } +} + +int main(int argc, char** argv) +{ + glutInit(&argc, argv); + glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); + glutInitWindowSize (350, 350); + glutInitWindowPosition (100, 100); + glutCreateWindow (argv[0]); + init (); + glutDisplayFunc(display); + glutReshapeFunc(reshape); + glutMouseFunc(mouse); + glutKeyboardFunc (keyboard); + glutMainLoop(); + return 0; +} +#else +int main(int argc, char** argv) +{ + fprintf (stderr, "This program demonstrates a feature which is not in OpenGL Version 1.0.\n"); + fprintf (stderr, "If your implementation of OpenGL Version 1.0 has the right extensions,\n"); + fprintf (stderr, "you may be able to modify this program to make it run.\n"); + return 0; +} +#endif diff --git a/progs/redbook/wrap.c b/progs/redbook/wrap.c new file mode 100644 index 00000000000..f9a1f162ab6 --- /dev/null +++ b/progs/redbook/wrap.c @@ -0,0 +1,180 @@ +/* + * Copyright (c) 1993-1997, 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(R) is a registered trademark of Silicon Graphics, Inc. + */ + +/* wrap.c + * This program texture maps a checkerboard image onto + * two rectangles. This program demonstrates the wrapping + * modes, if the texture coordinates fall outside 0.0 and 1.0. + * Interaction: Pressing the 's' and 'S' keys switch the + * wrapping between clamping and repeating for the s parameter. + * The 't' and 'T' keys control the wrapping for the t parameter. + * + * If running this program on OpenGL 1.0, texture objects are + * not used. + */ +#include +#include +#include + +/* Create checkerboard texture */ +#define checkImageWidth 64 +#define checkImageHeight 64 +static GLubyte checkImage[checkImageHeight][checkImageWidth][4]; + +#ifdef GL_VERSION_1_1 +static GLuint texName; +#endif + +void makeCheckImage(void) +{ + int i, j, c; + + for (i = 0; i < checkImageHeight; i++) { + for (j = 0; j < checkImageWidth; j++) { + c = (((i&0x8)==0)^((j&0x8)==0))*255; + checkImage[i][j][0] = (GLubyte) c; + checkImage[i][j][1] = (GLubyte) c; + checkImage[i][j][2] = (GLubyte) c; + checkImage[i][j][3] = (GLubyte) 255; + } + } +} + +void init(void) +{ + glClearColor (0.0, 0.0, 0.0, 0.0); + glShadeModel(GL_FLAT); + glEnable(GL_DEPTH_TEST); + + makeCheckImage(); + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + +#ifdef GL_VERSION_1_1 + glGenTextures(1, &texName); + glBindTexture(GL_TEXTURE_2D, texName); +#endif + + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); +#ifdef GL_VERSION_1_1 + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, checkImageWidth, checkImageHeight, + 0, GL_RGBA, GL_UNSIGNED_BYTE, checkImage); +#else + glTexImage2D(GL_TEXTURE_2D, 0, 4, checkImageWidth, checkImageHeight, + 0, GL_RGBA, GL_UNSIGNED_BYTE, checkImage); +#endif +} + +void display(void) +{ + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glEnable(GL_TEXTURE_2D); + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); +#ifdef GL_VERSION_1_1 + glBindTexture(GL_TEXTURE_2D, texName); +#endif + + glBegin(GL_QUADS); + glTexCoord2f(0.0, 0.0); glVertex3f(-2.0, -1.0, 0.0); + glTexCoord2f(0.0, 3.0); glVertex3f(-2.0, 1.0, 0.0); + glTexCoord2f(3.0, 3.0); glVertex3f(0.0, 1.0, 0.0); + glTexCoord2f(3.0, 0.0); glVertex3f(0.0, -1.0, 0.0); + + glTexCoord2f(0.0, 0.0); glVertex3f(1.0, -1.0, 0.0); + glTexCoord2f(0.0, 3.0); glVertex3f(1.0, 1.0, 0.0); + glTexCoord2f(3.0, 3.0); glVertex3f(2.41421, 1.0, -1.41421); + glTexCoord2f(3.0, 0.0); glVertex3f(2.41421, -1.0, -1.41421); + glEnd(); + glFlush(); + glDisable(GL_TEXTURE_2D); +} + +void reshape(int w, int h) +{ + glViewport(0, 0, (GLsizei) w, (GLsizei) h); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluPerspective(60.0, (GLfloat) w/(GLfloat) h, 1.0, 30.0); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTranslatef(0.0, 0.0, -3.6); +} + +/* ARGSUSED1 */ +void keyboard (unsigned char key, int x, int y) +{ + switch (key) { + case 's': + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); + glutPostRedisplay(); + break; + case 'S': + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); + glutPostRedisplay(); + break; + case 't': + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); + glutPostRedisplay(); + break; + case 'T': + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); + glutPostRedisplay(); + break; + case 27: + exit(0); + break; + default: + break; + } +} + +int main(int argc, char** argv) +{ + glutInit(&argc, argv); + glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH); + glutInitWindowSize(250, 250); + glutInitWindowPosition(100, 100); + glutCreateWindow(argv[0]); + init(); + glutDisplayFunc(display); + glutReshapeFunc(reshape); + glutKeyboardFunc(keyboard); + glutMainLoop(); + return 0; +} diff --git a/progs/samples/.cvsignore b/progs/samples/.cvsignore new file mode 100644 index 00000000000..12b0650567b --- /dev/null +++ b/progs/samples/.cvsignore @@ -0,0 +1,45 @@ +.cvsignore +accum +bitmap1 +bitmap2 +blendeq +blendxor +copy +cursor +depth +eval +fog +font +line +logo +nurb +oglinfo +olympic +overlay +point +prim +quad +select +shape +sphere +star +stencil +stretch +texture +tri +wave +bugger +pend +lthreads +lxdemo +lxgears +lxheads +lxinfo +lxpixmap +anywin +ffset +bdemo +binfo +incopy +demo +font diff --git a/progs/samples/Imakefile b/progs/samples/Imakefile new file mode 100644 index 00000000000..948a9783597 --- /dev/null +++ b/progs/samples/Imakefile @@ -0,0 +1,101 @@ +LOCAL_LIBRARIES = $(XLIB) $(TOP)\lib\glut.a $(TOP)\lib\Mesaglu.a $(TOP)\lib\MesaGL.a + +INCLUDES = -I$(TOP)\include + +SRCS = accum.c \ + bitmap1.c \ + bitmap2.c \ + blendeq.c \ + blendxor.c \ + copy.c \ + cursor.c \ + depth.c \ + eval.c \ + fog.c \ + font.c \ + line.c \ + logo.c \ + nurb.c \ + oglinfo.c \ + olympic.c \ + overlay.c \ + point.c \ + prim.c \ + quad.c \ + select.c \ + shape.c \ + speed.c \ + sphere.c \ + star.c \ + stencil.c \ + stretch.c \ + texture.c \ + tri.c \ + wave.c + +PROGRAMS = ProgramTargetName(accum) \ + ProgramTargetName(bitmap1) \ + ProgramTargetName(bitmap2) \ + ProgramTargetName(blendeq) \ + ProgramTargetName(blendxor) \ + ProgramTargetName(copy) \ + ProgramTargetName(cursor) \ + ProgramTargetName(depth) \ + ProgramTargetName(eval) \ + ProgramTargetName(fog) \ + ProgramTargetName(font) \ + ProgramTargetName(line) \ + ProgramTargetName(logo) \ + ProgramTargetName(nurb) \ + ProgramTargetName(oglinfo) \ + ProgramTargetName(olympic) \ + ProgramTargetName(overlay) \ + ProgramTargetName(point) \ + ProgramTargetName(prim) \ + ProgramTargetName(quad) \ + ProgramTargetName(select) \ + ProgramTargetName(shape) \ + ProgramTargetName(speed) \ + ProgramTargetName(sphere) \ + ProgramTargetName(star) \ + ProgramTargetName(stencil) \ + ProgramTargetName(stretch) \ + ProgramTargetName(texture) \ + ProgramTargetName(tri) \ + ProgramTargetName(wave) + +AllTarget($(PROGRAMS)) + +NormalProgramTarget(accum,accum.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(bitmap1,bitmap1.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(bitmap2,bitmap2.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(blendeq,blendeq.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(blendxor,blendxor.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(copy,copy.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(cursor,cursor.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(depth,depth.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(eval,eval.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(fog,fog.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(font,font.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(line,line.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(logo,logo.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(nurb,nurb.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(oglinfo,oglinfo.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(olympic,olympic.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(overlay,overlay.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(point,point.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(prim,prim.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(quad,quad.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(select,select.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(shape,shape.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(speed,speed.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(sphere,sphere.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(star,star.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(stencil,stencil.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(stretch,stretch.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(texture,texture.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(tri,tri.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) +NormalProgramTarget(wave,wave.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter) + +DependTarget() + diff --git a/progs/samples/Makefile b/progs/samples/Makefile new file mode 100644 index 00000000000..f14b7dfc009 --- /dev/null +++ b/progs/samples/Makefile @@ -0,0 +1,48 @@ +# progs/samples/Makefile + +TOP = ../.. +include $(TOP)/configs/current + +INCDIR = $(TOP)/include + +LIB_DEP = $(LIB_DIR)/$(GL_LIB_NAME) $(LIB_DIR)/$(GLU_LIB_NAME) $(LIB_DIR)/$(GLUT_LIB_NAME) + +PROGS = accum bitmap1 bitmap2 blendeq blendxor copy cursor depth eval fog \ + font line logo nurb olympic overlay point prim quad select \ + shape sphere star stencil stretch texture tri wave + + +##### RULES ##### + +.SUFFIXES: +.SUFFIXES: .c + +.c: $(LIB_DEP) + $(CC) -I$(INCDIR) $(CFLAGS) $< $(APP_LIB_DEPS) -o $@ + + +##### TARGETS ##### + +default: $(PROGS) + + +sphere: sphere.o readtex.o + $(CC) -I$(INCDIR) $(CFLAGS) sphere.o readtex.o $(APP_LIB_DEPS) -o $@ + +sphere.o: sphere.c readtex.h + $(CC) -c -I$(INCDIR) $(CFLAGS) sphere.c + +readtex.c: $(TOP)/progs/util/readtex.c + cp $< . + +readtex.h: $(TOP)/progs/util/readtex.h + cp $< . + +readtex.o: readtex.c readtex.h + $(CC) -c -I$(INCDIR) $(CFLAGS) $< -o $@ + + +clean: + -rm -f $(PROGS) + -rm -f *.o *~ + -rm -f readtex.c readtex.h diff --git a/progs/samples/Makefile.DJ b/progs/samples/Makefile.DJ new file mode 100644 index 00000000000..cda4e059418 --- /dev/null +++ b/progs/samples/Makefile.DJ @@ -0,0 +1,85 @@ +# Mesa 3-D graphics library +# Version: 4.0 +# +# 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. + +# DOS/DJGPP samples makefile v1.6 for Mesa +# +# Copyright (C) 2002 - Daniel Borca +# Email : dborca@users.sourceforge.net +# Web : http://www.geocities.com/dborca + + +# +# Available options: +# +# Environment variables: +# GLIDE path to Glide3 SDK; used with FX. +# default = $(TOP)/glide3 +# FX=1 build for 3dfx Glide3. Note that this disables +# compilation of most DMesa code and requires fxMesa. +# As a consequence, you'll need the DJGPP Glide3 +# library to build any application. +# default = no +# DXE=1 use DXE modules (see README.DJ for details). +# default = no +# +# Targets: +# build a specific file +# + + + +.PHONY: all +.SUFFIXES: .c .o .exe +.SECONDARY: ../util/readtex.o ../util/showbuffer.o + +TOP = ../.. +GLIDE ?= $(TOP)/glide3 + +CC = gcc +CFLAGS = -Wall -W -pedantic +CFLAGS += -O2 -ffast-math +CFLAGS += -I$(TOP)/include -I../util +CFLAGS += -DGLUT_IMPORT_LIB +ifeq ($(FX),1) +CFLAGS += -DFX +endif + +LD = gxx +LDFLAGS = -s -L$(TOP)/lib + +ifeq ($(DXE),1) +LDLIBS += -liglut -liglu -ligl +else +LDLIBS = -lglut -lglu -lgl +ifeq ($(FX),1) +LDFLAGS += -L$(GLIDE)/lib +LDLIBS += -lgld3x +endif +endif + +.c.o: + $(CC) -o $@ $(CFLAGS) -c $< +%.exe: ../util/readtex.o ../util/showbuffer.o %.o + $(LD) -o $@ $(LDFLAGS) $^ $(LDLIBS) + +all: + $(error Must specify to build) diff --git a/progs/samples/Makefile.dja b/progs/samples/Makefile.dja new file mode 100644 index 00000000000..b60a11197b6 --- /dev/null +++ b/progs/samples/Makefile.dja @@ -0,0 +1,25 @@ + +# Makefile for sample programs for MS-DOS with DJGPP and ALLEGRO + + + +INCDIR = ../include +LIBDIR = ../lib +include ../common.dja + + _PROGS = accum bitmap1 bitmap2 blendeq blendxor copy cursor depth \ + eval fog font line logo nurb oglinfo olympic overlay point \ + prim quad select shape sphere star stencil stretch texture \ + tri wave + + PROGS = $(_PROGS:=.exe) + + +default: $(PROGS) + +clean: + del *. + +realclean: clean + del *.exe + diff --git a/progs/samples/Makefile.mgw b/progs/samples/Makefile.mgw new file mode 100644 index 00000000000..11935405783 --- /dev/null +++ b/progs/samples/Makefile.mgw @@ -0,0 +1,68 @@ +# Mesa 3-D graphics library +# Version: 4.0 +# +# 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. + +# MinGW samples makefile v1.2 for Mesa +# +# Copyright (C) 2002 - Daniel Borca +# Email : dborca@users.sourceforge.net +# Web : http://www.geocities.com/dborca + + +# +# Available options: +# +# Environment variables: +# +# Targets: +# build a specific file +# + + + +.PHONY: all +.SUFFIXES: .c .o .exe +.SECONDARY: ../util/readtex.o ../util/showbuffer.o + +TOP = ../.. + +CC = mingw32-gcc +CFLAGS = -Wall -W -pedantic +CFLAGS += -O2 -ffast-math +CFLAGS += -I$(TOP)/include -I../util +ifeq ($(FX),1) +CFLAGS += -DFX +endif +CFLAGS += -DGLUT_DISABLE_ATEXIT_HACK -D_STDCALL_SUPPORTED +CFLAGS += -D_WINDEF_ -D_WINGDI_ + +LD = mingw32-g++ +LDFLAGS = -s -L$(TOP)/lib + +LDLIBS = -lglut32 -lglu32 -lopengl32 + +.c.o: + $(CC) -o $@ $(CFLAGS) -c $< +%.exe: ../util/readtex.o ../util/showbuffer.o %.o + $(LD) -o $@ $(LDFLAGS) $^ $(LDLIBS) + +all: + $(error Must specify to build) diff --git a/progs/samples/Makefile.win b/progs/samples/Makefile.win new file mode 100644 index 00000000000..e74568f7c96 --- /dev/null +++ b/progs/samples/Makefile.win @@ -0,0 +1,41 @@ + +# Mesa 3-D graphics library +# Version: 3.5 +# Copyright (C) 1995-2001 Brian Paul + +# Makefile for GLUT-based demo programs for Windows + +!include + +##### MACROS ##### + +TOP = .. +INCDIR = ..\include +LIBDIR = ..\lib + +PROGS = accum bitmap1 bitmap2 blendeq blendxor copy cursor depth eval fog \ + font line logo nurb oglinfo olympic overlay point prim quad select \ + shape sphere star stencil stretch texture tri wave + +SRCS = \ + accum.c \ + bitmap1.c \ + bitmap2.c \ + blendeq.c \ + blendxor.c \ + copy.c \ + cursor.c depth.c eval.c fog.c \ + font.c line.c logo.c nurb.c olympic.c overlay.c point.c prim.c quad.c select.c \ + shape.c sphere.c star.c stencil.c stretch.c texture.c tri.c wave.c + +!include "../mesawin32.mak" + +##### TARGETS ##### + +clean:: + +clobber:: + +$(EXES) : $*.obj + @echo $@ + $(link) -out:$@ $* /LIBPATH:$(LIBDIR) $(LIBS) diff --git a/progs/samples/README b/progs/samples/README new file mode 100644 index 00000000000..853158873c9 --- /dev/null +++ b/progs/samples/README @@ -0,0 +1,520 @@ +/* + * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the name of + * Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF + * ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +accum - Accumulation test. + - RGBA, SB/DB (SB default). + - cmd line options: + -sb Single buffer mode. + -db Double buffer mode. + - keys: + ESC Quit + 1 Use filled polygon mode. + 2 Use outlined polygon mode. + +bitmap1 - Bitmap test. + - RGBA/CI (RGBA default), SB/DB (SB default). + - cmd line options: + -rgb RGBA mode. + -ci Color index mode. + -sb Single buffer mode. + -db Double buffer mode. + - keys: + ESC Quit. + +bitmap2 - Bitmap test. + - RGBA/CI (RGBA default), SB/DB (SB default). + - cmd line options: + -rgb RGBA mode. + -ci Color index mode. + -sb Single buffer mode. + -db Double buffer mode. + - keys: + ESC Quit. + 1 Toggle display list mode. + 2 Toggle color animation mode. + +copy - Pixel copy test. + - RGBA, SB/DB (SB default). + - cmd line options: + -sb Single buffer mode. + -db Double buffer mode. + -dr Direct render mode. + -ir Indirect render mode. + -f RGB image file. + - keys: + ESC Quit. + Z Increase zoom factor. + z Decrease zoom factor. + - mouse input: + Left Copy location. + +cursor - Cursor test. + - RGBA/CI (RGBA default), SB/DB (SB default). + - cmd line options: + -rgb RGBA mode. + -ci Color index mode. + -sb Single buffer mode. + -db Double buffer mode. + - keys: + ESC Quit. + SPACE switch cursor color. + +depth - Z buffer test. + - RGBA/CI (RGBA default), SB/DB (SB default). + - cmd line options: + -rgb RGBA mode. + -ci Color index mode. + -sb Single buffer mode. + -db Double buffer mode. + - keys: + ESC Quit. + 1 Toggle anti-aliased mode. + 2 Toggle stipple mode. + +eval - Evaluator test. + - RGBA, SB/DB (SB default). + - cmd line options: + -sb Single buffer mode. + -db Double buffer mode. + - keys: + ESC Quit. + LEFT Rotate. + RIGHT Rotate. + UP Rotate. + DOWN Rotate. + 1 Toggle dimensions. + 2 Toggle dimensions. + e Use eval mode. + m Use mesh mode. + f Toggle polygon mode. + p Toggle point mode. + c Toggle color mode. + t Toggle texture mode. + l Toggle lighting mode. + +fog - Fog test. + - RGBA/CI (RGBA default), SB/DB (SB default). + - cmd line options: + -rgb RGBA mode. + -ci Color index mode. + -sb Single buffer mode. + -db Double buffer mode. + - keys: + ESC Quit. + LEFT Rotate. + RIGHT Rotate. + UP Rotate. + DOWN Rotate. + D Increase fog density. + d Decrease fog density. + +font - font test. + - RGBA/CI (RGBA default), SB/DB (SB default). + - cmd line options: + -rgb RGBA mode. + -ci Color index mode. + -sb Single buffer mode. + -db Double buffer mode. + - keys: + ESC Quit. + Left Shift left. + Right Shift right. + Up Shift up. + Down Shift down. + n Shift in. + m Shift out. + q Scale up x. + w Scale down x. + a Scale up y. + s Scale down y. + z Scale up z. + x Scale down z. + e Rotate clockwise x. + r Rotate counter-clockwise x. + d Rotate clockwise y. + f Rotate counter-clockwise y. + c Rotate clockwise z. + v Rotate counter-clockwise z. + +line - Line test. + - RGBA/CI (RGBA default), SB/DB (SB default). + - cmd line options: + -rgb RGBA mode. + -ci Color index mode. + -sb Single buffer mode. + -db Double buffer mode. + - keys: + ESC Quit. + W Increase line width. + w Decrease line width. + 1 Toggle stipple mode. + 2 Toggle anti-aliased mode. + +logo - Demo. + - RGBA/CI (RGBA default), SB/DB (SB default). + - cmd line options: + -rgb RGBA mode. + -ci Color index mode. + -sb Single buffer mode. + -db Double buffer mode. + - keys: + ESC Quit. + LEFT Rotate. + RIGHT Rotate + UP Move clipping plane. + DOWN Move clipping plane. + Z Translate. + z Translate. + 1 Use GL_POINT polygon mode. + 2 Use GL_LINE polygon mode. + 3 Use GL_FILL polygon mode. + p Toggle polygon fill modes. + 4 Use GL_NICEST for GL_POLYGON_SMOOTH_HINT. + 5 Use anti-aliased polygon mode. + 6 Use aliased polygon mode. + 8 Toggle dither mode. + 9 Toggle stipple polygon mode. + 0 Toggle flat/smooth shading mode. + q Disable cull mode. + w Use front face cull mode. + e Use back face cull mode. + r Use clockwise front face mode. + t Use counter-clockwise front face mode. + y Use MSB first stipple pattern. + u Use LSB first stipple pattern. + a Use brick texture map. + s Use checker texture map. + d Disable texture map. + f Use decal texture environment mode. + g Use modulate texture environment mode. + +nurb - Nurb test. + - RGBA, SB/DB (SB default). + - cmd line options: + -sb Single buffer mode. + -db Double buffer mode. + - keys: + ESC Quit. + LEFT Rotate. + RIGHT Rotate. + UP Rotate. + DOWN Rotate. + +olympic - Olymipic rings demo. + - RGBA/CI (RGBA default), SB/DB (SB default). + - cmd line options: + -rgb RGBA mode. + -ci Color index mode. + -sb Single buffer mode. + -db Double buffer mode. + - keys: + ESC Quit. + SPACE Restart demo. + +overlay - Overlay plane demo. + - RGBA, SB/DB (SB default). + - cmd line options: + -sb Single buffer mode. + -db Double buffer mode. + - keys: + ESC Quit. + SPACE Toggle star weird movement mode. + t Toggle star turbo mode. + +point - Point test. + - RGBA/CI (RGBA default), SB/DB (SB default). + - cmd line options: + -rgb RGBA mode. + -ci Color index mode. + -sb Single buffer mode. + -db Double buffer mode. + - keys: + ESC Quit. + LEFT Translate. + RIGHT Translate. + UP Translate. + DOWN Translate. + W Increase point width. + w Decrease point width. + 1 Toggle anti-aliased mode. + +prim - Primitive test. + - RGBA/CI (RGBA default), SB/DB (SB default). + - cmd line options: + -rgb RGBA mode. + -ci Color index mode. + -sb Single buffer mode. + -db Double buffer mode. + - keys: + ESC Quit. + 1 Toggle flat/smooth shade mode. + 2 Toggle outlined/filled polygon mode. + 3 Toggle color mask mode. + +quad - Quadric test. + - RGBA/CI (RGBA default), SB/DB (SB default). + - cmd line options: + -rgb RGBA mode. + -ci Color index mode. + -sb Single buffer mode. + -db Double buffer mode. + -dr Direct render mode. + -ir Indirect render mode. + -f texture file. + - keys: + ESC Quit. + LEFT Rotate. + RIGHT Rotate. + UP Rotate. + DOWN Rotate. + X Rotate. + x Rotate. + 1 Use GLU_FILL draw style. + 2 Use GLU_POINT draw style. + 3 Use GLU_LINE draw style. + 4 Use GLU_SILHOUETTE draw style. + 0 Toggle flat/smooth shade mode. + f Cylce through quadrics. + d Toggle orientation. + A Increase number of stacks. + a Decrease number of stacks. + S Increase number of slices. + s Decrease number of slices. + G Increase radius1. + g Decrease radius1. + J Increase radius2. + j Decrease radius2. + H Increase height. + h Decrease height. + K Increase angle1. + k Decrease angle1. + L Increase angle2. + l Decrease angle2. + z Toggle texture mode. + q Disable cull mode. + w Use front face cull mode. + e Use back face cull mode. + r Use clockwise front face mode. + t Use counter-clockwise front face mode. + y Toggle dither mode. + +select - Selection test. + - RGBA, SB. + - cmd line options: + - keys: + ESC Quit. + LEFT Rotate. + RIGHT Rotate. + Z Increase zoom factor. + z Decrease zoom factor. + d Zoom at current mouse location. + f Print feedback information. + l Toggle outlined/filled polygon mode. + - mouse: + Left Recolor selected triangle. + Center Enlarge selected triangle. + Right Delete selected triangle. + +shape - shape test. + - RGBA/CI (RGBA default), SB/DB (SB default). + - cmd line options: + -rgb RGBA mode. + -ci Color index mode. + -sb Single buffer mode. + -db Double buffer mode. + - keys: + ESC Quit. + Left Shift left. + Right Shift right. + Up Shift up. + Down Shift down. + n Shift in. + m Shift out. + q Scale up x. + w Scale down x. + a Scale up y. + s Scale down y. + z Scale up z. + x Scale down z. + e Rotate clockwise x. + r Rotate counter-clockwise x. + d Rotate clockwise y. + f Rotate counter-clockwise y. + c Rotate clockwise z. + v Rotate counter-clockwise z. + SPACE switch shapes. + +speed - Speed test. + - RGBA/CI (RGBA default), SB/DB (SB default). + - cmd line options: + -rgb RGBA mode. + -ci Color index mode. + -sb Single buffer mode. + -db Double buffer mode. + - keys: + ESC Quit. + a Toggle anti-aliased mode. + d Toggle z buffering mode. + f Toggle fog mode. + F Toggle fog hint mode. + s Toggle flat/smooth shading mode. + t Toggle texturing mode. + +sphere - Spheremap test. + - RGBA, SB/DB (SB default). + - cmd line options: + -sb Single buffer mode. + -db Double buffer mode. + -dr Direct render mode. + -ir Indirect render mode. + -f texture file. + -3 Use RGB components. + -4 Use RGBA components. + - keys: + ESC Quit. + LEFT Rotate about the y axis. + RIGHT Rotate about the y axis. + UP Rotate about the x axis. + DOWN Rotate about the x axis. + a Toggle auto rotate mode. + c toggle between cylinder or cube object. + t Use torus object. + d Use decal texture mode. + m Use modulate texture mode. + l Toggle lighted mode. + f Toggle fog mode. + 0 Use nearest magification filter. + 1 Use linear magification. + 2 Use nearest minification filter. + 3 Use linear minification filter. + 4 Use nearest-mipmap-nearest minification filter. + 5 Use nearest-mipmap-linear minification filter. + 6 Use linear-mipmap-nearest minification filter. + 7 Use linear-mipmap-linear minification filter. + +star - Demo. + - RGBA, SB/DB (SB default). + - cmd line options: + -sb Single buffer mode. + -db Double buffer mode. + - keys: + ESC Quit. + SPACE Toggle weird movement mode. + t Toggle turbo mode. + +stencil - Stencil test. + - RGBA, SB. + - cmd line options: + +stretch - Texture test. + - RGBA, SB. + - cmd line options: + -sb Single buffer mode. + -db Double buffer mode. + -dr Direct render mode. + -ir Indirect render mode. + -f texture file. + - keys: + ESC Quit. + SPACE Start animation. + - mouse: + Left Added stretch point. + +texture - Texture test. + - RGBA, SB/DB (SB default). + - cmd line options: + -sb Single buffer mode. + -db Double buffer mode. + -dr Direct render mode. + -ir Indirect render mode. + -f texture file. + - keys: + ESC Quit. + LEFT Rotate. + RIGHT Rotate. + UP Rotate. + DOWN Rotate. + T Translate. + t Translate. + s Toggle sphere map mode. + 0 Use nearest magification filter. + 1 Use linear magification filter. + 2 Use nearest minification filter. + 3 Use linear minification filter. + 4 Use nearest-mipmap-nearest minification filter. + 5 Use nearest-mipmap-linear minification filter. + 6 Use linear-mipmap-nearest minification filter. + 7 Use linear-mipmap-linear minification filter. + +tri - Triangle test. + - RGBA/CI (RGBA default), SB/DB (SB default). + - cmd line options: + -rgb RGBA mode. + -ci Color index mode. + -sb Single buffer mode. + -db Double buffer mode. + - keys: + ESC Quit. + LEFT Translate. + RIGHT Translate. + Z Increase zoom factor. + z Decrease zoom factor. + 1 Use point polygon mode. + 2 Use line polygon mode. + 3 Use filled polygon mode. + 4 Use point primitive. + 5 Use line-loop primitive. + 6 Use polygon primitive. + 7 Toggle cull mode. + 8 Use clockwise/counter-clockwise front face mode. + 9 Toggle front/back face cull mode. + v Toggle show verticies mode. + s Toggle flat/smooth shade mode. + h Toggle hide bottom triangle mode. + o Toggle outline mode. + m Toggle dither mode. + 0 Toggle anti-aliased mode. + +wave - Demo. + - RGBA/CI (RGBA default), SB/DB (SB default). + - cmd line options: + -rgb RGBA mode. + -ci Color index mode. + -sb Single buffer mode. + -db Double buffer mode. + -dr Direct render mode. + -ir Indirect render mode. + -grid Number of grids. + -size Size of grid. + -wave Height of wave (floating point number). + -frames Number of frames. + - keys: + ESC Quit. + c Toggle contouring mode. + s Toggle flat/smooth shade mode. + l Toggle lighting mode. + d Toggle depth checking mode. + SPACE Toggle step/animation mode. + n Single step in step mode. + a Toggle spin mode. diff --git a/progs/samples/accum.c b/progs/samples/accum.c new file mode 100644 index 00000000000..24dfc07d2a6 --- /dev/null +++ b/progs/samples/accum.c @@ -0,0 +1,157 @@ +/* + * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the name of + * Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF + * ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ +#include +#include +#include +#include + + +GLenum doubleBuffer; +GLint thing1, thing2; + + +static void Init(void) +{ + + glClearColor(0.0, 0.0, 0.0, 0.0); + glClearAccum(0.0, 0.0, 0.0, 0.0); + + thing1 = glGenLists(1); + glNewList(thing1, GL_COMPILE); + glColor3f(1.0, 0.0, 0.0); + glRectf(-1.0, -1.0, 1.0, 0.0); + glEndList(); + + thing2 = glGenLists(1); + glNewList(thing2, GL_COMPILE); + glColor3f(0.0, 1.0, 0.0); + glRectf(0.0, -1.0, 1.0, 1.0); + glEndList(); +} + +static void Reshape(int width, int height) +{ + + glViewport(0, 0, (GLint)width, (GLint)height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); +} + +static void Key(unsigned char key, int x, int y) +{ + (void) x; + (void) y; + switch (key) { + case 27: + exit(1); + case '1': + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); + break; + case '2': + glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); + break; + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + + glPushMatrix(); + + glScalef(0.8, 0.8, 1.0); + + glClear(GL_COLOR_BUFFER_BIT); + glCallList(thing1); + glAccum(GL_LOAD, 0.5); + + glClear(GL_COLOR_BUFFER_BIT); + glCallList(thing2); + glAccum(GL_ACCUM, 0.5); + + glAccum(GL_RETURN, 1.0); + + glPopMatrix(); + + glFlush(); + + if (doubleBuffer) { + glutSwapBuffers(); + } +} + +static GLenum Args(int argc, char **argv) +{ + GLint i; + + doubleBuffer = GL_FALSE; + + for (i = 1; i < argc; i++) { + if (strcmp(argv[i], "-sb") == 0) { + doubleBuffer = GL_FALSE; + } else if (strcmp(argv[i], "-db") == 0) { + doubleBuffer = GL_TRUE; + } else { + printf("%s (Bad option).\n", argv[i]); + return GL_FALSE; + } + } + return GL_TRUE; +} + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + if (Args(argc, argv) == GL_FALSE) { + exit(1); + } + + glutInitWindowPosition(0, 0); + glutInitWindowSize( 300, 300); + + type = GLUT_RGB | GLUT_ACCUM; + type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("Accum Test") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/samples/bitmap1.c b/progs/samples/bitmap1.c new file mode 100644 index 00000000000..517d584e212 --- /dev/null +++ b/progs/samples/bitmap1.c @@ -0,0 +1,250 @@ +/* + * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the name of + * Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF + * ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#include +#include +#include +#include + + +#define OPENGL_WIDTH 24 +#define OPENGL_HEIGHT 13 + + +GLenum rgb, doubleBuffer, windType; + +float boxA[3] = { + 0, 0, 0 +}; +float boxB[3] = { + -100, 0, 0 +}; +float boxC[3] = { + 100, 0, 0 +}; +float boxD[3] = { + 0, 95, 0 +}; +float boxE[3] = { + 0, -105, 0 +}; +GLubyte OpenGL_bits1[] = { + 0x00, 0x03, 0x00, + 0x7f, 0xfb, 0xff, + 0x7f, 0xfb, 0xff, + 0x00, 0x03, 0x00, + 0x3e, 0x8f, 0xb7, + 0x63, 0xdb, 0xb0, + 0x63, 0xdb, 0xb7, + 0x63, 0xdb, 0xb6, + 0x63, 0x8f, 0xf3, + 0x63, 0x00, 0x00, + 0x63, 0x00, 0x00, + 0x63, 0x00, 0x00, + 0x3e, 0x00, 0x00, +}; +GLubyte OpenGL_bits2[] = { + 0x00, 0x00, 0x00, + 0xff, 0xff, 0x01, + 0xff, 0xff, 0x01, + 0x00, 0x00, 0x00, + 0xf9, 0xfc, 0x01, + 0x8d, 0x0d, 0x00, + 0x8d, 0x0d, 0x00, + 0x8d, 0x0d, 0x00, + 0xcc, 0x0d, 0x00, + 0x0c, 0x4c, 0x0a, + 0x0c, 0x4c, 0x0e, + 0x8c, 0xed, 0x0e, + 0xf8, 0x0c, 0x00, +}; +GLubyte logo_bits[] = { + 0x00, 0x66, 0x66, + 0xff, 0x66, 0x66, + 0x00, 0x00, 0x00, + 0xff, 0x3c, 0x3c, + 0x00, 0x42, 0x40, + 0xff, 0x42, 0x40, + 0x00, 0x41, 0x40, + 0xff, 0x21, 0x20, + 0x00, 0x2f, 0x20, + 0xff, 0x20, 0x20, + 0x00, 0x10, 0x90, + 0xff, 0x10, 0x90, + 0x00, 0x0f, 0x10, + 0xff, 0x00, 0x00, + 0x00, 0x66, 0x66, + 0xff, 0x66, 0x66, +}; + +#include "tkmap.c" + +static void Init(void) +{ + + glClearColor(0.0, 0.0, 0.0, 0.0); + glClearIndex(0.0); +} + +static void Reshape(int width, int height) +{ + + glViewport(0, 0, (GLint)width, (GLint)height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluOrtho2D(-175, 175, -175, 175); + glMatrixMode(GL_MODELVIEW); +} + +static void Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + } +} + +static void Draw(void) +{ + float mapI[2], mapIA[2], mapIR[2]; + + glClear(GL_COLOR_BUFFER_BIT); + + mapI[0] = 0.0; + mapI[1] = 1.0; + mapIR[0] = 0.0; + mapIR[1] = 0.0; + mapIA[0] = 1.0; + mapIA[1] = 1.0; + + glPixelMapfv(GL_PIXEL_MAP_I_TO_R, 2, mapIR); + glPixelMapfv(GL_PIXEL_MAP_I_TO_G, 2, mapI); + glPixelMapfv(GL_PIXEL_MAP_I_TO_B, 2, mapI); + glPixelMapfv(GL_PIXEL_MAP_I_TO_A, 2, mapIA); + glPixelTransferi(GL_MAP_COLOR, GL_TRUE); + + SetColor(COLOR_WHITE); + glRasterPos3fv(boxA); + glPixelStorei(GL_UNPACK_ROW_LENGTH, 24); + glPixelStorei(GL_UNPACK_SKIP_PIXELS, 8); + glPixelStorei(GL_UNPACK_SKIP_ROWS, 2); + glPixelStorei(GL_UNPACK_LSB_FIRST, GL_FALSE); + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + glBitmap(16, 12, 8.0, 0.0, 0.0, 0.0, logo_bits); + + glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); + glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0); + glPixelStorei(GL_UNPACK_SKIP_ROWS, 0); + glPixelStorei(GL_UNPACK_LSB_FIRST, GL_TRUE); + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + + SetColor(COLOR_WHITE); + glRasterPos3fv(boxB); + glBitmap(OPENGL_WIDTH, OPENGL_HEIGHT, OPENGL_WIDTH, 0.0, OPENGL_WIDTH, 0.0, + OpenGL_bits1); + glBitmap(OPENGL_WIDTH, OPENGL_HEIGHT, OPENGL_WIDTH, 0.0, OPENGL_WIDTH, 0.0, + OpenGL_bits2); + + SetColor(COLOR_YELLOW); + glRasterPos3fv(boxC); + glBitmap(OPENGL_WIDTH, OPENGL_HEIGHT, OPENGL_WIDTH, 0.0, OPENGL_WIDTH, 0.0, + OpenGL_bits1); + glBitmap(OPENGL_WIDTH, OPENGL_HEIGHT, OPENGL_WIDTH, 0.0, OPENGL_WIDTH, 0.0, + OpenGL_bits2); + + SetColor(COLOR_CYAN); + glRasterPos3fv(boxD); + glBitmap(OPENGL_WIDTH, OPENGL_HEIGHT, OPENGL_WIDTH, 0.0, OPENGL_WIDTH, 0.0, + OpenGL_bits1); + glBitmap(OPENGL_WIDTH, OPENGL_HEIGHT, OPENGL_WIDTH, 0.0, OPENGL_WIDTH, 0.0, + OpenGL_bits2); + + SetColor(COLOR_RED); + glRasterPos3fv(boxE); + glBitmap(OPENGL_WIDTH, OPENGL_HEIGHT, OPENGL_WIDTH, 0.0, OPENGL_WIDTH, 0.0, + OpenGL_bits1); + glBitmap(OPENGL_WIDTH, OPENGL_HEIGHT, OPENGL_WIDTH, 0.0, OPENGL_WIDTH, 0.0, + OpenGL_bits2); + + glFlush(); + + if (doubleBuffer) { + glutSwapBuffers(); + } +} + +static GLenum Args(int argc, char **argv) +{ + GLint i; + + rgb = GL_TRUE; + doubleBuffer = GL_FALSE; + + for (i = 1; i < argc; i++) { + if (strcmp(argv[i], "-ci") == 0) { + rgb = GL_FALSE; + } else if (strcmp(argv[i], "-rgb") == 0) { + rgb = GL_TRUE; + } else 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; +} + +int main(int argc, char **argv) +{ + glutInit(&argc, argv); + + if (Args(argc, argv) == GL_FALSE) { + exit(1); + } + + glutInitWindowPosition(0, 0); glutInitWindowSize( 300, 300); + + windType = (rgb) ? GLUT_RGB : GLUT_INDEX; + windType |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; + glutInitDisplayMode(windType); + + if (glutCreateWindow("Bitmap Test") == GL_FALSE) { + exit(1); + } + + InitMap(); + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/samples/bitmap2.c b/progs/samples/bitmap2.c new file mode 100644 index 00000000000..5faac841622 --- /dev/null +++ b/progs/samples/bitmap2.c @@ -0,0 +1,787 @@ +/* + * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the name of + * Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF + * ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ +#include +#include +#include +#include + + +#define EXP_WIDTH 80 +#define EXP_HEIGHT 80 + + +GLenum rgb, doubleBuffer, windType; + +#include "tkmap.c" + +GLenum useLists, abuse; +GLubyte exp_bits[7][800] = { + { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x40, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x80, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x04, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x81, 0x04, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xf2, 0x1f, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xbe, 0x7c, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xf6, 0x4f, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xde, 0x7d, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xea, 0xef, 0x01, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xff, 0x55, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xdd, 0xfd, 0x03, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xbf, 0xae, 0x22, 0x36, 0x00, 0x00, + 0x00, 0x00, 0x00, 0xdb, 0xf7, 0x3f, 0x1e, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x80, 0x50, 0xbf, 0xbf, 0x85, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xff, 0xe5, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xee, 0x7e, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x74, 0x4b, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xe8, 0x3e, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xf8, 0x49, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x54, 0x07, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x04, 0x80, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x02, 0x80, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }, + { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xc0, 0x70, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x78, 0x91, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x60, 0xf1, 0x53, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x40, 0x97, 0x5c, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0xa0, 0x0c, 0x8c, 0x1b, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0xc4, 0x01, 0x00, 0xc8, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x08, 0x02, 0x00, 0x88, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x60, 0x00, 0x02, 0x40, 0x02, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x70, 0x00, 0x0c, 0x40, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x70, 0xe0, 0x0d, 0x00, 0x04, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x72, 0xc8, 0x07, 0x40, 0x08, 0x00, 0x00, + 0x00, 0x00, 0x80, 0x02, 0x78, 0x2f, 0x40, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x40, 0x02, 0xb0, 0x0a, 0x20, 0x77, 0x00, 0x00, + 0x00, 0x00, 0x40, 0x13, 0x10, 0x33, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xc0, 0x02, 0x78, 0xbb, 0x81, 0x09, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x02, 0xdc, 0xe7, 0x00, 0x09, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xac, 0x78, 0x00, 0x31, 0x00, 0x00, + 0x00, 0x00, 0x40, 0x03, 0x74, 0x4b, 0x00, 0x03, 0x00, 0x00, + 0x00, 0x00, 0x80, 0x02, 0xe8, 0x3e, 0x00, 0x01, 0x10, 0x00, + 0x00, 0x00, 0x80, 0x00, 0xf8, 0x49, 0x80, 0x09, 0x1c, 0x00, + 0x00, 0x00, 0x00, 0x0c, 0x40, 0x07, 0x00, 0x05, 0x1c, 0x00, + 0x00, 0x00, 0x80, 0x09, 0x04, 0x80, 0x00, 0x02, 0x00, 0x00, + 0x00, 0x00, 0x80, 0x11, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, + 0x00, 0x00, 0x80, 0x1d, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x80, 0xe3, 0x0b, 0x00, 0x22, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x80, 0x8f, 0x10, 0x00, 0xa0, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x80, 0x4f, 0x20, 0x78, 0x60, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x80, 0x80, 0x79, 0x18, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x78, 0x7c, 0x05, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x03, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x87, 0x01, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }, + { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x02, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x18, 0xc0, 0x04, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x84, 0x80, 0x04, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x80, 0x60, 0x06, 0x0c, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x80, 0x07, 0x64, 0x3a, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x39, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x20, 0x00, 0x08, 0x72, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x80, 0x3b, 0x00, 0x00, 0xc0, 0x33, 0x00, 0x00, + 0x00, 0x00, 0xa0, 0x1b, 0x00, 0x00, 0x80, 0x42, 0x00, 0x00, + 0x00, 0x00, 0xd0, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, + 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, + 0x00, 0x00, 0x6a, 0x00, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, + 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x50, 0x02, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, + 0x00, 0x80, 0x07, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, + 0x00, 0x30, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, + 0x00, 0x80, 0x03, 0x03, 0x80, 0x00, 0x00, 0x00, 0x08, 0x00, + 0x00, 0xe2, 0x82, 0x03, 0x00, 0x20, 0x00, 0x00, 0x40, 0x00, + 0x00, 0x0e, 0x80, 0x03, 0x00, 0x4c, 0x00, 0x00, 0x10, 0x00, + 0x00, 0x0e, 0x80, 0x03, 0xec, 0x10, 0x00, 0x00, 0x60, 0x00, + 0x00, 0x12, 0x00, 0x00, 0x05, 0x93, 0x01, 0x00, 0x20, 0x00, + 0x00, 0x12, 0x00, 0x00, 0x00, 0x5c, 0x0c, 0x00, 0x60, 0x00, + 0x00, 0x30, 0x00, 0xc0, 0x05, 0x81, 0x10, 0x00, 0x00, 0x00, + 0x00, 0x2c, 0x00, 0x00, 0xcc, 0x06, 0x00, 0x00, 0x20, 0x00, + 0x00, 0x30, 0x00, 0x00, 0x28, 0x20, 0x02, 0x00, 0x00, 0x00, + 0x00, 0x30, 0x80, 0x80, 0x22, 0x00, 0x02, 0x00, 0x00, 0x02, + 0x00, 0x20, 0x00, 0x80, 0x02, 0x20, 0x08, 0x00, 0x20, 0x02, + 0x00, 0x38, 0x00, 0x00, 0x00, 0x11, 0x28, 0x00, 0x20, 0x06, + 0x00, 0x20, 0x00, 0x80, 0x0e, 0xc0, 0x21, 0x00, 0x5c, 0x00, + 0x00, 0x24, 0x00, 0x90, 0x40, 0x58, 0x04, 0x00, 0x20, 0x01, + 0x00, 0x24, 0x00, 0x10, 0x22, 0x02, 0x05, 0x00, 0x20, 0x02, + 0x00, 0x00, 0x00, 0x00, 0x28, 0xb6, 0x00, 0x00, 0x20, 0x01, + 0x00, 0x70, 0x00, 0x00, 0x18, 0xc1, 0x00, 0x00, 0xc0, 0x01, + 0x00, 0xc0, 0x00, 0x00, 0x40, 0x83, 0x04, 0x00, 0xc0, 0x01, + 0x00, 0x00, 0x01, 0x80, 0xfc, 0x41, 0x02, 0x00, 0x10, 0x00, + 0x00, 0x00, 0x01, 0x00, 0x03, 0x30, 0x00, 0x00, 0x10, 0x00, + 0x00, 0x10, 0x02, 0x00, 0x40, 0x1d, 0x00, 0x00, 0x20, 0x00, + 0x00, 0x30, 0x04, 0x00, 0x00, 0x00, 0x02, 0x00, 0x20, 0x00, + 0x00, 0x00, 0x04, 0x00, 0x60, 0x00, 0x00, 0x00, 0x20, 0x00, + 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, + 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x01, + 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, + 0x00, 0x00, 0x38, 0x00, 0x81, 0x0f, 0x00, 0x00, 0x2a, 0x00, + 0x00, 0x00, 0xf8, 0x02, 0x80, 0x0f, 0x00, 0x00, 0x10, 0x00, + 0x00, 0x00, 0xf8, 0x02, 0x80, 0x0f, 0x00, 0x00, 0x08, 0x00, + 0x00, 0x00, 0x00, 0x06, 0xc0, 0x01, 0x00, 0x00, 0x07, 0x00, + 0x00, 0x00, 0x00, 0x14, 0xe0, 0x00, 0x00, 0x80, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x08, 0x70, 0x00, 0x00, 0x85, 0x00, 0x00, + 0x00, 0x00, 0xc0, 0x00, 0x30, 0x00, 0x20, 0x3c, 0x00, 0x00, + 0x00, 0x00, 0x00, 0xe0, 0xe0, 0x80, 0x00, 0x0b, 0x00, 0x00, + 0x00, 0x00, 0x00, 0xe0, 0x79, 0x83, 0x80, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x80, 0x19, 0x22, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf4, 0x28, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }, + { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x04, 0x00, 0x20, 0x00, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x80, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, + 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, + 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x83, 0x00, 0x00, + 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x80, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x00, 0xc0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0xe0, 0x03, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0xc0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, + 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x20, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x03, 0x00, 0x00, 0x00, 0x02, 0x90, 0x00, 0x00, 0x00, 0x40, + 0x02, 0x02, 0x00, 0x80, 0x80, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x40, 0x00, 0x00, 0x40, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x01, 0x00, 0x20, 0x00, 0x04, 0x02, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x30, 0x28, 0x90, 0x05, 0x00, 0x00, 0x40, + 0x00, 0x00, 0x00, 0x48, 0x05, 0x00, 0x21, 0x00, 0x00, 0x0c, + 0x00, 0x00, 0x00, 0x84, 0x00, 0x54, 0x05, 0x00, 0x00, 0x00, + 0x04, 0x00, 0x00, 0x40, 0x05, 0x80, 0x41, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x0e, 0x02, 0x01, 0x00, 0x00, 0x20, + 0x00, 0x00, 0x00, 0x08, 0x20, 0x20, 0x01, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x84, 0x82, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x48, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x40, + 0x04, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x21, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x90, 0x40, 0x40, 0x04, 0x00, 0x00, 0x80, + 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x41, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x08, 0x40, 0xa0, 0x00, 0x00, 0x00, 0x50, + 0x00, 0x00, 0x00, 0x00, 0x10, 0x01, 0x00, 0x00, 0x00, 0x40, + 0x40, 0x00, 0x00, 0x00, 0x40, 0x02, 0x04, 0x00, 0x00, 0x30, + 0x00, 0x00, 0x00, 0x80, 0x84, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xc2, 0x20, 0x20, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x10, 0xc0, 0x05, 0x20, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x20, 0x04, 0x00, 0x02, 0x00, 0x00, 0x10, + 0x08, 0x00, 0x00, 0x80, 0x00, 0x10, 0x10, 0x00, 0x00, 0x08, + 0x10, 0x02, 0x00, 0x00, 0x21, 0x04, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, + 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x18, 0x08, 0x00, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x08, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x3a, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x40, 0x04, + 0x00, 0x60, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x04, + 0x00, 0xb8, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, + 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x40, 0x00, 0x00, 0x20, 0x00, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }, + { + 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, + 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x81, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x01, 0x08, 0x00, 0x00, + 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x1f, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x80, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x40, 0x00, 0x80, 0x80, 0x00, 0x80, 0x00, 0x00, + 0x00, 0x00, 0x60, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x08, 0x01, 0x00, 0x01, 0x10, 0x04, 0x00, 0x00, + 0x00, 0x40, 0x00, 0x02, 0x02, 0x90, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x1c, 0x20, 0x05, 0x00, 0x04, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x28, 0x00, 0x14, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x20, 0x40, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x44, 0xc4, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x06, 0x40, 0x00, 0x00, 0x40, 0x00, 0x02, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x10, 0x00, 0x00, + 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x80, 0x10, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x80, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x04, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x02, 0x00, + 0x00, 0x00, 0x42, 0x00, 0x00, 0x04, 0x20, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x02, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x20, 0x05, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x02, 0x00, 0x81, 0x07, 0x01, 0x03, 0x00, 0x00, + 0x00, 0x00, 0x40, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x20, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x08, 0x02, 0x80, 0x20, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x80, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x80, 0x82, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x80, 0x00, 0x00, 0x40, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, + 0xc0, 0x00, 0x00, 0x80, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x40, 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x02, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x40, 0x0d, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }, + { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x07, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x1f, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, + 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x04, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, + 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xd0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x01, 0x10, 0x00, 0x00, 0x04, 0x00, 0x00, 0x20, 0x00, + 0x02, 0x02, 0x08, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0xc0, 0x00, 0x40, 0x00, 0x02, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x40, 0x00, + 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x01, + 0x00, 0x04, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, + 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, + 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x80, 0x06, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x04, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x02, 0x20, 0x00, 0x00, + 0x08, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00 + }, + { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x04, 0x00, 0x00, 0x80, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, + 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, + 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, + 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + } +}; +GLint exp_lists[7]; + + +static void Init(void) +{ + GLint i; + + glClearColor(0.0, 0.0, 0.0, 0.0); + glClearIndex(0.0); + + glPixelStorei(GL_UNPACK_LSB_FIRST, GL_TRUE); + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + for (i = 0; i < 7; i++) { + exp_lists[i] = glGenLists(1); + glNewList(exp_lists[i], GL_COMPILE); + glBitmap(80, 80, 40.0, 40.0, 0.0, 0.0, exp_bits[i]); + glEndList(); + } + + abuse = GL_FALSE; + useLists = GL_TRUE; +} + +static void Reshape(int width, int height) +{ + + glViewport(0, 0, (GLint)width, (GLint)height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluOrtho2D(-175, 175, -175, 175); + glMatrixMode(GL_MODELVIEW); +} + +static void Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + case '1': + useLists = !useLists; + break; + case '2': + abuse = !abuse; + break; + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + GLint i, j; + + glClear(GL_COLOR_BUFFER_BIT); + + for (i = 0; i < 7; i++) { + for (j = 0; j < 40; j++) { + switch (j % 7) { + case 0: + SetColor(COLOR_YELLOW); + break; + case 1: + SetColor(COLOR_GREEN); + break; + case 2: + SetColor(COLOR_BLUE); + break; + case 3: + SetColor(COLOR_MAGENTA); + break; + case 4: + SetColor(COLOR_CYAN); + break; + case 5: + SetColor(COLOR_WHITE); + break; + case 6: + SetColor(COLOR_RED); + break; + } + glRasterPos3i((j*3)%5, (j*3)%8, 0); + + if (useLists) { + glCallList(exp_lists[i]); + } else { + glBitmap(80, 80, 40.0, 40.0, 0.0, 0.0, exp_bits[i]); + } + if (!abuse) { + break; + } + } + + if (i == 6) { + break; + } + + for (j = 0; j < 40; j++) { + SetColor(COLOR_BLACK); + glRasterPos3i((j*3)%5, (j*3)%8, 0); + if (useLists) { + glCallList(exp_lists[i]); + } else { + glBitmap(80, 80, 40.0, 40.0, 0.0, 0.0, exp_bits[i]); + } + if (!abuse) { + break; + } + } + } + + glFlush(); + + if (doubleBuffer) { + glutSwapBuffers(); + } +} + +static GLenum Args(int argc, char **argv) +{ + GLint i; + + rgb = GL_TRUE; + doubleBuffer = GL_FALSE; + + for (i = 1; i < argc; i++) { + if (strcmp(argv[i], "-ci") == 0) { + rgb = GL_FALSE; + } else if (strcmp(argv[i], "-rgb") == 0) { + rgb = GL_TRUE; + } else 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; +} + +int main(int argc, char **argv) +{ + glutInit(&argc, argv); + + if (Args(argc, argv) == GL_FALSE) { + exit(1); + } + + glutInitWindowPosition(0, 0); glutInitWindowSize( 300, 300); + + windType = (rgb) ? GLUT_RGB : GLUT_INDEX; + windType |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; + glutInitDisplayMode(windType); + + if (glutCreateWindow("Bitmap Test") == GL_FALSE) { + exit(1); + } + + InitMap(); + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/samples/blendeq.c b/progs/samples/blendeq.c new file mode 100644 index 00000000000..f78afd30381 --- /dev/null +++ b/progs/samples/blendeq.c @@ -0,0 +1,319 @@ +/* +** blendeq.c - Demonstrates the use of the blend_minmax, blend_subtract, +** and blend_logic_op extensions using glBlendEquationEXT. +** +** Over a two-color backround, draw rectangles using twelve blend +** options. The values are read back as UNSIGNED_BYTE and printed +** in hex over each value. These values are useful for logic +** op comparisons when channels are 8 bits deep. +*/ + +#include +#include +#include +#ifdef _WIN32 +#include +#endif +#define GL_GLEXT_PROTOTYPES +#include + +GLenum doubleBuffer; +static int dithering = 0; +int use11ops = 0; +int supportlogops = 0; +static int doPrint = 1; +static int deltaY; +GLint windW, windH; + +static void DrawString(const char *string) +{ + int i; + + for (i = 0; string[i]; i++) + glutBitmapCharacter(GLUT_BITMAP_9_BY_15, string[i]); +} + +static void Init(void) +{ + + glDisable(GL_DITHER); + glShadeModel(GL_FLAT); +} + +static void Reshape(int width, int height) +{ + + windW = (GLint)width; + windH = (GLint)height; + + glViewport(0, 0, (GLint)width, (GLint)height); + deltaY = windH /16; + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluOrtho2D(0, windW, 0, windH); + glMatrixMode(GL_MODELVIEW); +} + +static void Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + case 'd': + dithering = !dithering; + break; + case 'l': + if (supportlogops == 3) + use11ops = (!use11ops); + if (use11ops) + printf("Using GL 1.1 color logic ops.\n"); + else printf("Using GL_EXT_blend_logic_op.\n"); + break; + default: + return; + } + + glutPostRedisplay(); +} + +static void PrintColorStrings( void ) +{ + GLubyte ubbuf[3]; + int i, xleft, xright; + char colorString[18]; + + xleft = 5 + windW/4; + xright = 5 + windW/2; + + for (i = windH - deltaY + 4; i > 0; i-=deltaY) { + glReadPixels(xleft, i+10, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, ubbuf); + sprintf(colorString, "(0x%x, 0x%x, 0x%x)", + ubbuf[0], ubbuf[1], ubbuf[2]); + glRasterPos2f(xleft, i); + DrawString(colorString); + glReadPixels(xright, i+10, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, ubbuf); + sprintf(colorString, "(0x%x, 0x%x, 0x%x)", + ubbuf[0], ubbuf[1], ubbuf[2]); + glRasterPos2f(xright, i); + DrawString(colorString); + } +} + +static void Draw(void) +{ + int stringOffset = 5, stringx = 8; + int x1, x2, xleft, xright; + int i; + + (dithering) ? glEnable(GL_DITHER) : glDisable(GL_DITHER); + glDisable(GL_BLEND); + if (supportlogops & 2) + glDisable(GL_COLOR_LOGIC_OP); + + glClearColor(0.5, 0.6, 0.1, 1.0); + glClear(GL_COLOR_BUFFER_BIT); + + /* Draw background */ + glColor3f(0.1, 0.1, 1.0); + glRectf(0.0, 0.0, windW/2, windH); + + /* Draw labels */ + glColor3f(0.8, 0.8, 0.0); + i = windH - deltaY + stringOffset; + glRasterPos2f(stringx, i); i -= deltaY; + DrawString("SOURCE"); + glRasterPos2f(stringx, i); i -= deltaY; + DrawString("DEST"); + glRasterPos2f(stringx, i); i -= deltaY; + DrawString("min"); + glRasterPos2f(stringx, i); i -= deltaY; + DrawString("max"); + glRasterPos2f(stringx, i); i -= deltaY; + DrawString("subtract"); + glRasterPos2f(stringx, i); i -= deltaY; + DrawString("reverse_subtract"); + glRasterPos2f(stringx, i); i -= deltaY; + DrawString("clear"); + glRasterPos2f(stringx, i); i -= deltaY; + DrawString("set"); + glRasterPos2f(stringx, i); i -= deltaY; + DrawString("copy"); + glRasterPos2f(stringx, i); i -= deltaY; + DrawString("noop"); + glRasterPos2f(stringx, i); i -= deltaY; + DrawString("and"); + glRasterPos2f(stringx, i); i -= deltaY; + DrawString("invert"); + glRasterPos2f(stringx, i); i -= deltaY; + DrawString("or"); + glRasterPos2f(stringx, i); i -= deltaY; + DrawString("xor"); + + + i = windH - deltaY; + x1 = windW/4; + x2 = 3 * windW/4; + xleft = 5 + windW/4; + xright = 5 + windW/2; + + /* Draw foreground color for comparison */ + glColor3f(0.9, 0.2, 0.8); + glRectf(x1, i, x2, i+deltaY); + + /* Leave one rectangle of background color */ + + /* Begin test cases */ + glEnable(GL_BLEND); + glBlendFunc(GL_ONE, GL_ONE); + + i -= 2*deltaY; + glBlendEquationEXT(GL_MIN_EXT); + glRectf(x1, i, x2, i+deltaY); + + i -= deltaY; + glBlendEquationEXT(GL_MAX_EXT); + glRectf(x1, i, x2, i+deltaY); + + i -= deltaY; + glBlendEquationEXT(GL_FUNC_SUBTRACT_EXT); + glRectf(x1, i, x2, i+deltaY); + + i -= deltaY; + glBlendEquationEXT(GL_FUNC_REVERSE_SUBTRACT_EXT); + glRectf(x1, i, x2, i+deltaY); + + glBlendFunc(GL_ONE, GL_ZERO); + i -= deltaY; + if (!use11ops) + glBlendEquationEXT(GL_LOGIC_OP); + else + glEnable(GL_COLOR_LOGIC_OP); + glLogicOp(GL_CLEAR); + glRectf(x1, i, x2, i+deltaY); + + i -= deltaY; + glLogicOp(GL_SET); + glRectf(x1, i, x2, i+deltaY); + + i -= deltaY; + glLogicOp(GL_COPY); + glRectf(x1, i, x2, i+deltaY); + + i -= deltaY; + glLogicOp(GL_NOOP); + glRectf(x1, i, x2, i+deltaY); + + i -= deltaY; + glLogicOp(GL_AND); + glRectf(x1, i, x2, i+deltaY); + + i -= deltaY; + glLogicOp(GL_INVERT); + glRectf(x1, i, x2, i+deltaY); + + i -= deltaY; + glLogicOp(GL_OR); + glRectf(x1, i, x2, i+deltaY); + + i -= deltaY; + glLogicOp(GL_XOR); + glRectf(x1, i, x2, i+deltaY); + glRectf(x1, i+10, x2, i+5); + + if (doPrint) { + glDisable(GL_BLEND); + if (supportlogops & 2) + glDisable(GL_COLOR_LOGIC_OP); + glColor3f(1.0, 1.0, 1.0); + PrintColorStrings(); + } + glFlush(); + + if (doubleBuffer) { + glutSwapBuffers(); + } + +} + +static GLenum Args(int argc, char **argv) +{ + GLint i; + + doubleBuffer = GL_FALSE; + + for (i = 1; i < argc; i++) { + if (strcmp(argv[i], "-sb") == 0) { + doubleBuffer = GL_FALSE; + } else if (strcmp(argv[i], "-db") == 0) { + doubleBuffer = GL_TRUE; + } else { + printf("%s (Bad option).\n", argv[i]); + return GL_FALSE; + } + } + return GL_TRUE; +} + +int main(int argc, char **argv) +{ + GLenum type; + char *s; + char *extName1 = "GL_EXT_blend_logic_op"; + char *extName2 = "GL_EXT_blend_minmax"; + char *extName3 = "GL_EXT_blend_subtract"; + char *version; + + glutInit(&argc, argv); + + if (Args(argc, argv) == GL_FALSE) { + exit(1); + } + + glutInitWindowPosition(0, 0); glutInitWindowSize( 800, 400); + + type = GLUT_RGB; + type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("Blend Equation") == GL_FALSE) { + exit(1); + } + + /* Make sure blend_logic_op extension is there. */ + s = (char *) glGetString(GL_EXTENSIONS); + version = (char*) glGetString(GL_VERSION); + if (!s) + exit(1); + if (strstr(s,extName1)) { + supportlogops = 1; + use11ops = 0; + printf("blend_logic_op extension available.\n"); + } + if (strncmp(version,"1.1",3)>=0) { + supportlogops += 2; + use11ops = 1; + printf("1.1 color logic ops available.\n"); + } + if (supportlogops == 0) { + printf("Blend_logic_op extension and GL 1.1 not present.\n"); + exit(1); + } + if (strstr(s,extName2) == 0) { + printf("Blend_minmax extension is not present.\n"); + exit(1); + } + if (strstr(s,extName3) == 0) { + printf("Blend_subtract extension is not present.\n"); + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/samples/blendxor.c b/progs/samples/blendxor.c new file mode 100644 index 00000000000..5bc4aa9bea4 --- /dev/null +++ b/progs/samples/blendxor.c @@ -0,0 +1,206 @@ +/* +** blendxor.c - Demonstrates the use of the blend_logic_op +** extension to draw hilights. Using XOR to draw the same +** image twice restores the background to its original value. +*/ + +#include +#include +#ifndef _WIN32 +#include +#endif +#include +#ifdef _WIN32 +#include +#endif +#define GL_GLEXT_LEGACY +#define GL_GLEXT_PROTOTYPES +#include +#include + + +GLenum doubleBuffer; +int dithering = 0; +int use11ops = 0; +int supportlogops = 0; +GLint windW, windH; + +static void Init(void) +{ + glDisable(GL_DITHER); + glShadeModel(GL_FLAT); +} + +static void Reshape(int width, int height) +{ + + windW = (GLint)width; + windH = (GLint)height; + + glViewport(0, 0, (GLint)width, (GLint)height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluOrtho2D(0, 400, 0, 400); + glMatrixMode(GL_MODELVIEW); +} + +static void Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + case 'd': + dithering = !dithering; + break; + case 'l': + if (supportlogops == 3) + use11ops = (!use11ops); + if (use11ops) + printf("Using GL 1.1 color logic ops.\n"); + else printf("Using GL_EXT_blend_logic_op.\n"); + break; + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + int i; + + glDisable(GL_BLEND); + if (supportlogops & 2) + glDisable(GL_COLOR_LOGIC_OP); + + (dithering) ? glEnable(GL_DITHER) : glDisable(GL_DITHER); + + glClearColor(0.5, 0.6, 0.1, 1.0); + glClear(GL_COLOR_BUFFER_BIT); + + /* Draw background prims */ + glColor3f(0.1, 0.1, 1.0); + glBegin(GL_TRIANGLES); + glVertex2i(5, 5); + glVertex2i(130, 50); + glVertex2i(100, 300); + glEnd(); + glColor3f(0.5, 0.2, 0.9); + glBegin(GL_TRIANGLES); + glVertex2i(200, 100); + glVertex2i(330, 50); + glVertex2i(340, 400); + glEnd(); + + glEnable(GL_BLEND); + if (!use11ops) + glBlendEquationEXT(GL_LOGIC_OP); + else + glEnable(GL_COLOR_LOGIC_OP); + glLogicOp(GL_XOR); + + /* Draw a set of rectangles across the window */ + glColor3f(0.9, 0.2, 0.8); + for(i = 0; i < 400; i+=60) { + glBegin(GL_POLYGON); + glVertex2i(i, 100); + glVertex2i(i+50, 100); + glVertex2i(i+50, 200); + glVertex2i(i, 200); + glEnd(); + } + glFlush(); /* Added by Brian Paul */ +#ifndef _WIN32 + sleep(2); +#endif + + /* Redraw the rectangles, which should erase them */ + for(i = 0; i < 400; i+=60) { + glBegin(GL_POLYGON); + glVertex2i(i, 100); + glVertex2i(i+50, 100); + glVertex2i(i+50, 200); + glVertex2i(i, 200); + glEnd(); + } + glFlush(); + + + if (doubleBuffer) { + glutSwapBuffers(); + } +} + +static GLenum Args(int argc, char **argv) +{ + GLint i; + + doubleBuffer = GL_FALSE; + + for (i = 1; i < argc; i++) { + if (strcmp(argv[i], "-sb") == 0) { + doubleBuffer = GL_FALSE; + } else if (strcmp(argv[i], "-db") == 0) { + doubleBuffer = GL_TRUE; + } else { + printf("%s (Bad option).\n", argv[i]); + return GL_FALSE; + } + } + return GL_TRUE; +} + +int main(int argc, char **argv) +{ + GLenum type; + char *s; + char *extName = "GL_EXT_blend_logic_op"; + char *version; + + glutInit(&argc, argv); + + if (Args(argc, argv) == GL_FALSE) { + exit(1); + } + + glutInitWindowPosition(0, 0); glutInitWindowSize( 400, 400); + + type = GLUT_RGB; + type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("Blend XOR") == GL_FALSE) { + exit(1); + } + + /* Make sure blend_logic_op extension is there. */ + s = (char *) glGetString(GL_EXTENSIONS); + version = (char*) glGetString(GL_VERSION); + if (!s) + exit(1); + if (strstr(s,extName)) { + supportlogops = 1; + use11ops = 0; + printf("blend_logic_op extension available.\n"); + } + if (strncmp(version,"1.1",3)>=0) { + supportlogops += 2; + use11ops = 1; + printf("1.1 color logic ops available.\n"); + } + if (supportlogops == 0) { + printf("Blend_logic_op extension and GL 1.1 not present.\n"); + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/samples/copy.c b/progs/samples/copy.c new file mode 100644 index 00000000000..391c637d6fa --- /dev/null +++ b/progs/samples/copy.c @@ -0,0 +1,193 @@ +/* + * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the name of + * Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF + * ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#include +#include +#include +#include + + +#include "loadppm.c" + +GLenum doubleBuffer; +GLint windW, windH; + +char *fileName = 0; +PPMImage *image; +float point[3]; +float zoom; +GLint x, y; + +static void Init(void) +{ + + glClearColor(0.0, 0.0, 0.0, 0.0); + + x = 0; + y = windH; + zoom = 1.8; +} + +static void Reshape(int width, int height) +{ + + windW = (GLint)width; + windH = (GLint)height; + + glViewport(0, 0, windW, windH); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluOrtho2D(0, windW, 0, windH); + glMatrixMode(GL_MODELVIEW); +} + +static void Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + case 'Z': + zoom += 0.2; + break; + case 'z': + zoom -= 0.2; + if (zoom < 0.2) { + zoom = 0.2; + } + break; + default: + return; + } + + glutPostRedisplay(); +} + +static void Mouse(int button, int state, int mouseX, int mouseY) +{ + if (state != GLUT_DOWN) + return; + x = (GLint)mouseX; + y = (GLint)mouseY; + + glutPostRedisplay(); +} + +static void Draw(void) +{ + + glClear(GL_COLOR_BUFFER_BIT); + + point[0] = (windW / 2) - (image->sizeX / 2); + point[1] = (windH / 2) - (image->sizeY / 2); + point[2] = 0; + glRasterPos3fv(point); + + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + glPixelZoom(1.0, 1.0); + glDrawPixels(image->sizeX, image->sizeY, GL_RGB, GL_UNSIGNED_BYTE, + image->data); + + point[0] = (float)x; + point[1] = windH - (float)y; + point[2] = 0.0; + glRasterPos3fv(point); + + glPixelZoom(zoom, zoom); + glCopyPixels((windW/2)-(image->sizeX/2), + (windH/2)-(image->sizeY/2), + image->sizeX, image->sizeY, GL_COLOR); + + glFlush(); + + if (doubleBuffer) { + glutSwapBuffers(); + } +} + +static GLenum Args(int argc, char **argv) +{ + GLint i; + + doubleBuffer = GL_FALSE; + + for (i = 1; i < argc; i++) { + if (strcmp(argv[i], "-sb") == 0) { + doubleBuffer = GL_FALSE; + } else if (strcmp(argv[i], "-db") == 0) { + doubleBuffer = GL_TRUE; + } else if (strcmp(argv[i], "-f") == 0) { + if (i+1 >= argc || argv[i+1][0] == '-') { + printf("-f (No file name).\n"); + return GL_FALSE; + } else { + fileName = argv[++i]; + } + } else { + printf("%s (Bad option).\n", argv[i]); + return GL_FALSE; + } + } + return GL_TRUE; +} + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + if (Args(argc, argv) == GL_FALSE) { + exit(1); + } + + if (fileName == 0) { + printf("No image file.\n"); + exit(1); + } + + image = LoadPPM(fileName); + + windW = 300; + windH = 300; + glutInitWindowPosition(0, 0); glutInitWindowSize( windW, windH); + + type = GLUT_RGB; + type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("Copy Test") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutMouseFunc(Mouse); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/samples/cursor.c b/progs/samples/cursor.c new file mode 100644 index 00000000000..de8fc58556c --- /dev/null +++ b/progs/samples/cursor.c @@ -0,0 +1,150 @@ +/* + * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the name of + * Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF + * ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#include +#include +#include +#include + + +GLenum rgb, doubleBuffer, windType; +int windX, windY; +int cursor; + + +#include "tkmap.c" + +static void Init(void) +{ + cursor = 0; + glutSetCursor(cursor); + glClearColor(0.0, 0.0, 0.0, 0.0); + glClearIndex(0.0); +} + +static void Reshape(int width, int height) +{ + + windX = width; + windY = height; + glViewport(0, 0, windX, windY); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluOrtho2D(0, windX, 0, windY); + glMatrixMode(GL_MODELVIEW); +} + +static void Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + case 32: + cursor++; + if (cursor > 19) { + cursor = 0; + } + glutSetCursor(cursor); + } +} + +static void Draw(void) +{ + + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_POLYGON); + SetColor(COLOR_BLACK); + glVertex2i(0, 0); + SetColor(COLOR_RED); + glVertex2i(windX, 0); + SetColor(COLOR_GREEN); + glVertex2i(windX, windY); + SetColor(COLOR_BLUE); + glVertex2i(0, windY); + glEnd(); + + glFlush(); + + if (doubleBuffer) { + glutSwapBuffers(); + } +} + +static GLenum Args(int argc, char **argv) +{ + GLint i; + + rgb = GL_TRUE; + doubleBuffer = GL_FALSE; + + for (i = 1; i < argc; i++) { + if (strcmp(argv[i], "-ci") == 0) { + rgb = GL_FALSE; + } else if (strcmp(argv[i], "-rgb") == 0) { + rgb = GL_TRUE; + } else 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; +} + +int main(int argc, char **argv) +{ + glutInit(&argc, argv); + + if (Args(argc, argv) == GL_FALSE) { + exit(1); + } + + windX = 300; + windY = 300; + glutInitWindowPosition(0, 0); glutInitWindowSize( windX, windY); + + windType = (rgb) ? GLUT_RGB : GLUT_INDEX; + windType |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; + glutInitDisplayMode(windType); + + if (glutCreateWindow("Cursor Test") == GL_FALSE) { + exit(1); + } + + InitMap(); + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/samples/depth.c b/progs/samples/depth.c new file mode 100644 index 00000000000..afe2ec17a38 --- /dev/null +++ b/progs/samples/depth.c @@ -0,0 +1,209 @@ +/* + * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the name of + * Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF + * ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#include +#include +#include +#include + + +#define CI_OFFSET_1 16 +#define CI_OFFSET_2 32 + + +GLenum rgb, doubleBuffer; + +GLenum antiAlias, stipple; +GLubyte stippleBits[32*4] = { + 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, +}; + + +#include "tkmap.c" + +static void Init(void) +{ + GLint i; + + glClearColor(0.0, 0.0, 0.0, 0.0); + glClearIndex(0.0); + + if (!rgb) { + for (i = 0; i < 16; i++) { + glutSetColor(i+CI_OFFSET_1, 0.0, 0.0, i/15.0); + glutSetColor(i+CI_OFFSET_2, 0.0, i/15.0, 0.0); + } + } + + glPolygonStipple(stippleBits); + + antiAlias = GL_FALSE; + stipple = GL_FALSE; +} + +static void Reshape(int width, int height) +{ + + glViewport(0, 0, (GLint)width, (GLint)height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0); + glMatrixMode(GL_MODELVIEW); +} + +static void Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + case '1': + antiAlias = !antiAlias; + break; + case '2': + stipple = !stipple; + break; + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + GLint ci1, ci2; + + glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); + + if (antiAlias) { + ci1 = CI_OFFSET_1; + ci2 = CI_OFFSET_2; + glBlendFunc(GL_SRC_ALPHA, GL_ONE); + glEnable(GL_BLEND); + glEnable(GL_POLYGON_SMOOTH); + glDisable(GL_DEPTH_TEST); + } else { + ci1 = COLOR_BLUE; + ci2 = COLOR_GREEN; + glDisable(GL_BLEND); + glDisable(GL_POLYGON_SMOOTH); + glEnable(GL_DEPTH_TEST); + } + + if (stipple) { + glEnable(GL_POLYGON_STIPPLE); + } else { + glDisable(GL_POLYGON_STIPPLE); + } + + glBegin(GL_TRIANGLES); + (rgb) ? glColor3fv(RGBMap[COLOR_BLUE]) : glIndexi(ci1); + glVertex3f( 0.9, -0.9, -30.0); + glVertex3f( 0.9, 0.9, -30.0); + glVertex3f(-0.9, 0.0, -30.0); + (rgb) ? glColor3fv(RGBMap[COLOR_GREEN]) : glIndexi(ci2); + glVertex3f(-0.9, -0.9, -40.0); + glVertex3f(-0.9, 0.9, -40.0); + glVertex3f( 0.9, 0.0, -25.0); + glEnd(); + + glFlush(); + + if (doubleBuffer) { + glutSwapBuffers(); + } +} + +static GLenum Args(int argc, char **argv) +{ + GLint i; + + rgb = GL_TRUE; + doubleBuffer = GL_FALSE; + + for (i = 1; i < argc; i++) { + if (strcmp(argv[i], "-ci") == 0) { + rgb = GL_FALSE; + } else if (strcmp(argv[i], "-rgb") == 0) { + rgb = GL_TRUE; + } else 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; +} + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + if (Args(argc, argv) == GL_FALSE) { + exit(1); + } + + glutInitWindowPosition(0, 0); glutInitWindowSize( 300, 300); + + type = GLUT_DEPTH; + type |= (rgb) ? GLUT_RGB : GLUT_INDEX; + type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("Depth Test") == GL_FALSE) { + exit(1); + } + + InitMap(); + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/samples/eval.c b/progs/samples/eval.c new file mode 100644 index 00000000000..3ad9c5468f8 --- /dev/null +++ b/progs/samples/eval.c @@ -0,0 +1,472 @@ +/* + * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the name of + * Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF + * ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#include +#include +#include +#include +#include + + +#define VORDER 10 +#define CORDER 10 +#define TORDER 3 + +#define VMAJOR_ORDER 2 +#define VMINOR_ORDER 3 + +#define CMAJOR_ORDER 2 +#define CMINOR_ORDER 2 + +#define TMAJOR_ORDER 2 +#define TMINOR_ORDER 2 + +#define VDIM 4 +#define CDIM 4 +#define TDIM 2 + +#define ONE_D 1 +#define TWO_D 2 + +#define EVAL 3 +#define MESH 4 + + +GLenum doubleBuffer; + +float rotX = 0.0, rotY = 0.0, translateZ = -1.0; + +GLenum arrayType = ONE_D; +GLenum colorType = GL_FALSE; +GLenum textureType = GL_FALSE; +GLenum polygonFilled = GL_FALSE; +GLenum lighting = GL_FALSE; +GLenum mapPoint = GL_FALSE; +GLenum mapType = EVAL; + +double point1[10*4] = { + -0.5, 0.0, 0.0, 1.0, + -0.4, 0.5, 0.0, 1.0, + -0.3,-0.5, 0.0, 1.0, + -0.2, 0.5, 0.0, 1.0, + -0.1,-0.5, 0.0, 1.0, + 0.0, 0.5, 0.0, 1.0, + 0.1,-0.5, 0.0, 1.0, + 0.2, 0.5, 0.0, 1.0, + 0.3,-0.5, 0.0, 1.0, + 0.4, 0.0, 0.0, 1.0, +}; +double cpoint1[10*4] = { + 0.0, 0.0, 1.0, 1.0, + 0.3, 0.0, 0.7, 1.0, + 0.6, 0.0, 0.3, 1.0, + 1.0, 0.0, 0.0, 1.0, + 1.0, 0.3, 0.0, 1.0, + 1.0, 0.6, 0.0, 1.0, + 1.0, 1.0, 0.0, 1.0, + 1.0, 1.0, 0.5, 1.0, + 1.0, 1.0, 1.0, 1.0, +}; +double tpoint1[11*4] = { + 0.0, 0.0, 0.0, 1.0, + 0.0, 0.1, 0.0, 1.0, + 0.0, 0.2, 0.0, 1.0, + 0.0, 0.3, 0.0, 1.0, + 0.0, 0.4, 0.0, 1.0, + 0.0, 0.5, 0.0, 1.0, + 0.0, 0.6, 0.0, 1.0, + 0.0, 0.7, 0.0, 1.0, + 0.0, 0.8, 0.0, 1.0, + 0.0, 0.9, 0.0, 1.0, +}; +double point2[2*3*4] = { + -0.5, -0.5, 0.5, 1.0, + 0.0, 1.0, 0.5, 1.0, + 0.5, -0.5, 0.5, 1.0, + -0.5, 0.5, -0.5, 1.0, + 0.0, -1.0, -0.5, 1.0, + 0.5, 0.5, -0.5, 1.0, +}; +double cpoint2[2*2*4] = { + 0.0, 0.0, 0.0, 1.0, + 0.0, 0.0, 1.0, 1.0, + 0.0, 1.0, 0.0, 1.0, + 1.0, 1.0, 1.0, 1.0, +}; +double tpoint2[2*2*2] = { + 0.0, 0.0, 0.0, 1.0, + 1.0, 0.0, 1.0, 1.0, +}; +float textureImage[4*2*4] = { + 1.0, 1.0, 1.0, 1.0, + 1.0, 0.0, 0.0, 1.0, + 1.0, 0.0, 0.0, 1.0, + 1.0, 1.0, 1.0, 1.0, + 1.0, 1.0, 1.0, 1.0, + 1.0, 0.0, 0.0, 1.0, + 1.0, 0.0, 0.0, 1.0, + 1.0, 1.0, 1.0, 1.0, +}; + + +static void Init(void) +{ + static float ambient[] = {0.1, 0.1, 0.1, 1.0}; + static float diffuse[] = {1.0, 1.0, 1.0, 1.0}; + static float position[] = {0.0, 0.0, -150.0, 0.0}; + static float front_mat_diffuse[] = {1.0, 0.2, 1.0, 1.0}; + static float back_mat_diffuse[] = {1.0, 1.0, 0.2, 1.0}; + static float lmodel_ambient[] = {1.0, 1.0, 1.0, 1.0}; + static float lmodel_twoside[] = {GL_TRUE}; + static float decal[] = {GL_DECAL}; + static float repeat[] = {GL_REPEAT}; + static float nr[] = {GL_NEAREST}; + + glFrontFace(GL_CCW); + + glEnable(GL_DEPTH_TEST); + + glMap1d(GL_MAP1_VERTEX_4, 0.0, 1.0, VDIM, VORDER, point1); + glMap1d(GL_MAP1_COLOR_4, 0.0, 1.0, CDIM, CORDER, cpoint1); + + glMap2d(GL_MAP2_VERTEX_4, 0.0, 1.0, VMINOR_ORDER*VDIM, VMAJOR_ORDER, 0.0, + 1.0, VDIM, VMINOR_ORDER, point2); + glMap2d(GL_MAP2_COLOR_4, 0.0, 1.0, CMINOR_ORDER*CDIM, CMAJOR_ORDER, 0.0, + 1.0, CDIM, CMINOR_ORDER, cpoint2); + glMap2d(GL_MAP2_TEXTURE_COORD_2, 0.0, 1.0, TMINOR_ORDER*TDIM, + TMAJOR_ORDER, 0.0, 1.0, TDIM, TMINOR_ORDER, tpoint2); + + glLightfv(GL_LIGHT0, GL_AMBIENT, ambient); + glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse); + glLightfv(GL_LIGHT0, GL_POSITION, position); + + glMaterialfv(GL_FRONT, GL_DIFFUSE, front_mat_diffuse); + glMaterialfv(GL_BACK, GL_DIFFUSE, back_mat_diffuse); + + glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient); + glLightModelfv(GL_LIGHT_MODEL_TWO_SIDE, lmodel_twoside); + + glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, decal); + glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, repeat); + glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, repeat); + glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, nr); + glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, nr); + glTexImage2D(GL_TEXTURE_2D, 0, 4, 2, 4, 0, GL_RGBA, GL_FLOAT, + (GLvoid *)textureImage); +} + +static void DrawPoints1(void) +{ + GLint i; + + glColor3f(0.0, 1.0, 0.0); + glPointSize(2); + glBegin(GL_POINTS); + for (i = 0; i < VORDER; i++) { + glVertex4dv(&point1[i*4]); + } + glEnd(); +} + +static void DrawPoints2(void) +{ + GLint i, j; + + glColor3f(1.0, 0.0, 1.0); + glPointSize(2); + glBegin(GL_POINTS); + for (i = 0; i < VMAJOR_ORDER; i++) { + for (j = 0; j < VMINOR_ORDER; j++) { + glVertex4dv(&point2[i*4*VMINOR_ORDER+j*4]); + } + } + glEnd(); +} + +static void DrawMapEval1(float du) +{ + float u; + + glColor3f(1.0, 0.0, 0.0); + glBegin(GL_LINE_STRIP); + for (u = 0.0; u < 1.0; u += du) { + glEvalCoord1d(u); + } + glEvalCoord1d(1.0); + glEnd(); +} + +static void DrawMapEval2(float du, float dv) +{ + float u, v, tmp; + + glColor3f(1.0, 0.0, 0.0); + for (v = 0.0; v < 1.0; v += dv) { + glBegin(GL_QUAD_STRIP); + for (u = 0.0; u <= 1.0; u += du) { + glEvalCoord2d(u,v); + tmp = (v + dv < 1.0) ? (v + dv) : 1.0; + glEvalCoord2d(u, tmp); + } + glEvalCoord2d(1.0, v); + glEvalCoord2d(1.0, v+dv); + glEnd(); + } +} + +static void RenderEval(void) +{ + + if (colorType) { + glEnable(GL_MAP1_COLOR_4); + glEnable(GL_MAP2_COLOR_4); + } else { + glDisable(GL_MAP1_COLOR_4); + glDisable(GL_MAP2_COLOR_4); + } + + if (textureType) { + glEnable(GL_TEXTURE_2D); + glEnable(GL_MAP2_TEXTURE_COORD_2); + } else { + glDisable(GL_TEXTURE_2D); + glDisable(GL_MAP2_TEXTURE_COORD_2); + } + + if (polygonFilled) { + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); + } else { + glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); + } + + glShadeModel(GL_SMOOTH); + + switch (mapType) { + case EVAL: + switch (arrayType) { + case ONE_D: + glDisable(GL_MAP2_VERTEX_4); + glEnable(GL_MAP1_VERTEX_4); + DrawPoints1(); + DrawMapEval1(0.1/VORDER); + break; + case TWO_D: + glDisable(GL_MAP1_VERTEX_4); + glEnable(GL_MAP2_VERTEX_4); + DrawPoints2(); + DrawMapEval2(0.1/VMAJOR_ORDER,0.1/VMINOR_ORDER); + break; + default: + break; + } + break; + case MESH: + switch (arrayType) { + case ONE_D: + DrawPoints1(); + glDisable(GL_MAP2_VERTEX_4); + glEnable (GL_MAP1_VERTEX_4); + glColor3f(0.0, 0.0, 1.0); + glMapGrid1d(40, 0.0, 1.0); + if (mapPoint) { + glPointSize(2); + glEvalMesh1(GL_POINT, 0, 40); + } else { + glEvalMesh1(GL_LINE, 0, 40); + } + break; + case TWO_D: + DrawPoints2(); + glDisable(GL_MAP1_VERTEX_4); + glEnable(GL_MAP2_VERTEX_4); + glColor3f(0.0, 0.0, 1.0); + glMapGrid2d(20, 0.0, 1.0, 20, 0.0, 1.0); + if (mapPoint) { + glPointSize(2); + glEvalMesh2(GL_POINT, 0, 20, 0, 20); + } else if (polygonFilled) { + glEvalMesh2(GL_FILL, 0, 20, 0, 20); + } else { + glEvalMesh2(GL_LINE, 0, 20, 0, 20); + } + break; + default: + break; + } + break; + default: + break; + } +} + +static void Reshape(int width, int height) +{ + + glViewport(0, 0, (GLint)width, (GLint)height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 10.0); + glMatrixMode(GL_MODELVIEW); +} + +static void Key2(int key, int x, int y) +{ + switch (key) { + case GLUT_KEY_LEFT: + rotY -= 30; + break; + case GLUT_KEY_RIGHT: + rotY += 30; + break; + case GLUT_KEY_UP: + rotX -= 30; + break; + case GLUT_KEY_DOWN: + rotX += 30; + break; + default: + return; + } + + glutPostRedisplay(); +} + +static void Key(unsigned char key, int x, int y) +{ + switch (key) { + case 27: + exit(1); + case '1': + arrayType = ONE_D; + break; + case '2': + arrayType = TWO_D; + break; + case 'e': + mapType = EVAL; + break; + case 'm': + mapType = MESH; + break; + case 'f': + polygonFilled = !polygonFilled; + break; + case 'p': + mapPoint = !mapPoint; + break; + case 'c': + colorType = !colorType; + break; + case 't': + textureType = !textureType; + break; + case 'l': + lighting =! lighting; + if (lighting) { + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + glEnable(GL_AUTO_NORMAL); + } else { + glDisable(GL_LIGHTING); + glDisable(GL_LIGHT0); + glDisable(GL_AUTO_NORMAL); + } + break; + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + + glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); + + glPushMatrix(); + + glTranslatef(0.0, 0.0 , translateZ); + glRotatef(rotX, 1, 0, 0); + glRotatef(rotY, 0, 1, 0); + RenderEval(); + + glPopMatrix(); + + glFlush(); + + if (doubleBuffer) { + glutSwapBuffers(); + } +} + +static GLenum Args(int argc, char **argv) +{ + GLint i; + + doubleBuffer = GL_FALSE; + + for (i = 1; i < argc; i++) { + if (strcmp(argv[i], "-sb") == 0) { + doubleBuffer = GL_FALSE; + } else if (strcmp(argv[i], "-db") == 0) { + doubleBuffer = GL_TRUE; + } else { + printf("%s (Bad option).\n", argv[i]); + return GL_FALSE; + } + } + return GL_TRUE; +} + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + if (Args(argc, argv) == GL_FALSE) { + exit(1); + } + + glutInitWindowPosition(0, 0); glutInitWindowSize( 300, 300); + + type = GLUT_RGB | GLUT_DEPTH; + type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("Evaluator Test") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutSpecialFunc(Key2); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/samples/fog.c b/progs/samples/fog.c new file mode 100644 index 00000000000..3f3ffdbcc7a --- /dev/null +++ b/progs/samples/fog.c @@ -0,0 +1,311 @@ +/* + * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the name of + * Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF + * ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#include +#include +#include +#include + +GLenum rgb, doubleBuffer; + +#include "tkmap.c" + +double plane[4] = { + 1.0, 0.0, -1.0, 0.0 +}; +float rotX = 5.0, rotY = -5.0, zTranslate = -65.0; +float fogDensity = 0.02; +GLint cubeList = 1; + +float scp[18][3] = { + { + 1.000000, 0.000000, 0.000000 + }, + { + 1.000000, 0.000000, 5.000000 + }, + { + 0.707107, 0.707107, 0.000000 + }, + { + 0.707107, 0.707107, 5.000000 + }, + { + 0.000000, 1.000000, 0.000000 + }, + { + 0.000000, 1.000000, 5.000000 + }, + { + -0.707107, 0.707107, 0.000000 + }, + { + -0.707107, 0.707107, 5.000000 + }, + { + -1.000000, 0.000000, 0.000000 + }, + { + -1.000000, 0.000000, 5.000000 + }, + { + -0.707107, -0.707107, 0.000000 + }, + { + -0.707107, -0.707107, 5.000000 + }, + { + 0.000000, -1.000000, 0.000000 + }, + { + 0.000000, -1.000000, 5.000000 + }, + { + 0.707107, -0.707107, 0.000000 + }, + { + 0.707107, -0.707107, 5.000000 + }, + { + 1.000000, 0.000000, 0.000000 + }, + { + 1.000000, 0.000000, 5.000000 + }, +}; + + +static void Build_lists(void) +{ + + glNewList(cubeList, GL_COMPILE); + glBegin(GL_TRIANGLE_STRIP); + glNormal3fv(scp[0]); glVertex3fv(scp[0]); + glNormal3fv(scp[0]); glVertex3fv(scp[1]); + glNormal3fv(scp[2]); glVertex3fv(scp[2]); + glNormal3fv(scp[2]); glVertex3fv(scp[3]); + glNormal3fv(scp[4]); glVertex3fv(scp[4]); + glNormal3fv(scp[4]); glVertex3fv(scp[5]); + glNormal3fv(scp[6]); glVertex3fv(scp[6]); + glNormal3fv(scp[6]); glVertex3fv(scp[7]); + glNormal3fv(scp[8]); glVertex3fv(scp[8]); + glNormal3fv(scp[8]); glVertex3fv(scp[9]); + glNormal3fv(scp[10]); glVertex3fv(scp[10]); + glNormal3fv(scp[10]); glVertex3fv(scp[11]); + glNormal3fv(scp[12]); glVertex3fv(scp[12]); + glNormal3fv(scp[12]); glVertex3fv(scp[13]); + glNormal3fv(scp[14]); glVertex3fv(scp[14]); + glNormal3fv(scp[14]); glVertex3fv(scp[15]); + glNormal3fv(scp[16]); glVertex3fv(scp[16]); + glNormal3fv(scp[16]); glVertex3fv(scp[17]); + glEnd(); + glEndList(); +} + +static void Init(void) +{ + static float ambient[] = {0.1, 0.1, 0.1, 1.0}; + static float diffuse[] = {1.0, 1.0, 1.0, 1.0}; + static float position[] = {90.0, 90.0, 0.0, 0.0}; + static float front_mat_shininess[] = {30.0}; + static float front_mat_specular[] = {0.0, 0.0, 0.0, 1.0}; + static float front_mat_diffuse[] = {0.0, 1.0, 0.0, 1.0}; + static float back_mat_shininess[] = {50.0}; + static float back_mat_specular[] = {0.0, 0.0, 1.0, 1.0}; + static float back_mat_diffuse[] = {1.0, 0.0, 0.0, 1.0}; + static float lmodel_ambient[] = {0.0, 0.0, 0.0, 1.0}; + static float fog_color[] = {0.8, 0.8, 0.8, 1.0}; + + glFrontFace(GL_CW); + + glEnable(GL_DEPTH_TEST); + + glLightfv(GL_LIGHT0, GL_AMBIENT, ambient); + glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse); + glLightfv(GL_LIGHT0, GL_POSITION, position); + glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient); + glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE); + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + + glMaterialfv(GL_FRONT, GL_SHININESS, front_mat_shininess); + glMaterialfv(GL_FRONT, GL_SPECULAR, front_mat_specular); + glMaterialfv(GL_FRONT, GL_DIFFUSE, front_mat_diffuse); + glMaterialfv(GL_BACK, GL_SHININESS, back_mat_shininess); + glMaterialfv(GL_BACK, GL_SPECULAR, back_mat_specular); + glMaterialfv(GL_BACK, GL_DIFFUSE, back_mat_diffuse); + + glEnable(GL_FOG); + glFogi(GL_FOG_MODE, GL_EXP); + glFogf(GL_FOG_DENSITY, fogDensity); + if (rgb) { + glFogfv(GL_FOG_COLOR, fog_color); + glClearColor(0.8, 0.8, 0.8, 1.0); + } else { + glFogi(GL_FOG_INDEX, 1<<5); + SetFogRamp(5, 3); + glClearIndex(128); + } + + Build_lists(); +} + +static void Reshape(int width, int height) +{ + + glViewport(0, 0, (GLint)width, (GLint)height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluPerspective(45.0, 1.0, 1.0, 200.0); + glMatrixMode(GL_MODELVIEW); +} + +static void Key2(int key, int x, int y) +{ + + switch (key) { + case GLUT_KEY_UP: + rotX -= 5; + break; + case GLUT_KEY_DOWN: + rotX += 5; + break; + case GLUT_KEY_LEFT: + rotY -= 5; + break; + case GLUT_KEY_RIGHT: + rotY += 5; + break; + default: + return; + } + + glutPostRedisplay(); +} + +static void Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + case 'D': + if (rgb) { + fogDensity *= 1.10; + glFogf(GL_FOG_DENSITY, fogDensity); + } + break; + case 'd': + if (rgb) { + fogDensity /= 1.10; + glFogf(GL_FOG_DENSITY, fogDensity); + } + break; + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + + glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); + + glPushMatrix(); + + glTranslatef(0, 0, zTranslate); + glRotatef(rotY, 0,1,0); + glRotatef(rotX, 1,0,0); + glScalef(1.0, 1.0, 10.0); + + glCallList(cubeList); + + glPopMatrix(); + + glFlush(); + + if (doubleBuffer) { + glutSwapBuffers(); + } +} + +static GLenum Args(int argc, char **argv) +{ + GLint i; + + rgb = GL_TRUE; + doubleBuffer = GL_TRUE; + + for (i = 1; i < argc; i++) { + if (strcmp(argv[i], "-ci") == 0) { + rgb = GL_FALSE; + } else if (strcmp(argv[i], "-rgb") == 0) { + rgb = GL_TRUE; + } else 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; +} + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + if (Args(argc, argv) == GL_FALSE) { + exit(1); + } + + glutInitWindowPosition(0, 0); glutInitWindowSize( 300, 300); + + type = GLUT_DEPTH; + type |= (rgb) ? GLUT_RGB : GLUT_INDEX; + type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("Fog Test") == GL_FALSE) { + exit(1); + } + + InitMap(); + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutSpecialFunc(Key2); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/samples/font.c b/progs/samples/font.c new file mode 100644 index 00000000000..a0091a65d79 --- /dev/null +++ b/progs/samples/font.c @@ -0,0 +1,273 @@ +/* + * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the name of + * Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF + * ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#include +#include +#include +#include + + +#define OPENGL_WIDTH 24 +#define OPENGL_HEIGHT 13 + + +char string[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz"; +GLenum rgb, doubleBuffer, windType; +float angleX = 0.0, angleY = 0.0, angleZ = 0.0; +float scaleX = 1.0, scaleY = 1.0, scaleZ = 1.0; +float shiftX = 0.0, shiftY = 0.0, shiftZ = 0.0; + + +#include "tkmap.c" + + +static void DrawBitmapString(void *font, const char *string) +{ + int i; + + for (i = 0; string[i]; i++) + glutBitmapCharacter(font, string[i]); +} + +static void DrawStrokeString(void *font, const char *string) +{ + int i; + + for (i = 0; string[i]; i++) + glutStrokeCharacter(font, string[i]); +} + +static void Init(void) +{ + + glClearColor(0.0, 0.0, 0.0, 0.0); + glClearIndex(0.0); +} + +static void Reshape(int width, int height) +{ + + glViewport(0, 0, (GLint)width, (GLint)height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-400.0, 400.0, -200.0, 200.0, -400.0, 400.0); + glMatrixMode(GL_MODELVIEW); +} + +static void Key2(int key, int x, int y) +{ + + switch (key) { + case GLUT_KEY_LEFT: + shiftX -= 20.0; + break; + case GLUT_KEY_RIGHT: + shiftX += 20.0; + break; + case GLUT_KEY_UP: + shiftY += 20.0; + break; + case GLUT_KEY_DOWN: + shiftY -= 20.0; + break; + default: + return; + } + + glutPostRedisplay(); +} + +static void Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + + case 'n': + shiftZ += 20.0; + break; + case 'm': + shiftZ -= 20.0; + break; + + case 'q': + scaleX -= 0.1; + if (scaleX < 0.1) { + scaleX = 0.1; + } + break; + case 'w': + scaleX += 0.1; + break; + case 'a': + scaleY -= 0.1; + if (scaleY < 0.1) { + scaleY = 0.1; + } + break; + case 's': + scaleY += 0.1; + break; + case 'z': + scaleZ -= 0.1; + if (scaleZ < 0.1) { + scaleZ = 0.1; + } + break; + case 'x': + scaleZ += 0.1; + break; + + case 'e': + angleX -= 5.0; + if (angleX < 0.0) { + angleX = 360.0 + angleX; + } + break; + case 'r': + angleX += 5.0; + if (angleX > 360.0) { + angleX = angleX - 360.0; + } + break; + case 'd': + angleY -= 5.0; + if (angleY < 0.0) { + angleY = 360.0 + angleY; + } + break; + case 'f': + angleY += 5.0; + if (angleY > 360.0) { + angleY = angleY - 360.0; + } + break; + case 'c': + angleZ -= 5.0; + if (angleZ < 0.0) { + angleZ = 360.0 + angleZ; + } + break; + case 'v': + angleZ += 5.0; + if (angleZ > 360.0) { + angleZ = angleZ - 360.0; + } + break; + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + + glClear(GL_COLOR_BUFFER_BIT); + + SetColor(COLOR_WHITE); + + glPushMatrix(); + + glTranslatef(shiftX, shiftY, shiftZ); + glRotatef(angleX, 1.0, 0.0, 0.0); + glRotatef(angleY, 0.0, 1.0, 0.0); + glRotatef(angleZ, 0.0, 0.0, 1.0); + glScalef(scaleX, scaleY, scaleZ); + + glPushMatrix(); + glRasterPos2f(-390.5, 0.5); + DrawBitmapString(GLUT_BITMAP_9_BY_15, string); + glPopMatrix(); + + glPushMatrix(); + glTranslatef(-390.5, -30.5, 0.0); + DrawStrokeString(GLUT_STROKE_ROMAN, string); + glPopMatrix(); + + glPopMatrix(); + + glFlush(); + + if (doubleBuffer) { + glutSwapBuffers(); + } +} + +static GLenum Args(int argc, char **argv) +{ + GLint i; + + rgb = GL_TRUE; + doubleBuffer = GL_FALSE; + + for (i = 1; i < argc; i++) { + if (strcmp(argv[i], "-ci") == 0) { + rgb = GL_FALSE; + } else if (strcmp(argv[i], "-rgb") == 0) { + rgb = GL_TRUE; + } else 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; +} + +int main(int argc, char **argv) +{ + glutInit(&argc, argv); + + if (Args(argc, argv) == GL_FALSE) { + exit(1); + } + + glutInitWindowPosition(0, 0); glutInitWindowSize( 800, 400); + + windType = (rgb) ? GLUT_RGB : GLUT_INDEX; + windType |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; + glutInitDisplayMode(windType); + + if (glutCreateWindow("Font Test") == GL_FALSE) { + exit(1); + } + + InitMap(); + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutSpecialFunc(Key2); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/samples/line.c b/progs/samples/line.c new file mode 100644 index 00000000000..83f70cb3ac4 --- /dev/null +++ b/progs/samples/line.c @@ -0,0 +1,219 @@ +/* + * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the name of + * Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF + * ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#include +#include +#include +#include + + +#define CI_OFFSET 16 + + +GLenum rgb, doubleBuffer, windType; + +GLenum mode1, mode2; +GLint size; +float pntA[3] = { + -160.0, 0.0, 0.0 +}; +float pntB[3] = { + -130.0, 0.0, 0.0 +}; +float pntC[3] = { + -40.0, -50.0, 0.0 +}; +float pntD[3] = { + 30.0, 60.0, 0.0 +}; + + +#include "tkmap.c" + +static void Init(void) +{ + GLint i; + + glClearColor(0.0, 0.0, 0.0, 0.0); + + glLineStipple(1, 0xF0E0); + glBlendFunc(GL_SRC_ALPHA, GL_ONE); + + if (!rgb) { + for (i = 0; i < 16; i++) { + glutSetColor(i+CI_OFFSET, i/15.0, i/15.0, 0.0); + } + } + + mode1 = GL_FALSE; + mode2 = GL_FALSE; + size = 1; +} + +static void Reshape(int width, int height) +{ + + glViewport(0, 0, (GLint)width, (GLint)height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluOrtho2D(-175, 175, -175, 175); + glMatrixMode(GL_MODELVIEW); +} + +static void Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + case '1': + mode1 = !mode1; + break; + case '2': + mode2 = !mode2; + break; + case 'W': + size++; + break; + case 'w': + size--; + if (size < 1) { + size = 1; + } + break; + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + GLint ci, i; + + glClear(GL_COLOR_BUFFER_BIT); + + glLineWidth(size); + + if (mode1) { + glEnable(GL_LINE_STIPPLE); + } else { + glDisable(GL_LINE_STIPPLE); + } + + if (mode2) { + ci = CI_OFFSET; + glEnable(GL_LINE_SMOOTH); + glEnable(GL_BLEND); + } else { + ci = COLOR_YELLOW; + glDisable(GL_LINE_SMOOTH); + glDisable(GL_BLEND); + } + + glPushMatrix(); + + glShadeModel( GL_FLAT ); + + for (i = 0; i < 360; i += 5) { + glRotatef(5.0, 0,0,1); + + (rgb) ? glColor3f(1.0, 1.0, 0.0) : glIndexi(ci); + glBegin(GL_LINE_STRIP); + glVertex3fv(pntA); + glVertex3fv(pntB); + glEnd(); + + glPointSize(1); + + SetColor(COLOR_GREEN); + glBegin(GL_POINTS); + glVertex3fv(pntA); + glVertex3fv(pntB); + glEnd(); + } + + glPopMatrix(); + + glFlush(); + + if (doubleBuffer) { + glutSwapBuffers(); + } +} + +static GLenum Args(int argc, char **argv) +{ + GLint i; + + rgb = GL_TRUE; + doubleBuffer = GL_TRUE; + + for (i = 1; i < argc; i++) { + if (strcmp(argv[i], "-ci") == 0) { + rgb = GL_FALSE; + } else if (strcmp(argv[i], "-rgb") == 0) { + rgb = GL_TRUE; + } else 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; +} + +int main(int argc, char **argv) +{ + glutInit(&argc, argv); + + if (Args(argc, argv) == GL_FALSE) { + exit(1); + } + + glutInitWindowPosition(0, 0); glutInitWindowSize( 300, 300); + + windType = (rgb) ? GLUT_RGB : GLUT_INDEX; + windType |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; + glutInitDisplayMode(windType); + + if (glutCreateWindow("Line Test") == GL_FALSE) { + exit(1); + } + + InitMap(); + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/samples/loadppm.c b/progs/samples/loadppm.c new file mode 100644 index 00000000000..be056d62940 --- /dev/null +++ b/progs/samples/loadppm.c @@ -0,0 +1,72 @@ + +typedef struct { + size_t sizeX, sizeY; + GLubyte *data; +} PPMImage; + +static PPMImage *LoadPPM(const char *filename) +{ + char buff[16]; + PPMImage *result; + FILE *fp; + int maxval; + + fp = fopen(filename, "rb"); + if (!fp) + { + fprintf(stderr, "Unable to open file `%s'\n", filename); + exit(1); + } + + if (!fgets(buff, sizeof(buff), fp)) + { + perror(filename); + exit(1); + } + + if (buff[0] != 'P' || buff[1] != '6') + { + fprintf(stderr, "Invalid image format (must be `P6')\n"); + exit(1); + } + + result = (PPMImage *) malloc(sizeof(PPMImage)); + if (!result) + { + fprintf(stderr, "Unable to allocate memory\n"); + exit(1); + } + + if (fscanf(fp, "%lu %lu", &result->sizeX, &result->sizeY) != 2) + { + fprintf(stderr, "Error loading image `%s'\n", filename); + exit(1); + } + + if (fscanf(fp, "%d", &maxval) != 1) + { + fprintf(stderr, "Error loading image `%s'\n", filename); + exit(1); + } + + while (fgetc(fp) != '\n') + ; + + result->data = (GLubyte *) malloc(3 * result->sizeX * result->sizeY); + if (!result) + { + fprintf(stderr, "Unable to allocate memory\n"); + exit(1); + } + + if (fread(result->data, 3 * result->sizeX, result->sizeY, fp) != result->sizeY) + { + fprintf(stderr, "Error loading image `%s'\n", filename); + exit(1); + } + + fclose(fp); + + return result; +} + diff --git a/progs/samples/logo.c b/progs/samples/logo.c new file mode 100644 index 00000000000..ae74af685a7 --- /dev/null +++ b/progs/samples/logo.c @@ -0,0 +1,1635 @@ + +/* + * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the name of + * Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF + * ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#include +#include +#include +#include + + +#define PI 3.141592654 + +#define BLACK 0 +#define GRAY 128 +#define WHITE 255 +#define BL 0x00 +#define WH 0xFF +#define RD 0xA4,0x00,0x00,0xFF +#define WT 0xFF,0xFF,0xFF,0xFF + +#define CHECKIMAGEWIDTH 8 +#define CHECKIMAGEHEIGHT 8 +#define BRICKIMAGEWIDTH 16 +#define BRICKIMAGEHEIGHT 16 + + +GLenum rgb, doubleBuffer; + +#include "tkmap.c" + +float black[3] = {0.0, 0.0, 0.0}; +float white[3] = {1.0, 1.0, 1.0}; +float gray[3] = {0.5, 0.5, 0.5}; +float blue[3] = {0.0, 0.0, 1.0}; +GLint colorIndexes[3] = {0, 200, 255}; + +GLenum polyMode; +GLboolean dithering; +GLboolean shade; +GLboolean doStipple; +GLboolean noDraw = 0; +GLboolean LineSmooth = GL_FALSE; + +double plane[4] = {1.0, 0.0, -1.0, 0.0}; +float xRotation = 30.0, yRotation = 30.0; +float zTranslation = -15.0; + +GLint singleCylinder; +GLint doubleCylinder; +GLint elbow, logo; + +GLubyte checkImage[3*CHECKIMAGEWIDTH*CHECKIMAGEHEIGHT] = { + BL, BL, BL, WH, WH, WH, BL, BL, BL, WH, WH, WH, BL, BL, BL, WH, + WH, WH, BL, BL, BL, WH, WH, WH, WH, WH, WH, BL, BL, BL, WH, WH, + WH, BL, BL, BL, WH, WH, WH, BL, BL, BL, WH, WH, WH, BL, BL, BL, + BL, BL, BL, WH, WH, WH, BL, BL, BL, WH, WH, WH, BL, BL, BL, WH, + WH, WH, BL, BL, BL, WH, WH, WH, WH, WH, WH, BL, BL, BL, WH, WH, + WH, BL, BL, BL, WH, WH, WH, BL, BL, BL, WH, WH, WH, BL, BL, BL, + BL, BL, BL, WH, WH, WH, BL, BL, BL, WH, WH, WH, BL, BL, BL, WH, + WH, WH, BL, BL, BL, WH, WH, WH, WH, WH, WH, BL, BL, BL, WH, WH, + WH, BL, BL, BL, WH, WH, WH, BL, BL, BL, WH, WH, WH, BL, BL, BL, + BL, BL, BL, WH, WH, WH, BL, BL, BL, WH, WH, WH, BL, BL, BL, WH, + WH, WH, BL, BL, BL, WH, WH, WH, WH, WH, WH, BL, BL, BL, WH, WH, + WH, BL, BL, BL, WH, WH, WH, BL, BL, BL, WH, WH, WH, BL, BL, BL, +}; +GLubyte brickImage[4*BRICKIMAGEWIDTH*BRICKIMAGEHEIGHT] = { + RD, RD, RD, RD, RD, RD, RD, RD, RD, WT, RD, RD, RD, RD, RD, RD, + RD, RD, RD, RD, RD, RD, RD, RD, RD, WT, RD, RD, RD, RD, RD, RD, + RD, RD, RD, RD, RD, RD, RD, RD, RD, WT, RD, RD, RD, RD, RD, RD, + RD, RD, RD, RD, RD, RD, RD, RD, RD, WT, RD, RD, RD, RD, RD, RD, + WT, WT, WT, WT, WT, WT, WT, WT, WT, WT, WT, WT, WT, WT, WT, WT, + RD, RD, RD, WT, RD, RD, RD, RD, RD, RD, RD, RD, RD, WT, RD, RD, + RD, RD, RD, WT, RD, RD, RD, RD, RD, RD, RD, RD, RD, WT, RD, RD, + RD, RD, RD, WT, RD, RD, RD, RD, RD, RD, RD, RD, RD, WT, RD, RD, + RD, RD, RD, WT, RD, RD, RD, RD, RD, RD, RD, RD, RD, WT, RD, RD, + WT, WT, WT, WT, WT, WT, WT, WT, WT, WT, WT, WT, WT, WT, WT, WT, + RD, RD, RD, RD, RD, RD, RD, WT, RD, RD, RD, RD, RD, RD, RD, RD, + RD, RD, RD, RD, RD, RD, RD, WT, RD, RD, RD, RD, RD, RD, RD, RD, + RD, RD, RD, RD, RD, RD, RD, WT, RD, RD, RD, RD, RD, RD, RD, RD, + RD, RD, RD, RD, RD, RD, RD, WT, RD, RD, RD, RD, RD, RD, RD, RD, + WT, WT, WT, WT, WT, WT, WT, WT, WT, WT, WT, WT, WT, WT, WT, WT, + RD, RD, RD, RD, WT, RD, RD, RD, RD, RD, RD, RD, RD, RD, WT, RD +}; + +GLubyte *image = checkImage; +GLint imageHeight = CHECKIMAGEHEIGHT; +GLint imageWidth = CHECKIMAGEWIDTH; + +static float decal[] = { + GL_DECAL, +}; +static float modulate[] = { + GL_MODULATE, +}; +static float repeat[] = { + GL_REPEAT, +}; +static float nearest[] = { + GL_NEAREST, +}; + +GLubyte stipple[4*32] = { + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + + 0x00, 0x0F, 0xF0, 0x00, + 0x00, 0x0F, 0xF0, 0x00, + 0x00, 0x0F, 0xF0, 0x00, + 0x00, 0x0F, 0xF0, 0x00, + 0x00, 0x0F, 0xF0, 0x00, + 0x00, 0x0F, 0xF0, 0x00, + 0x00, 0x0F, 0xF0, 0x00, + 0x00, 0x0F, 0xF0, 0x00, + + 0x00, 0x0F, 0xF0, 0x00, + 0x00, 0x0F, 0xF0, 0x00, + 0x00, 0x0F, 0xF0, 0x00, + 0x00, 0x0F, 0xF0, 0x00, + 0x00, 0x0F, 0xF0, 0x00, + 0x00, 0x0F, 0xF0, 0x00, + 0x00, 0x0F, 0xF0, 0x00, + 0x00, 0x0F, 0xF0, 0x00, + + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, +}; + +float tscp[18][2] = { + { + 0.0, 0.0 + }, + { + 1.0, 0.0 + }, + { + 0.0, 0.125 + }, + { + 1.0, 0.125 + }, + { + 0.0, 0.250 + }, + { + 1.0, 0.25 + }, + { + 0.0, 0.375 + }, + { + 1.0, 0.375 + }, + { + 0.0, 0.50 + }, + { + 1.0, 0.50 + }, + { + 0.0, 0.625 + }, + { + 1.0, 0.625 + }, + { + 0.0, 0.75 + }, + { + 1.0, 0.75 + }, + { + 0.0, 0.875 + }, + { + 1.0, 0.875 + }, + { + 0.0, 1.0 + }, + { + 1.0, 1.0 + } +}; +float scp[18][3] = { + { + 1.000000, 0.000000, 0.000000 + }, + { + 1.000000, 0.000000, 5.000000 + }, + { + 0.707107, 0.707107, 0.000000 + }, + { + 0.707107, 0.707107, 5.000000 + }, + { + 0.000000, 1.000000, 0.000000 + }, + { + 0.000000, 1.000000, 5.000000 + }, + { + -0.707107, 0.707107, 0.000000 + }, + { + -0.707107, 0.707107, 5.000000 + }, + { + -1.000000, 0.000000, 0.000000 + }, + { + -1.000000, 0.000000, 5.000000 + }, + { + -0.707107, -0.707107, 0.000000 + }, + { + -0.707107, -0.707107, 5.000000 + }, + { + 0.000000, -1.000000, 0.000000 + }, + { + 0.000000, -1.000000, 5.000000 + }, + { + 0.707107, -0.707107, 0.000000 + }, + { + 0.707107, -0.707107, 5.000000 + }, + { + 1.000000, 0.000000, 0.000000 + }, + { + 1.000000, 0.000000, 5.000000 + } +}; +float dcp[18][3] = { + { + 1.000000, 0.000000, 0.000000 + }, + { + 1.000000, 0.000000, 7.000000 + }, + { + 0.707107, 0.707107, 0.000000 + }, + { + 0.707107, 0.707107, 7.000000 + }, + { + 0.000000, 1.000000, 0.000000 + }, + { + 0.000000, 1.000000, 7.000000 + }, + { + -0.707107, 0.707107, 0.000000 + }, + { + -0.707107, 0.707107, 7.000000 + }, + { + -1.000000, 0.000000, 0.000000 + }, + { + -1.000000, 0.000000, 7.000000 + }, + { + -0.707107, -0.707107, 0.000000 + }, + { + -0.707107, -0.707107, 7.000000 + }, + { + 0.000000, -1.000000, 0.000000 + }, + { + 0.000000, -1.000000, 7.000000 + }, + { + 0.707107, -0.707107, 0.000000 + }, + { + 0.707107, -0.707107, 7.000000 + }, + { + 1.000000, 0.000000, 0.000000 + }, + { + 1.000000, 0.000000, 7.000000 + } +}; +float ep[7][9][3] = { + { + { + 1.000000, 0.000000, 0.000000 + }, + { + 0.707107, 0.707107, 0.000000 + }, + { + 0.000000, 1.000000, 0.000000 + }, + { + -0.707107, 0.707107, 0.000000 + }, + { + -1.000000, 0.000000, 0.000000 + }, + { + -0.707107, -0.707107, 0.000000 + }, + { + 0.000000, -1.000000, 0.000000 + }, + { + 0.707107, -0.707107, 0.000000 + }, + { + 1.000000, 0.000000, 0.000000 + } + }, + { + { + 1.000000, 0.034074, 0.258819 + }, + { + 0.707107, 0.717087, 0.075806 + }, + { + 0.000000, 1.000000, 0.000000 + }, + { + -0.707107, 0.717087, 0.075806 + }, + { + -1.000000, 0.034074, 0.258819 + }, + { + -0.707107, -0.648939, 0.441832 + }, + { + 0.000000, -0.931852, 0.517638 + }, + { + 0.707107, -0.648939, 0.441832 + }, + { + 1.000000, 0.034074, 0.258819 + } + }, + { + { + 1.000000, 0.133975, 0.500000 + }, + { + 0.707107, 0.746347, 0.146447 + }, + { + 0.000000, 1.000000, 0.000000 + }, + { + -0.707107, 0.746347, 0.146447 + }, + { + -1.000000, 0.133975, 0.500000 + }, + { + -0.707107, -0.478398, 0.853553 + }, + { + 0.000000, -0.732051, 1.000000 + }, + { + 0.707107, -0.478398, 0.853553 + }, + { + 1.000000, 0.133975, 0.500000 + } + }, + { + { + 1.000000, 0.292893, 0.707107 + }, + { + 0.707107, 0.792893, 0.207107 + }, + { + 0.000000, 1.000000, 0.000000 + }, + { + -0.707107, 0.792893, 0.207107 + }, + { + -1.000000, 0.292893, 0.707107 + }, + { + -0.707107, -0.207107, 1.207107 + }, + { + 0.000000, -0.414214, 1.414214 + }, + { + 0.707107, -0.207107, 1.207107 + }, + { + 1.000000, 0.292893, 0.707107 + } + }, + { + { + 1.000000, 0.500000, 0.866025 + }, + { + 0.707107, 0.853553, 0.253653 + }, + { + 0.000000, 1.000000, 0.000000 + }, + { + -0.707107, 0.853553, 0.253653 + }, + { + -1.000000, 0.500000, 0.866025 + }, + { + -0.707107, 0.146447, 1.478398 + }, + { + 0.000000, 0.000000, 1.732051 + }, + { + 0.707107, 0.146447, 1.478398 + }, + { + 1.000000, 0.500000, 0.866025 + } + }, + { + { + 1.000000, 0.741181, 0.965926 + }, + { + 0.707107, 0.924194, 0.282913 + }, + { + 0.000000, 1.000000, 0.000000 + }, + { + -0.707107, 0.924194, 0.282913 + }, + { + -1.000000, 0.741181, 0.965926 + }, + { + -0.707107, 0.558168, 1.648939 + }, + { + 0.000000, 0.482362, 1.931852 + }, + { + 0.707107, 0.558168, 1.648939 + }, + { + 1.000000, 0.741181, 0.965926 + } + }, + { + { + 1.000000, 1.000000, 1.000000 + }, + { + 0.707107, 1.000000, 0.292893 + }, + { + 0.000000, 1.000000, 0.000000 + }, + { + -0.707107, 1.000000, 0.292893 + }, + { + -1.000000, 1.000000, 1.000000 + }, + { + -0.707107, 1.000000, 1.707107 + }, + { + 0.000000, 1.000000, 2.000000 + }, + { + 0.707107, 1.000000, 1.707107 + }, + { + 1.000000, 1.000000, 1.000000 + } + } +}; +float en[7][9][3] = { + { + { + 1.000000, 0.000000, 0.000000 + }, + { + 0.707107, 0.707107, 0.000000 + }, + { + 0.000000, 1.000000, 0.000000 + }, + { + -0.707107, 0.707107, 0.000000 + }, + { + -1.000000, 0.000000, 0.000000 + }, + { + -0.707107, -0.707107, 0.000000 + }, + { + 0.000000, -1.000000, 0.000000 + }, + { + 0.707107, -0.707107, 0.000000 + }, + { + 1.000000, 0.000000, 0.000000 + } + }, + { + { + 1.000000, 0.000000, 0.000000 + }, + { + 0.707107, 0.683013, -0.183013 + }, + { + 0.000000, 0.965926, -0.258819 + }, + { + -0.707107, 0.683013, -0.183013 + }, + { + -1.000000, 0.000000, 0.000000 + }, + { + -0.707107, -0.683013, 0.183013 + }, + { + 0.000000, -0.965926, 0.258819 + }, + { + 0.707107, -0.683013, 0.183013 + }, + { + 1.000000, 0.000000, 0.000000 + } + }, + { + { + 1.000000, 0.000000, 0.000000 + }, + { + 0.707107, 0.612372, -0.353553 + }, + { + 0.000000, 0.866025, -0.500000 + }, + { + -0.707107, 0.612372, -0.353553 + }, + { + -1.000000, 0.000000, 0.000000 + }, + { + -0.707107, -0.612372, 0.353553 + }, + { + 0.000000, -0.866025, 0.500000 + }, + { + 0.707107, -0.612372, 0.353553 + }, + { + 1.000000, 0.000000, 0.000000 + } + }, + { + { + 1.000000, 0.000000, 0.000000 + }, + { + /* These 3 lines added by BEP */ + 0.707107, 0.500000, -0.500000 + }, + { + 0.000000, 0.707107, -0.707107 + }, + { + -0.707107, 0.500000, -0.500000 + }, + { + -1.000000, 0.000000, 0.000000 + }, + { + -0.707107, -0.500000, 0.500000 + }, + { + 0.000000, -0.707107, 0.707107 + }, + { + 0.707107, -0.500000, 0.500000 + }, + { + 1.000000, 0.000000, 0.000000 + } + }, + { + { + 1.000000, 0.000000, 0.000000 + }, + { + 0.707107, 0.353553, -0.612372 + }, + { + 0.000000, 0.500000, -0.866025 + }, + { + -0.707107, 0.353553, -0.612372 + }, + { + -1.000000, 0.000000, 0.000000 + }, + { + -0.707107, -0.353553, 0.612372 + }, + { + 0.000000, -0.500000, 0.866025 + }, + { + 0.707107, -0.353553, 0.612372 + }, + { + 1.000000, 0.000000, 0.000000 + } + }, + { + { + 1.000000, 0.000000, 0.000000 + }, + { + 0.707107, 0.183013, -0.683013 + }, + { + 0.000000, 0.258819, -0.965926 + }, + { + -0.707107, 0.183013, -0.683013 + }, + { + -1.000000, 0.000000, 0.000000 + }, + { + -0.707107, -0.183013, 0.683013 + }, + { + 0.000000, -0.258819, 0.965926 + }, + { + 0.707107, -0.183013, 0.683013 + }, + { + 1.000000, 0.000000, 0.000000 + } + }, + { + { + 1.000000, 0.000000, 0.000000 + }, + { + 0.707107, 0.000000, -0.707107 + }, + { + 0.000000, 0.000000, -1.000000 + }, + { + -0.707107, 0.000000, -0.707107 + }, + { + -1.000000, 0.000000, 0.000000 + }, + { + -0.707107, 0.000000, 0.707107 + }, + { + 0.000000, 0.000000, 1.000000 + }, + { + 0.707107, 0.000000, 0.707107 + }, + { + 1.000000, 0.000000, 0.000000 + } + } +}; +float tep[7][9][2] = { + { + { + 0, 0.0 + }, + { + 0.125, 0.0 + }, + { + 0.25, 0.0 + }, + { + 0.375, 0.0 + }, + { + 0.5, 0.0 + }, + { + 0.625, 0.0 + }, + { + 0.75, 0.0 + }, + { + 0.875, 0.0 + }, + { + 1.0, 0.0 + } + }, + { + { + 0, 0.16667 + }, + { + 0.125, 0.16667 + }, + { + 0.25, 0.16667 + }, + { + 0.375, 0.16667 + }, + { + 0.5, 0.16667 + }, + { + 0.625, 0.16667 + }, + { + 0.75, 0.16667 + }, + { + 0.875, 0.16667 + }, + { + 1.0, 0.16667 + } + }, + { + { + 0, 0.33333 + }, + { + 0.125, 0.33333 + }, + { + 0.25, 0.33333 + }, + { + 0.375, 0.33333 + }, + { + 0.5, 0.33333 + }, + { + 0.625, 0.33333 + }, + { + 0.75, 0.33333 + }, + { + 0.875, 0.33333 + }, + { + 1.0, 0.33333 + } + }, + { + { + 0, 0.5 + }, + { + 0.125, 0.5 + }, + { + 0.25, 0.5 + }, + { + 0.375, 0.5 + }, + { + 0.5, 0.5 + }, + { + 0.625, 0.5 + }, + { + 0.75, 0.5 + }, + { + 0.875, 0.5 + }, + { + 1.0, 0.5 + } + }, + { + { + 0, 0.6667 + }, + { + 0.125, 0.6667 + }, + { + 0.25, 0.6667 + }, + { + 0.375, 0.6667 + }, + { + 0.5, 0.6667 + }, + { + 0.625, 0.6667 + }, + { + 0.75, 0.6667 + }, + { + 0.875, 0.6667 + }, + { + 1.0, 0.6667 + } + }, + { + { + 0, 0.83333 + }, + { + 0.125, 0.83333 + }, + { + 0.25, 0.83333 + }, + { + 0.375, 0.83333 + }, + { + 0.5, 0.83333 + }, + { + 0.625, 0.83333 + }, + { + 0.75, 0.83333 + }, + { + 0.875, 0.83333 + }, + { + 1.0, 0.83333 + } + }, + { + { + 0, 1.0 + }, + { + 0.125, 1.0 + }, + { + 0.25, 1.0 + }, + { + 0.375, 1.0 + }, + { + 0.5, 1.0 + }, + { + 0.625, 1.0 + }, + { + 0.75, 1.0 + }, + { + 0.875, 1.0 + }, + { + 1.0, 1.0 + } + } +}; + + +static void SetUpAntiAliasedGrayScale(void) +{ + float color; + GLint i, j; + + for (i = 0; i < 16; i++) { + color = (2 * i + 1) / 32.0; + for (j = 0; j < 16; j++) { + glutSetColor(i*16+j, color*j/15.0, color*j/15.0, color*j/15.0); + } + } +} + +static void BendForward(void) +{ + + glTranslatef(0.0, 1.0, 0.0); + glRotatef(90.0, 1, 0, 0); + glTranslatef(0.0, -1.0, 0.0); +} + +static void BendLeft(void) +{ + + glRotatef(-90.0, 0, 0, 1); + glTranslatef(0.0, 1.0, 0.0); + glRotatef(90.0, 1, 0, 0); + glTranslatef(0.0, -1.0, 0.0); +} + +static void BendRight(void) +{ + + glRotatef(90.0, 0, 0, 1); + glTranslatef(0.0, 1.0, 0.0); + glRotatef(90.0, 1, 0, 0); + glTranslatef(0.0, -1.0, 0.0); +} + +static void BuildSingleCylinder(void) +{ + + glNewList(singleCylinder, GL_COMPILE); + + glBegin(GL_TRIANGLE_STRIP); + glNormal3fv(scp[0]); glTexCoord2fv(tscp[0]); glVertex3fv(scp[0]); + glNormal3fv(scp[0]); glTexCoord2fv(tscp[1]); glVertex3fv(scp[1]); + glNormal3fv(scp[2]); glTexCoord2fv(tscp[2]); glVertex3fv(scp[2]); + glNormal3fv(scp[2]); glTexCoord2fv(tscp[3]); glVertex3fv(scp[3]); + glNormal3fv(scp[4]); glTexCoord2fv(tscp[4]); glVertex3fv(scp[4]); + glNormal3fv(scp[4]); glTexCoord2fv(tscp[5]); glVertex3fv(scp[5]); + glNormal3fv(scp[6]); glTexCoord2fv(tscp[6]); glVertex3fv(scp[6]); + glNormal3fv(scp[6]); glTexCoord2fv(tscp[7]); glVertex3fv(scp[7]); + glNormal3fv(scp[8]); glTexCoord2fv(tscp[8]); glVertex3fv(scp[8]); + glNormal3fv(scp[8]); glTexCoord2fv(tscp[9]); glVertex3fv(scp[9]); + glNormal3fv(scp[10]); glTexCoord2fv(tscp[10]); glVertex3fv(scp[10]); + glNormal3fv(scp[10]); glTexCoord2fv(tscp[11]); glVertex3fv(scp[11]); + glNormal3fv(scp[12]); glTexCoord2fv(tscp[12]); glVertex3fv(scp[12]); + glNormal3fv(scp[12]); glTexCoord2fv(tscp[13]); glVertex3fv(scp[13]); + glNormal3fv(scp[14]); glTexCoord2fv(tscp[14]); glVertex3fv(scp[14]); + glNormal3fv(scp[14]); glTexCoord2fv(tscp[15]); glVertex3fv(scp[15]); + glNormal3fv(scp[16]); glTexCoord2fv(tscp[16]); glVertex3fv(scp[16]); + glNormal3fv(scp[16]); glTexCoord2fv(tscp[17]); glVertex3fv(scp[17]); + glEnd(); + + glEndList(); +} + +static void BuildDoubleCylinder(void) +{ + + glNewList(doubleCylinder, GL_COMPILE); + + glBegin(GL_TRIANGLE_STRIP); + glNormal3fv(dcp[0]); glTexCoord2fv(tscp[0]); glVertex3fv(dcp[0]); + glNormal3fv(dcp[0]); glTexCoord2fv(tscp[1]); glVertex3fv(dcp[1]); + glNormal3fv(dcp[2]); glTexCoord2fv(tscp[2]); glVertex3fv(dcp[2]); + glNormal3fv(dcp[2]); glTexCoord2fv(tscp[3]); glVertex3fv(dcp[3]); + glNormal3fv(dcp[4]); glTexCoord2fv(tscp[4]); glVertex3fv(dcp[4]); + glNormal3fv(dcp[4]); glTexCoord2fv(tscp[5]); glVertex3fv(dcp[5]); + glNormal3fv(dcp[6]); glTexCoord2fv(tscp[6]); glVertex3fv(dcp[6]); + glNormal3fv(dcp[6]); glTexCoord2fv(tscp[7]); glVertex3fv(dcp[7]); + glNormal3fv(dcp[8]); glTexCoord2fv(tscp[8]); glVertex3fv(dcp[8]); + glNormal3fv(dcp[8]); glTexCoord2fv(tscp[9]); glVertex3fv(dcp[9]); + glNormal3fv(dcp[10]); glTexCoord2fv(tscp[10]); glVertex3fv(dcp[10]); + glNormal3fv(dcp[10]); glTexCoord2fv(tscp[11]); glVertex3fv(dcp[11]); + glNormal3fv(dcp[12]); glTexCoord2fv(tscp[12]); glVertex3fv(dcp[12]); + glNormal3fv(dcp[12]); glTexCoord2fv(tscp[13]); glVertex3fv(dcp[13]); + glNormal3fv(dcp[14]); glTexCoord2fv(tscp[14]); glVertex3fv(dcp[14]); + glNormal3fv(dcp[14]); glTexCoord2fv(tscp[15]); glVertex3fv(dcp[15]); + glNormal3fv(dcp[16]); glTexCoord2fv(tscp[16]); glVertex3fv(dcp[16]); + glNormal3fv(dcp[16]); glTexCoord2fv(tscp[17]); glVertex3fv(dcp[17]); + glEnd(); + + glEndList(); +} + +static void BuildElbow(void) +{ + + glNewList(elbow, GL_COMPILE); + + glBegin(GL_TRIANGLE_STRIP); + glNormal3fv(en[0][0]); glTexCoord2fv(tep[0][0]); glVertex3fv(ep[0][0]); + glNormal3fv(en[1][0]); glTexCoord2fv(tep[1][0]); glVertex3fv(ep[1][0]); + glNormal3fv(en[0][1]); glTexCoord2fv(tep[0][1]); glVertex3fv(ep[0][1]); + glNormal3fv(en[1][1]); glTexCoord2fv(tep[1][1]); glVertex3fv(ep[1][1]); + glNormal3fv(en[0][2]); glTexCoord2fv(tep[0][2]); glVertex3fv(ep[0][2]); + glNormal3fv(en[1][2]); glTexCoord2fv(tep[1][2]); glVertex3fv(ep[1][2]); + glNormal3fv(en[0][3]); glTexCoord2fv(tep[0][3]); glVertex3fv(ep[0][3]); + glNormal3fv(en[1][3]); glTexCoord2fv(tep[1][3]); glVertex3fv(ep[1][3]); + glNormal3fv(en[0][4]); glTexCoord2fv(tep[0][4]); glVertex3fv(ep[0][4]); + glNormal3fv(en[1][4]); glTexCoord2fv(tep[1][4]); glVertex3fv(ep[1][4]); + glNormal3fv(en[0][5]); glTexCoord2fv(tep[0][5]); glVertex3fv(ep[0][5]); + glNormal3fv(en[1][5]); glTexCoord2fv(tep[1][5]); glVertex3fv(ep[1][5]); + glNormal3fv(en[0][6]); glTexCoord2fv(tep[0][6]); glVertex3fv(ep[0][6]); + glNormal3fv(en[1][6]); glTexCoord2fv(tep[1][6]); glVertex3fv(ep[1][6]); + glNormal3fv(en[0][7]); glTexCoord2fv(tep[0][7]); glVertex3fv(ep[0][7]); + glNormal3fv(en[1][7]); glTexCoord2fv(tep[1][7]); glVertex3fv(ep[1][7]); + glNormal3fv(en[0][8]); glTexCoord2fv(tep[0][8]); glVertex3fv(ep[0][8]); + glNormal3fv(en[1][8]); glTexCoord2fv(tep[1][8]); glVertex3fv(ep[1][8]); + glEnd(); + glBegin(GL_TRIANGLE_STRIP); + glNormal3fv(en[1][0]); glTexCoord2fv(tep[1][0]); glVertex3fv(ep[1][0]); + glNormal3fv(en[2][0]); glTexCoord2fv(tep[2][0]); glVertex3fv(ep[2][0]); + glNormal3fv(en[1][1]); glTexCoord2fv(tep[1][1]); glVertex3fv(ep[1][1]); + glNormal3fv(en[2][1]); glTexCoord2fv(tep[2][1]); glVertex3fv(ep[2][1]); + glNormal3fv(en[1][2]); glTexCoord2fv(tep[1][2]); glVertex3fv(ep[1][2]); + glNormal3fv(en[2][2]); glTexCoord2fv(tep[2][2]); glVertex3fv(ep[2][2]); + glNormal3fv(en[1][3]); glTexCoord2fv(tep[1][3]); glVertex3fv(ep[1][3]); + glNormal3fv(en[2][3]); glTexCoord2fv(tep[2][3]); glVertex3fv(ep[2][3]); + glNormal3fv(en[1][4]); glTexCoord2fv(tep[1][4]); glVertex3fv(ep[1][4]); + glNormal3fv(en[2][4]); glTexCoord2fv(tep[2][4]); glVertex3fv(ep[2][4]); + glNormal3fv(en[1][5]); glTexCoord2fv(tep[1][5]); glVertex3fv(ep[1][5]); + glNormal3fv(en[2][5]); glTexCoord2fv(tep[2][5]); glVertex3fv(ep[2][5]); + glNormal3fv(en[1][6]); glTexCoord2fv(tep[1][6]); glVertex3fv(ep[1][6]); + glNormal3fv(en[2][6]); glTexCoord2fv(tep[2][6]); glVertex3fv(ep[2][6]); + glNormal3fv(en[1][7]); glTexCoord2fv(tep[1][7]); glVertex3fv(ep[1][7]); + glNormal3fv(en[2][7]); glTexCoord2fv(tep[2][7]); glVertex3fv(ep[2][7]); + glNormal3fv(en[1][8]); glTexCoord2fv(tep[1][8]); glVertex3fv(ep[1][8]); + glNormal3fv(en[2][8]); glTexCoord2fv(tep[2][8]); glVertex3fv(ep[2][8]); + glEnd(); + glBegin(GL_TRIANGLE_STRIP); + glNormal3fv(en[2][0]); glTexCoord2fv(tep[2][0]); glVertex3fv(ep[2][0]); + glNormal3fv(en[3][0]); glTexCoord2fv(tep[3][0]); glVertex3fv(ep[3][0]); + glNormal3fv(en[2][1]); glTexCoord2fv(tep[2][1]); glVertex3fv(ep[2][1]); + glNormal3fv(en[3][1]); glTexCoord2fv(tep[3][1]); glVertex3fv(ep[3][1]); + glNormal3fv(en[2][2]); glTexCoord2fv(tep[2][2]); glVertex3fv(ep[2][2]); + glNormal3fv(en[3][2]); glTexCoord2fv(tep[3][2]); glVertex3fv(ep[3][2]); + glNormal3fv(en[2][3]); glTexCoord2fv(tep[2][3]); glVertex3fv(ep[2][3]); + glNormal3fv(en[3][3]); glTexCoord2fv(tep[3][3]); glVertex3fv(ep[3][3]); + glNormal3fv(en[2][4]); glTexCoord2fv(tep[2][4]); glVertex3fv(ep[2][4]); + glNormal3fv(en[3][4]); glTexCoord2fv(tep[3][4]); glVertex3fv(ep[3][4]); + glNormal3fv(en[2][5]); glTexCoord2fv(tep[2][5]); glVertex3fv(ep[2][5]); + glNormal3fv(en[3][5]); glTexCoord2fv(tep[3][5]); glVertex3fv(ep[3][5]); + glNormal3fv(en[2][6]); glTexCoord2fv(tep[2][6]); glVertex3fv(ep[2][6]); + glNormal3fv(en[3][6]); glTexCoord2fv(tep[3][6]); glVertex3fv(ep[3][6]); + glNormal3fv(en[2][7]); glTexCoord2fv(tep[2][7]); glVertex3fv(ep[2][7]); + glNormal3fv(en[3][7]); glTexCoord2fv(tep[3][7]); glVertex3fv(ep[3][7]); + glNormal3fv(en[2][8]); glTexCoord2fv(tep[2][8]); glVertex3fv(ep[2][8]); + glNormal3fv(en[3][8]); glTexCoord2fv(tep[3][8]); glVertex3fv(ep[3][8]); + glEnd(); + glBegin(GL_TRIANGLE_STRIP); + glNormal3fv(en[3][0]); glTexCoord2fv(tep[3][0]); glVertex3fv(ep[3][0]); + glNormal3fv(en[4][0]); glTexCoord2fv(tep[4][0]); glVertex3fv(ep[4][0]); + glNormal3fv(en[3][1]); glTexCoord2fv(tep[3][1]); glVertex3fv(ep[3][1]); + glNormal3fv(en[4][1]); glTexCoord2fv(tep[4][1]); glVertex3fv(ep[4][1]); + glNormal3fv(en[3][2]); glTexCoord2fv(tep[3][2]); glVertex3fv(ep[3][2]); + glNormal3fv(en[4][2]); glTexCoord2fv(tep[4][2]); glVertex3fv(ep[4][2]); + glNormal3fv(en[3][3]); glTexCoord2fv(tep[3][3]); glVertex3fv(ep[3][3]); + glNormal3fv(en[4][3]); glTexCoord2fv(tep[4][3]); glVertex3fv(ep[4][3]); + glNormal3fv(en[3][4]); glTexCoord2fv(tep[3][4]); glVertex3fv(ep[3][4]); + glNormal3fv(en[4][4]); glTexCoord2fv(tep[4][4]); glVertex3fv(ep[4][4]); + glNormal3fv(en[3][5]); glTexCoord2fv(tep[3][5]); glVertex3fv(ep[3][5]); + glNormal3fv(en[4][5]); glTexCoord2fv(tep[4][5]); glVertex3fv(ep[4][5]); + glNormal3fv(en[3][6]); glTexCoord2fv(tep[3][6]); glVertex3fv(ep[3][6]); + glNormal3fv(en[4][6]); glTexCoord2fv(tep[4][6]); glVertex3fv(ep[4][6]); + glNormal3fv(en[3][7]); glTexCoord2fv(tep[3][7]); glVertex3fv(ep[3][7]); + glNormal3fv(en[4][7]); glTexCoord2fv(tep[4][7]); glVertex3fv(ep[4][7]); + glNormal3fv(en[3][8]); glTexCoord2fv(tep[3][8]); glVertex3fv(ep[3][8]); + glNormal3fv(en[4][8]); glTexCoord2fv(tep[4][8]); glVertex3fv(ep[4][8]); + glEnd(); + glBegin(GL_TRIANGLE_STRIP); + glNormal3fv(en[4][0]); glTexCoord2fv(tep[4][0]); glVertex3fv(ep[4][0]); + glNormal3fv(en[5][0]); glTexCoord2fv(tep[5][0]); glVertex3fv(ep[5][0]); + glNormal3fv(en[4][1]); glTexCoord2fv(tep[4][1]); glVertex3fv(ep[4][1]); + glNormal3fv(en[5][1]); glTexCoord2fv(tep[5][1]); glVertex3fv(ep[5][1]); + glNormal3fv(en[4][2]); glTexCoord2fv(tep[4][2]); glVertex3fv(ep[4][2]); + glNormal3fv(en[5][2]); glTexCoord2fv(tep[5][2]); glVertex3fv(ep[5][2]); + glNormal3fv(en[4][3]); glTexCoord2fv(tep[4][3]); glVertex3fv(ep[4][3]); + glNormal3fv(en[5][3]); glTexCoord2fv(tep[5][3]); glVertex3fv(ep[5][3]); + glNormal3fv(en[4][4]); glTexCoord2fv(tep[4][4]); glVertex3fv(ep[4][4]); + glNormal3fv(en[5][4]); glTexCoord2fv(tep[5][4]); glVertex3fv(ep[5][4]); + glNormal3fv(en[4][5]); glTexCoord2fv(tep[4][5]); glVertex3fv(ep[4][5]); + glNormal3fv(en[5][5]); glTexCoord2fv(tep[5][5]); glVertex3fv(ep[5][5]); + glNormal3fv(en[4][6]); glTexCoord2fv(tep[4][6]); glVertex3fv(ep[4][6]); + glNormal3fv(en[5][6]); glTexCoord2fv(tep[5][6]); glVertex3fv(ep[5][6]); + glNormal3fv(en[4][7]); glTexCoord2fv(tep[4][7]); glVertex3fv(ep[4][7]); + glNormal3fv(en[5][7]); glTexCoord2fv(tep[5][7]); glVertex3fv(ep[5][7]); + glNormal3fv(en[4][8]); glTexCoord2fv(tep[4][8]); glVertex3fv(ep[4][8]); + glNormal3fv(en[5][8]); glTexCoord2fv(tep[5][8]); glVertex3fv(ep[5][8]); + glEnd(); + glBegin(GL_TRIANGLE_STRIP); + glNormal3fv(en[5][0]); glTexCoord2fv(tep[5][0]); glVertex3fv(ep[5][0]); + glNormal3fv(en[6][0]); glTexCoord2fv(tep[6][0]); glVertex3fv(ep[6][0]); + glNormal3fv(en[5][1]); glTexCoord2fv(tep[5][1]); glVertex3fv(ep[5][1]); + glNormal3fv(en[6][1]); glTexCoord2fv(tep[6][1]); glVertex3fv(ep[6][1]); + glNormal3fv(en[5][2]); glTexCoord2fv(tep[5][2]); glVertex3fv(ep[5][2]); + glNormal3fv(en[6][2]); glTexCoord2fv(tep[6][2]); glVertex3fv(ep[6][2]); + glNormal3fv(en[5][3]); glTexCoord2fv(tep[5][3]); glVertex3fv(ep[5][3]); + glNormal3fv(en[6][3]); glTexCoord2fv(tep[6][3]); glVertex3fv(ep[6][3]); + glNormal3fv(en[5][4]); glTexCoord2fv(tep[5][4]); glVertex3fv(ep[5][4]); + glNormal3fv(en[6][4]); glTexCoord2fv(tep[6][4]); glVertex3fv(ep[6][4]); + glNormal3fv(en[5][5]); glTexCoord2fv(tep[5][5]); glVertex3fv(ep[5][5]); + glNormal3fv(en[6][5]); glTexCoord2fv(tep[6][5]); glVertex3fv(ep[6][5]); + glNormal3fv(en[5][6]); glTexCoord2fv(tep[5][6]); glVertex3fv(ep[5][6]); + glNormal3fv(en[6][6]); glTexCoord2fv(tep[6][6]); glVertex3fv(ep[6][6]); + glNormal3fv(en[5][7]); glTexCoord2fv(tep[5][7]); glVertex3fv(ep[5][7]); + glNormal3fv(en[6][7]); glTexCoord2fv(tep[6][7]); glVertex3fv(ep[6][7]); + glNormal3fv(en[5][8]); glTexCoord2fv(tep[5][8]); glVertex3fv(ep[5][8]); + glNormal3fv(en[6][8]); glTexCoord2fv(tep[6][8]); glVertex3fv(ep[6][8]); + glEnd(); + + glEndList(); +} + +static void BuildLogo(void) +{ + + glNewList(logo, GL_COMPILE); + + glTranslatef(5.5, -3.5, 4.5); + glTranslatef(0.0, 0.0, -7.0); + glCallList(doubleCylinder); + BendForward(); + glCallList(elbow); + glTranslatef(0.0, 0.0, -7.0); + glCallList(doubleCylinder); + BendForward(); + glCallList(elbow); + glTranslatef(0.0, 0.0, -5.0); + glCallList(singleCylinder); + BendRight(); + glCallList(elbow); + glTranslatef(0.0, 0.0, -7.0); + glCallList(doubleCylinder); + BendForward(); + glCallList(elbow); + glTranslatef(0.0, 0.0, -7.0); + glCallList(doubleCylinder); + BendForward(); + glCallList(elbow); + glTranslatef(0.0, 0.0, -5.0); + glCallList(singleCylinder); + BendLeft(); + glCallList(elbow); + glTranslatef(0.0, 0.0, -7.0); + glCallList(doubleCylinder); + BendForward(); + glCallList(elbow); + glTranslatef(0.0, 0.0, -7.0); + glCallList(doubleCylinder); + BendForward(); + glCallList(elbow); + glTranslatef(0.0, 0.0, -5.0); + glCallList(singleCylinder); + BendRight(); + glCallList(elbow); + glTranslatef(0.0, 0.0, -7.0); + glCallList(doubleCylinder); + BendForward(); + glCallList(elbow); + glTranslatef(0.0, 0.0, -7.0); + glCallList(doubleCylinder); + BendForward(); + glCallList(elbow); + glTranslatef(0.0, 0.0, -5.0); + glCallList(singleCylinder); + BendLeft(); + glCallList(elbow); + glTranslatef(0.0, 0.0, -7.0); + glCallList(doubleCylinder); + BendForward(); + glCallList(elbow); + glTranslatef(0.0, 0.0, -7.0); + glCallList(doubleCylinder); + BendForward(); + glCallList(elbow); + glTranslatef(0.0, 0.0, -5.0); + glCallList(singleCylinder); + BendRight(); + glCallList(elbow); + glTranslatef(0.0, 0.0, -7.0); + glCallList(doubleCylinder); + BendForward(); + glCallList(elbow); + glTranslatef(0.0, 0.0, -7.0); + glCallList(doubleCylinder); + BendForward(); + glCallList(elbow); + glTranslatef(0.0, 0.0, -5.0); + glCallList(singleCylinder); + BendLeft(); + glCallList(elbow); + + glEndList(); +} + +static void BuildLists(void) +{ + + singleCylinder = glGenLists(1); + doubleCylinder = glGenLists(1); + elbow = glGenLists(1); + logo = glGenLists(1); + + BuildSingleCylinder(); + BuildDoubleCylinder(); + BuildElbow(); + BuildLogo(); +} + +static void Init(void) +{ + static float ambient[] = {0.1, 0.1, 0.1, 1.0}; + static float diffuse[] = {0.5, 1.0, 1.0, 1.0}; + static float position[] = {90.0, 90.0, 150.0, 0.0}; + static float front_mat_shininess[] = {30.0}; + static float front_mat_specular[] = {0.2, 0.2, 0.2, 1.0}; + static float front_mat_diffuse[] = {0.5, 0.28, 0.38, 1.0}; + static float back_mat_shininess[] = {50.0}; + static float back_mat_specular[] = {0.5, 0.5, 0.2, 1.0}; + static float back_mat_diffuse[] = {1.0, 1.0, 0.2, 1.0}; + static float lmodel_ambient[] = {1.0, 1.0, 1.0, 1.0}; + static float lmodel_twoside[] = {GL_TRUE}; + + glClearColor(0.0, 0.0, 0.0, 0.0); + + glFrontFace(GL_CW); + + glEnable(GL_DEPTH_TEST); + + glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient); + glLightModelfv(GL_LIGHT_MODEL_TWO_SIDE, lmodel_twoside); + glLightfv(GL_LIGHT0, GL_AMBIENT, ambient); + glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse); + glLightfv(GL_LIGHT0, GL_POSITION, position); + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + + glMaterialfv(GL_FRONT, GL_SHININESS, front_mat_shininess); + glMaterialfv(GL_FRONT, GL_SPECULAR, front_mat_specular); + glMaterialfv(GL_FRONT, GL_DIFFUSE, front_mat_diffuse); + glMaterialfv(GL_BACK, GL_SHININESS, back_mat_shininess); + glMaterialfv(GL_BACK, GL_SPECULAR, back_mat_specular); + glMaterialfv(GL_BACK, GL_DIFFUSE, back_mat_diffuse); + + glEnable(GL_CLIP_PLANE0); + + if (rgb) { + glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, decal); + glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, repeat); + glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, repeat); + glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, nearest); + glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, nearest); + glTexImage2D(GL_TEXTURE_2D, 0, 3, CHECKIMAGEWIDTH, CHECKIMAGEHEIGHT, 0, + GL_RGB, GL_UNSIGNED_BYTE, (GLvoid *)checkImage); + glEnable(GL_TEXTURE_2D); + + glCullFace(GL_BACK); + glEnable(GL_CULL_FACE); + } else { + SetGreyRamp(); + /* commented out by BrianP because it's the wrong way to handle a 4-bit visual! + if (doubleBuffer) { + colorIndexes[1] = 10; + colorIndexes[2] = 15; + } + */ + glMaterialiv(GL_FRONT_AND_BACK, GL_COLOR_INDEXES, colorIndexes); + } + + BuildLists(); + + dithering = GL_TRUE; + shade = GL_TRUE; + doStipple = GL_FALSE; + polyMode = GL_BACK; +} + +static void Reshape(int width, int height) +{ + glViewport(0, 0, (GLint)width, (GLint)height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluPerspective(90, 1.0, 1.0, 200.0); + glMatrixMode(GL_MODELVIEW); +} + +static void Key2(int key, int x, int y) +{ + (void) x; + (void) y; + switch (key) { + case GLUT_KEY_LEFT: + yRotation += 0.5; + break; + case GLUT_KEY_RIGHT: + yRotation -= 0.5; + break; + case GLUT_KEY_UP: + plane[3] += 2.0; + break; + case GLUT_KEY_DOWN: + plane[3] -= 2.0; + break; + default: + return; + } + + glutPostRedisplay(); +} + +static void Key(unsigned char key, int x, int y) +{ + (void) x; + (void) y; + switch (key) { + case 27: + exit(1); + + case 'Z': + zTranslation -= 1.0; + break; + case 'z': + zTranslation += 1.0; + break; + + case '1': + glPolygonMode(polyMode, GL_POINT); + break; + case '2': + glPolygonMode(polyMode, GL_LINE); + break; + case '3': + glPolygonMode(polyMode, GL_FILL); + break; + case 'p': + switch (polyMode) { + case GL_BACK: + polyMode = GL_FRONT; + printf("PolygonMode GL_FRONT\n"); + break; + case GL_FRONT: + polyMode = GL_FRONT_AND_BACK; + printf("PolygonMode GL_FRONT_AND_BACK\n"); + break; + case GL_FRONT_AND_BACK: + polyMode = GL_BACK; + printf("PolygonMode GL_BACK\n"); + break; + default: + break; + } + break; + + case '4': + glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST); + break; + case '5': + glEnable(GL_POLYGON_SMOOTH); + if (rgb) { + glBlendFunc(GL_SRC_ALPHA, GL_ONE); + glEnable(GL_BLEND); + glDisable(GL_DEPTH_TEST); + } else { + SetUpAntiAliasedGrayScale(); + } + break; + case '6': + glDisable(GL_POLYGON_SMOOTH); + if (rgb) { + glBlendFunc(GL_ONE, GL_ZERO); + glDisable(GL_BLEND); + glEnable(GL_DEPTH_TEST); + } else { + SetGreyRamp(); + } + break; + + case '8': + dithering = !dithering; + (dithering) ? glEnable(GL_DITHER) : glDisable(GL_DITHER); + break; + + case '9': + doStipple = !doStipple; + if (doStipple) { + glPolygonStipple(stipple); + glEnable(GL_POLYGON_STIPPLE); + } else { + glDisable(GL_POLYGON_STIPPLE); + } + break; + + case '0': + shade = !shade; + (shade) ? glShadeModel(GL_SMOOTH) : glShadeModel(GL_FLAT); + break; + + case 'q': + glDisable(GL_CULL_FACE); + printf("disable culling\n"); + break; + case 'w': + glEnable(GL_CULL_FACE); + glCullFace(GL_FRONT); + printf("enable front face culling\n"); + break; + case 'e': + glEnable(GL_CULL_FACE); + glCullFace(GL_BACK); + printf("enable back face culling\n"); + break; + + case 'r': + glFrontFace(GL_CW); + break; + case 't': + glFrontFace(GL_CCW); + break; + case 'y': + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + glPixelStorei(GL_UNPACK_LSB_FIRST, 0); + glPolygonStipple(stipple); + break; + case 'u': + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + glPixelStorei(GL_UNPACK_LSB_FIRST, 1); + glPolygonStipple(stipple); + break; + + case 'a': + glEnable(GL_TEXTURE_2D); + glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, repeat); + glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, repeat); + glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, nearest); + glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, nearest); + glTexImage2D(GL_TEXTURE_2D, 0, 4, BRICKIMAGEWIDTH, + BRICKIMAGEHEIGHT, 0, GL_RGBA, GL_UNSIGNED_BYTE, + (GLvoid *)brickImage); + break; + case 's': + glEnable(GL_TEXTURE_2D); + glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, repeat); + glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, repeat); + glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, nearest); + glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, nearest); + glTexImage2D(GL_TEXTURE_2D, 0, 3, CHECKIMAGEWIDTH, + CHECKIMAGEHEIGHT, 0, GL_RGB, GL_UNSIGNED_BYTE, + (GLvoid *)checkImage); + break; + case 'd': + glDisable(GL_TEXTURE_2D); + break; + + case 'f': + glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, decal); + break; + case 'g': + glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, modulate); + break; + + case 'n': + /* added by BrianP */ + noDraw = !noDraw; + if (noDraw) { + glDrawBuffer( GL_NONE ); + } + else { + if (doubleBuffer) { + glDrawBuffer( GL_BACK ); + } + else { + glDrawBuffer( GL_FRONT ); + } + } + break; + + case 'l': + /* Line Smooth - added by BrianP */ + LineSmooth = !LineSmooth; + if (LineSmooth) { + glEnable(GL_LINE_SMOOTH); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_BLEND); + } + else { + glDisable(GL_LINE_SMOOTH); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glDisable(GL_BLEND); + } + break; + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + + glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); + + glPushMatrix(); + + glTranslatef(0, 0, zTranslation); + glRotatef(30.0, 1, 0, 0); + glRotatef(yRotation, 0, 1, 0); + glClipPlane(GL_CLIP_PLANE0, plane); + glCallList(logo); + + glPopMatrix(); + + glFlush(); + + if (doubleBuffer) { + glutSwapBuffers(); + } +} + +static GLenum Args(int argc, char **argv) +{ + GLint i; + + rgb = GL_TRUE; + doubleBuffer = GL_FALSE; + + for (i = 1; i < argc; i++) { + if (strcmp(argv[i], "-ci") == 0) { + rgb = GL_FALSE; + } else if (strcmp(argv[i], "-rgb") == 0) { + rgb = GL_TRUE; + } else 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; +} + +int main(int argc, char **argv) +{ + unsigned int type; + + glutInit(&argc, argv); + + if (Args(argc, argv) == GL_FALSE) { + exit(1); + } + + glutInitWindowPosition(0, 0); glutInitWindowSize( 300, 300); + + type = GLUT_DEPTH; + type |= (rgb) ? GLUT_RGB : GLUT_INDEX; + type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("Logo Test") == GL_FALSE) { + exit(1); + } + + InitMap(); + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutSpecialFunc(Key2); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/samples/nurb.c b/progs/samples/nurb.c new file mode 100644 index 00000000000..dc8991295e8 --- /dev/null +++ b/progs/samples/nurb.c @@ -0,0 +1,357 @@ +/* + * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the name of + * Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF + * ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#include +#include +#include +#include +#include + + +#ifndef CALLBACK +#define CALLBACK +#endif + + +#define INREAL float + +#define S_NUMPOINTS 13 +#define S_ORDER 3 +#define S_NUMKNOTS (S_NUMPOINTS + S_ORDER) +#define T_NUMPOINTS 3 +#define T_ORDER 3 +#define T_NUMKNOTS (T_NUMPOINTS + T_ORDER) +#define SQRT_TWO 1.41421356237309504880 + + +typedef INREAL Point[4]; + + +GLenum doubleBuffer; + +GLenum expectedError; +GLint rotX = 40, rotY = 40; +INREAL sknots[S_NUMKNOTS] = { + -1.0, -1.0, -1.0, 0.0, 1.0, 2.0, 3.0, 4.0, + 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 9.0, 9.0 +}; +INREAL tknots[T_NUMKNOTS] = { + 1.0, 1.0, 1.0, 2.0, 2.0, 2.0 +}; +Point ctlpoints[S_NUMPOINTS][T_NUMPOINTS] = { + { + { + 4.0, 2.0, 2.0, 1.0 + }, + { + 4.0, 1.6, 2.5, 1.0 + }, + { + 4.0, 2.0, 3.0, 1.0 + } + }, + { + { + 5.0, 4.0, 2.0, 1.0 + }, + { + 5.0, 4.0, 2.5, 1.0 + }, + { + 5.0, 4.0, 3.0, 1.0 + } + }, + { + { + 6.0, 5.0, 2.0, 1.0 + }, + { + 6.0, 5.0, 2.5, 1.0 + }, + { + 6.0, 5.0, 3.0, 1.0 + } + }, + { + { + SQRT_TWO*6.0, SQRT_TWO*6.0, SQRT_TWO*2.0, SQRT_TWO + }, + { + SQRT_TWO*6.0, SQRT_TWO*6.0, SQRT_TWO*2.5, SQRT_TWO + }, + { + SQRT_TWO*6.0, SQRT_TWO*6.0, SQRT_TWO*3.0, SQRT_TWO + } + }, + { + { + 5.2, 6.7, 2.0, 1.0 + }, + { + 5.2, 6.7, 2.5, 1.0 + }, + { + 5.2, 6.7, 3.0, 1.0 + } + }, + { + { + SQRT_TWO*4.0, SQRT_TWO*6.0, SQRT_TWO*2.0, SQRT_TWO + }, + { + SQRT_TWO*4.0, SQRT_TWO*6.0, SQRT_TWO*2.5, SQRT_TWO + }, + { + SQRT_TWO*4.0, SQRT_TWO*6.0, SQRT_TWO*3.0, SQRT_TWO + } + }, + { + { + 4.0, 5.2, 2.0, 1.0 + }, + { + 4.0, 4.6, 2.5, 1.0 + }, + { + 4.0, 5.2, 3.0, 1.0 + } + }, + { + { + SQRT_TWO*4.0, SQRT_TWO*6.0, SQRT_TWO*2.0, SQRT_TWO + }, + { + SQRT_TWO*4.0, SQRT_TWO*6.0, SQRT_TWO*2.5, SQRT_TWO + }, + { + SQRT_TWO*4.0, SQRT_TWO*6.0, SQRT_TWO*3.0, SQRT_TWO + } + }, + { + { + 2.8, 6.7, 2.0, 1.0 + }, + { + 2.8, 6.7, 2.5, 1.0 + }, + { + 2.8, 6.7, 3.0, 1.0 + } + }, + { + { + SQRT_TWO*2.0, SQRT_TWO*6.0, SQRT_TWO*2.0, SQRT_TWO + }, + { + SQRT_TWO*2.0, SQRT_TWO*6.0, SQRT_TWO*2.5, SQRT_TWO + }, + { + SQRT_TWO*2.0, SQRT_TWO*6.0, SQRT_TWO*3.0, SQRT_TWO + } + }, + { + { + 2.0, 5.0, 2.0, 1.0 + }, + { + 2.0, 5.0, 2.5, 1.0 + }, + { + 2.0, 5.0, 3.0, 1.0 + } + }, + { + { + 3.0, 4.0, 2.0, 1.0 + }, + { + 3.0, 4.0, 2.5, 1.0 + }, + { + 3.0, 4.0, 3.0, 1.0 + } + }, + { + { + 4.0, 2.0, 2.0, 1.0 + }, + { + 4.0, 1.6, 2.5, 1.0 + }, + { + 4.0, 2.0, 3.0, 1.0 + } + } +}; +GLUnurbsObj *theNurbs; + + +static void CALLBACK ErrorCallback(GLenum which) +{ + + if (which != expectedError) { + fprintf(stderr, "Unexpected error occured (%d):\n", which); + fprintf(stderr, " %s\n", (char *) gluErrorString(which)); + } +} + +typedef void (GLAPIENTRY *callback_t)(); + +static void Init(void) +{ + + theNurbs = gluNewNurbsRenderer(); + gluNurbsCallback(theNurbs, GLU_ERROR, (callback_t) ErrorCallback); + + gluNurbsProperty(theNurbs, GLU_SAMPLING_TOLERANCE, 15.0); + gluNurbsProperty(theNurbs, GLU_DISPLAY_MODE, GLU_OUTLINE_PATCH); + + expectedError = GLU_INVALID_ENUM; + gluNurbsProperty(theNurbs, ~0, 15.0); + expectedError = GLU_NURBS_ERROR13; + gluEndSurface(theNurbs); + expectedError = 0; + + glColor3f(1.0, 1.0, 1.0); +} + +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, 0.8, 10.0); + gluLookAt(7.0, 4.5, 4.0, 4.5, 4.5, 2.5, 6.0, -3.0, 2.0); + glMatrixMode(GL_MODELVIEW); +} + +static void Key2(int key, int x, int y) +{ + + switch (key) { + case GLUT_KEY_DOWN: + rotX -= 5; + break; + case GLUT_KEY_UP: + rotX += 5; + break; + case GLUT_KEY_LEFT: + rotY -= 5; + break; + case GLUT_KEY_RIGHT: + rotY += 5; + break; + default: + return; + } + + glutPostRedisplay(); +} + +static void Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + } +} + +static void Draw(void) +{ + + glClear(GL_COLOR_BUFFER_BIT); + + glPushMatrix(); + + glTranslatef(4.0, 4.5, 2.5); + glRotatef(rotY, 1, 0, 0); + glRotatef(rotX, 0, 1, 0); + glTranslatef(-4.0, -4.5, -2.5); + + gluBeginSurface(theNurbs); + gluNurbsSurface(theNurbs, S_NUMKNOTS, sknots, T_NUMKNOTS, tknots, + 4*T_NUMPOINTS, 4, &ctlpoints[0][0][0], S_ORDER, + T_ORDER, GL_MAP2_VERTEX_4); + gluEndSurface(theNurbs); + + glPopMatrix(); + + glFlush(); + + if (doubleBuffer) { + glutSwapBuffers(); + } +} + +static GLenum Args(int argc, char **argv) +{ + GLint i; + + doubleBuffer = GL_FALSE; + + for (i = 1; i < argc; i++) { + if (strcmp(argv[i], "-sb") == 0) { + doubleBuffer = GL_FALSE; + } else if (strcmp(argv[i], "-db") == 0) { + doubleBuffer = GL_TRUE; + } else { + printf("%s (Bad option).\n", argv[i]); + return GL_FALSE; + } + } + return GL_TRUE; +} + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + if (Args(argc, argv) == GL_FALSE) { + exit(1); + } + + glutInitWindowPosition(0, 0); glutInitWindowSize( 300, 300); + + type = GLUT_RGB; + type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("NURBS Test") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutSpecialFunc(Key2); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/samples/oglinfo.c b/progs/samples/oglinfo.c new file mode 100644 index 00000000000..4fe51efb3cb --- /dev/null +++ b/progs/samples/oglinfo.c @@ -0,0 +1,218 @@ +/* oglinfo.c */ + +/* This demo modified by BrianP to accomodate Mesa and test + * the GLX 1.1 functions. + */ + + + +#include +#include +#include +#include +#include + +int visual_request0[] = { None }; /* don't need much of a visual */ +int visual_request1[] = { GLX_RGBA, None }; /* in case CI failed */ + +int main(int argc, char **argv) +{ + char *display_name = NULL; + char *string; + Display *dpy; + int screen_num; + int major, minor; + XVisualInfo *vis; + GLXContext ctx; + Window root, win; + Colormap cmap; + XSetWindowAttributes swa; + int dontcare; + + /* parse arguments */ + if(argc > 1) { + if(!strcmp(argv[1],"-display")) + display_name = argv[2]; + else { + fprintf(stderr, "Usage: %s [-display ]\n",argv[0]); + return 0; + } + } + + /* get display */ + if (!(dpy = XOpenDisplay(display_name))) { + fprintf(stderr,"Error: XOpenDisplay() failed.\n"); + return 1; + } + + /* does the server know about OpenGL & GLX? */ +#ifndef MESA + if(!XQueryExtension(dpy, "GLX", &dontcare, &dontcare, &dontcare)) { + fprintf(stderr,"This system doesn't appear to support OpenGL\n"); + return 1; + } +#else + (void) dontcare; +#endif + + /* find the glx version */ + if(glXQueryVersion(dpy, &major, &minor)) + printf("GLX Version: %d.%d\n", major, minor); + else { + fprintf(stderr, "Error: glXQueryVersion() failed.\n"); + return 1; + } + + /* get screen number */ + screen_num = DefaultScreen(dpy); + +/* This #ifdef isn't redundant. It keeps the build from breaking +** if you are building on a machine that has an old (1.0) version +** of glx. +** +** This program could still be *run* on a machine that has an old +** version of glx, even if it was *compiled* on a version that has +** a new version. +** +** If compiled on a system with an old version of glx, then it will +** never recognize glx extensions, since that code would have been +** #ifdef'ed out. +*/ +#ifdef GLX_VERSION_1_1 + + /* + ** This test guarantees that glx, on the display you are inquiring, + ** suppports glXQueryExtensionsString(). + */ + if(minor > 0 || major > 1) + string = (char *) glXQueryExtensionsString(dpy, screen_num); + else + string = ""; + + if(string) + printf("GLX Extensions (client & server): %s\n", + string); + else { + fprintf(stderr, "Error: glXQueryExtensionsString() failed.\n"); + return 1; + } + + if (minor>0 || major>1) { + printf("glXGetClientString(GLX_VENDOR): %s\n", glXGetClientString(dpy,GLX_VENDOR)); + printf("glXGetClientString(GLX_VERSION): %s\n", glXGetClientString(dpy,GLX_VERSION)); + printf("glXGetClientString(GLX_EXTENSIONS): %s\n", glXGetClientString(dpy,GLX_EXTENSIONS)); + printf("glXQueryServerString(GLX_VENDOR): %s\n", glXQueryServerString(dpy,screen_num,GLX_VENDOR)); + printf("glXQueryServerString(GLX_VERSION): %s\n", glXQueryServerString(dpy,screen_num,GLX_VERSION)); + printf("glXQueryServerString(GLX_EXTENSIONS): %s\n", glXQueryServerString(dpy,screen_num,GLX_EXTENSIONS)); + } + + +#endif + + /* get any valid OpenGL visual */ + if (!(vis = glXChooseVisual(dpy, screen_num, visual_request0))) { + if (!(vis = glXChooseVisual(dpy, screen_num, visual_request1))) { + fprintf(stderr,"Error: glXChooseVisual() failed.\n"); + return 1; + } + } + + /* get context */ + ctx = glXCreateContext(dpy,vis,0,GL_TRUE); + + /* root window */ + root = RootWindow(dpy,vis->screen); + + /* get RGBA colormap */ + cmap = XCreateColormap(dpy, root, vis->visual, AllocNone); + + /* get window */ + swa.colormap = cmap; + swa.border_pixel = 0; + swa.event_mask = StructureNotifyMask; + win = XCreateWindow(dpy, root, 0, 0, 1, 1, 0, vis->depth, + InputOutput,vis->visual, + CWBorderPixel|CWColormap|CWEventMask, + &swa); + + glXMakeCurrent(dpy,win,ctx); + + string = (char *) glGetString(GL_VERSION); + if(string) +#ifdef MESA + printf("Mesa Version: %s\n", string); +#else + printf("OpenGL Version: %s\n", string); +#endif + else { + fprintf(stderr, "Error: glGetString(GL_VERSION) failed.\n"); + return 1; + } + + string = (char *) glGetString(GL_EXTENSIONS); + + if(string) +#ifdef MESA + printf("Mesa Extensions: %s\n", string); +#else + printf("OpenGL Extensions: %s\n", string); +#endif + else { + fprintf(stderr, "Error: glGetString(GL_EXTENSIONS) failed.\n"); + return 1; + } + + string = (char *) glGetString(GL_RENDERER); + + if(string) +#ifdef MESA + printf("Mesa Renderer: %s\n", string); +#else + printf("OpenGL renderer: %s\n", string); +#endif + else { + fprintf(stderr, "Error: glGetString(GL_RENDERER) failed.\n"); + return 1; + } + +/* +** This #ifdef prevents a build failure if you compile on an a +** machine with an old GLU library. +** +** If you build on a pre GLU 1.1 machine, you will never be able +** to get glu info, even if you run on a GLU 1.1 or latter machine, +** since the code has been #ifdef'ed out. +*/ +#ifdef GLU_VERSION_1_1 + + /* + ** If the glx version is 1.1 or latter, gluGetString() is guaranteed + ** to exist. + */ + if(minor > 0 || major > 1) + string = (char *) gluGetString(GLU_VERSION); + else + string = "1.0"; + + if(string) + printf("GLU Version: %s\n", string); + else { + fprintf(stderr, "Error: gluGetString(GLU_VERSION) failed.\n"); + return 1; + } + + if(minor > 0 || major > 1) + string = (char *) gluGetString(GLU_EXTENSIONS); + else + string = ""; + + if(string) + printf("GLU Extensions: %s\n", string); + else { + fprintf(stderr, "Error: gluGetString(GLU_EXTENSIONS) failed.\n"); + return 1; + } + +#endif + return 0; +} diff --git a/progs/samples/olympic.c b/progs/samples/olympic.c new file mode 100644 index 00000000000..5385e487026 --- /dev/null +++ b/progs/samples/olympic.c @@ -0,0 +1,389 @@ +/* + * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the name of + * Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF + * ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +/* + * Nov 20, 1995 use stdlib's rand()/srand() instead of random()/srand48(), etc. + */ + +/* + * Modified by Li Wei(liwei@aiar.xjtu.edu.cn) to be able to run in Windows + * 6/13 + * + * Modified by Brian Paul to compile with Windows OR Unix. 7/23/97 + */ + + +#define _HPUX_SOURCE + +#include +#include +#include +#include +#include + +#ifndef RAND_MAX +# define RAND_MAX 32767 +#endif + + +#define XSIZE 100 +#define YSIZE 75 + +#define RINGS 5 +#define BLUERING 0 +#define BLACKRING 1 +#define REDRING 2 +#define YELLOWRING 3 +#define GREENRING 4 + +#define BACKGROUND 8 + + +GLenum rgb, doubleBuffer; + +#include "tkmap.c" + +unsigned char rgb_colors[RINGS][3]; +int mapped_colors[RINGS]; +float dests[RINGS][3]; +float offsets[RINGS][3]; +float angs[RINGS]; +float rotAxis[RINGS][3]; +int iters[RINGS]; +GLuint theTorus; + + +void FillTorus(float rc, int numc, float rt, int numt) +{ + int i, j, k; + double s, t; + double x, y, z; + double pi, twopi; + + pi = 3.14159265358979323846; + twopi = 2 * pi; + + for (i = 0; i < numc; i++) { + glBegin(GL_QUAD_STRIP); + for (j = 0; j <= numt; j++) { + for (k = 1; k >= 0; k--) { + s = (i + k) % numc + 0.5; + t = j % numt; + + x = cos(t*twopi/numt) * cos(s*twopi/numc); + y = sin(t*twopi/numt) * cos(s*twopi/numc); + z = sin(s*twopi/numc); + glNormal3f(x, y, z); + + x = (rt + rc * cos(s*twopi/numc)) * cos(t*twopi/numt); + y = (rt + rc * cos(s*twopi/numc)) * sin(t*twopi/numt); + z = rc * sin(s*twopi/numc); + glVertex3f(x, y, z); + } + } + glEnd(); + } +} + +float Clamp(int iters_left, float t) +{ + if (iters_left < 3) { + return 0.0; + } + return (iters_left-2)*t/iters_left; +} + +void DrawScene(void) +{ + int i, j; + GLboolean goIdle; + static double t0 = -1.; + double t, dt; + t = glutGet(GLUT_ELAPSED_TIME) / 1000.; + if (t0 < 0.) + t0 = t; + dt = t - t0; + + if (dt < 1./30.) + return; + + t0 = t; + + goIdle = GL_TRUE; + for (i = 0; i < RINGS; i++) { + if (iters[i]) { + for (j = 0; j < 3; j++) { + offsets[i][j] = Clamp(iters[i], offsets[i][j]); + } + angs[i] = Clamp(iters[i], angs[i]); + iters[i]--; + goIdle = GL_FALSE; + } + } + if (goIdle) { + glutIdleFunc(NULL); + } + + glPushMatrix(); + + glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); + gluLookAt(0,0,10, 0,0,0, 0,1,0); + + for (i = 0; i < RINGS; i++) { + if (rgb) { + glColor3ubv(rgb_colors[i]); + } else { + glIndexi(mapped_colors[i]); + } + glPushMatrix(); + glTranslatef(dests[i][0]+offsets[i][0], dests[i][1]+offsets[i][1], + dests[i][2]+offsets[i][2]); + glRotatef(angs[i], rotAxis[i][0], rotAxis[i][1], rotAxis[i][2]); + glCallList(theTorus); + glPopMatrix(); + } + + glPopMatrix(); + + glFlush(); + if (doubleBuffer) { + glutSwapBuffers(); + } +} + +float MyRand(void) +{ + return 10.0 * ( (float) rand() / (float) RAND_MAX - 0.5 ); +} + +#if !defined(GLUTCALLBACK) +#define GLUTCALLBACK +#endif + +void GLUTCALLBACK glut_post_redisplay_p(void) +{ + glutPostRedisplay(); +} + +void ReInit(void) +{ + int i; + float deviation; + + deviation = MyRand() / 2; + deviation = deviation * deviation; + for (i = 0; i < RINGS; i++) { + offsets[i][0] = MyRand(); + offsets[i][1] = MyRand(); + offsets[i][2] = MyRand(); + angs[i] = 260.0 * MyRand(); + rotAxis[i][0] = MyRand(); + rotAxis[i][1] = MyRand(); + rotAxis[i][2] = MyRand(); + iters[i] = (deviation * MyRand() + 60.0); + } + glutIdleFunc(glut_post_redisplay_p); +} + +void Init(void) +{ + float base, height; + float aspect, x, y; + int i; + + float top_y = 1.0; + float bottom_y = 0.0; + float top_z = 0.15; + float bottom_z = 0.69; + float spacing = 2.5; + static float lmodel_ambient[] = {0.0, 0.0, 0.0, 0.0}; + static float lmodel_twoside[] = {GL_FALSE}; + static float lmodel_local[] = {GL_FALSE}; + static float light0_ambient[] = {0.1, 0.1, 0.1, 1.0}; + static float light0_diffuse[] = {1.0, 1.0, 1.0, 0.0}; + static float light0_position[] = {0.8660254, 0.5, 1, 0}; + static float light0_specular[] = {1.0, 1.0, 1.0, 0.0}; + static float bevel_mat_ambient[] = {0.0, 0.0, 0.0, 1.0}; + static float bevel_mat_shininess[] = {40.0}; + static float bevel_mat_specular[] = {1.0, 1.0, 1.0, 0.0}; + static float bevel_mat_diffuse[] = {1.0, 0.0, 0.0, 0.0}; + + srand( (unsigned int) glutGet(GLUT_ELAPSED_TIME) ); + + ReInit(); + for (i = 0; i < RINGS; i++) { + rgb_colors[i][0] = rgb_colors[i][1] = rgb_colors[i][2] = 0; + } + rgb_colors[BLUERING][2] = 255; + rgb_colors[REDRING][0] = 255; + rgb_colors[GREENRING][1] = 255; + rgb_colors[YELLOWRING][0] = 255; + rgb_colors[YELLOWRING][1] = 255; + mapped_colors[BLUERING] = COLOR_BLUE; + mapped_colors[REDRING] = COLOR_RED; + mapped_colors[GREENRING] = COLOR_GREEN; + mapped_colors[YELLOWRING] = COLOR_YELLOW; + mapped_colors[BLACKRING] = COLOR_BLACK; + + dests[BLUERING][0] = -spacing; + dests[BLUERING][1] = top_y; + dests[BLUERING][2] = top_z; + + dests[BLACKRING][0] = 0.0; + dests[BLACKRING][1] = top_y; + dests[BLACKRING][2] = top_z; + + dests[REDRING][0] = spacing; + dests[REDRING][1] = top_y; + dests[REDRING][2] = top_z; + + dests[YELLOWRING][0] = -spacing / 2.0; + dests[YELLOWRING][1] = bottom_y; + dests[YELLOWRING][2] = bottom_z; + + dests[GREENRING][0] = spacing / 2.0; + dests[GREENRING][1] = bottom_y; + dests[GREENRING][2] = bottom_z; + + base = 2.0; + height = 2.0; + theTorus = glGenLists(1); + glNewList(theTorus, GL_COMPILE); + FillTorus(0.1, 8, 1.0, 25); + glEndList(); + + x = (float)XSIZE; + y = (float)YSIZE; + aspect = x / y; + glEnable(GL_CULL_FACE); + glCullFace(GL_BACK); + glEnable(GL_DEPTH_TEST); + glClearDepth(1.0); + + if (rgb) { + glClearColor(0.5, 0.5, 0.5, 0.0); + glLightfv(GL_LIGHT0, GL_AMBIENT, light0_ambient); + glLightfv(GL_LIGHT0, GL_DIFFUSE, light0_diffuse); + glLightfv(GL_LIGHT0, GL_SPECULAR, light0_specular); + glLightfv(GL_LIGHT0, GL_POSITION, light0_position); + glEnable(GL_LIGHT0); + + glLightModelfv(GL_LIGHT_MODEL_LOCAL_VIEWER, lmodel_local); + glLightModelfv(GL_LIGHT_MODEL_TWO_SIDE, lmodel_twoside); + glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient); + glEnable(GL_LIGHTING); + + glMaterialfv(GL_FRONT, GL_AMBIENT, bevel_mat_ambient); + glMaterialfv(GL_FRONT, GL_SHININESS, bevel_mat_shininess); + glMaterialfv(GL_FRONT, GL_SPECULAR, bevel_mat_specular); + glMaterialfv(GL_FRONT, GL_DIFFUSE, bevel_mat_diffuse); + + glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE); + glEnable(GL_COLOR_MATERIAL); + glShadeModel(GL_SMOOTH); + } else { + glClearIndex(BACKGROUND); + glShadeModel(GL_FLAT); + } + + glMatrixMode(GL_PROJECTION); + gluPerspective(45, 1.33, 0.1, 100.0); + glMatrixMode(GL_MODELVIEW); +} + +void Reshape(int width, int height) +{ + + glViewport(0, 0, width, height); +} + +void Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + case 32: + ReInit(); + break; + } +} + +GLenum Args(int argc, char **argv) +{ + GLint i; + + rgb = GL_TRUE; + doubleBuffer = GL_TRUE; + + for (i = 1; i < argc; i++) { + if (strcmp(argv[i], "-ci") == 0) { + rgb = GL_FALSE; + } else if (strcmp(argv[i], "-rgb") == 0) { + rgb = GL_TRUE; + } else 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; +} + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + if (Args(argc, argv) == GL_FALSE) { + exit(1); + } + + glutInitWindowPosition(0, 0); glutInitWindowSize( 400, 300); + + type = GLUT_DEPTH; + type |= (rgb) ? GLUT_RGB : GLUT_INDEX; + type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("Olympic") == GL_FALSE) { + exit(1); + } + + InitMap(); + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(DrawScene); + glutIdleFunc(glut_post_redisplay_p); + + glutMainLoop(); + return 0; +} diff --git a/progs/samples/overlay.c b/progs/samples/overlay.c new file mode 100644 index 00000000000..23b5a4793ba --- /dev/null +++ b/progs/samples/overlay.c @@ -0,0 +1,378 @@ +/* + * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the name of + * Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF + * ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#include +#include +#include +#include +#include +#include + + +#ifndef PI +#define PI 3.141592657 +#endif + + +enum { + NORMAL = 0, + WEIRD = 1 +}; + +enum { + STREAK = 0, + CIRCLE = 1 +}; + +#define MAXSTARS 400 +#define MAXPOS 10000 +#define MAXWARP 10 +#define MAXANGLES 6000 + + +typedef struct _starRec { + GLint type; + float x[2], y[2], z[2]; + float offsetX, offsetY, offsetR, rotation; +} starRec; + + +GLenum doubleBuffer; +GLint windW, windH; + +GLenum flag = NORMAL, overlayInit = GL_FALSE; +GLint starCount = MAXSTARS / 2; +float speed = 1.0; +GLint nitro = 0; +starRec stars[MAXSTARS]; +float sinTable[MAXANGLES]; + + +float Sin(float angle) +{ + + return (sinTable[(GLint)angle]); +} + +float Cos(float angle) +{ + + return (sinTable[((GLint)angle+(MAXANGLES/4))%MAXANGLES]); +} + +void NewStar(GLint n, GLint d) +{ + + if (rand()%4 == 0) { + stars[n].type = CIRCLE; + } else { + stars[n].type = STREAK; + } + stars[n].x[0] = (float)(rand() % MAXPOS - MAXPOS / 2); + stars[n].y[0] = (float)(rand() % MAXPOS - MAXPOS / 2); + stars[n].z[0] = (float)(rand() % MAXPOS + d); + if (rand()%4 == 0 && flag == WEIRD) { + stars[n].offsetX = (float)(rand() % 100 - 100 / 2); + stars[n].offsetY = (float)(rand() % 100 - 100 / 2); + stars[n].offsetR = (float)(rand() % 25 - 25 / 2); + } else { + stars[n].offsetX = 0.0; + stars[n].offsetY = 0.0; + stars[n].offsetR = 0.0; + } +} + +void RotatePoint(float *x, float *y, float rotation) +{ + float tmpX, tmpY; + + tmpX = *x * Cos(rotation) - *y * Sin(rotation); + tmpY = *y * Cos(rotation) + *x * Sin(rotation); + *x = tmpX; + *y = tmpY; +} + +void MoveStars(void) +{ + float offset; + GLint n; + + offset = speed * 60.0; + + for (n = 0; n < starCount; n++) { + stars[n].x[1] = stars[n].x[0]; + stars[n].y[1] = stars[n].y[0]; + stars[n].z[1] = stars[n].z[0]; + stars[n].x[0] += stars[n].offsetX; + stars[n].y[0] += stars[n].offsetY; + stars[n].z[0] -= offset; + stars[n].rotation += stars[n].offsetR; + if (stars[n].rotation > MAXANGLES) { + stars[n].rotation = 0.0; + } + } +} + +GLenum StarPoint(GLint n) +{ + float x0, y0, x1, y1, width; + GLint i; + + x0 = stars[n].x[0] * windW / stars[n].z[0]; + y0 = stars[n].y[0] * windH / stars[n].z[0]; + RotatePoint(&x0, &y0, stars[n].rotation); + x0 += windW / 2.0; + y0 += windH / 2.0; + + if (x0 >= 0.0 && x0 < windW && y0 >= 0.0 && y0 < windH) { + if (stars[n].type == STREAK) { + x1 = stars[n].x[1] * windW / stars[n].z[1]; + y1 = stars[n].y[1] * windH / stars[n].z[1]; + RotatePoint(&x1, &y1, stars[n].rotation); + x1 += windW / 2.0; + y1 += windH / 2.0; + + glLineWidth(MAXPOS/100.0/stars[n].z[0]+1.0); + glColor3f(1.0, (MAXWARP-speed)/MAXWARP, (MAXWARP-speed)/MAXWARP); + if (fabs(x0-x1) < 1.0 && fabs(y0-y1) < 1.0) { + glBegin(GL_POINTS); + glVertex2f(x0, y0); + glEnd(); + } else { + glBegin(GL_LINES); + glVertex2f(x0, y0); + glVertex2f(x1, y1); + glEnd(); + } + } else { + width = MAXPOS / 10.0 / stars[n].z[0] + 1.0; + glColor3f(1.0, 0.0, 0.0); + glBegin(GL_POLYGON); + for (i = 0; i < 8; i++) { + float x = x0 + width * Cos((float)i*MAXANGLES/8.0); + float y = y0 + width * Sin((float)i*MAXANGLES/8.0); + glVertex2f(x, y); + }; + glEnd(); + } + return GL_TRUE; + } else { + return GL_FALSE; + } +} + +void ShowStars(void) +{ + GLint n; + + glClear(GL_COLOR_BUFFER_BIT); + + for (n = 0; n < starCount; n++) { + if (stars[n].z[0] > speed || (stars[n].z[0] > 0.0 && speed < MAXWARP)) { + if (StarPoint(n) == GL_FALSE) { + NewStar(n, MAXPOS); + } + } else { + NewStar(n, MAXPOS); + } + } +} + +static void Init(void) +{ + float angle; + GLint n; + + srand((unsigned int)time(NULL)); + + for (n = 0; n < MAXSTARS; n++) { + NewStar(n, 100); + } + + angle = 0.0; + for (n = 0; n < MAXANGLES ; n++) { + sinTable[n] = sin(angle); + angle += PI / (MAXANGLES / 2.0); + } + + glClearColor(0.0, 0.0, 0.0, 0.0); + + glDisable(GL_DITHER); +} + +void Reshape(int width, int height) +{ + + windW = (GLint)width; + windH = (GLint)height; + + glutUseLayer(GLUT_OVERLAY); + + glViewport(0, 0, windW, windH); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluOrtho2D(-0.5, windW+0.5, -0.5, windH+0.5); + glMatrixMode(GL_MODELVIEW); + overlayInit = GL_FALSE; + + glutUseLayer(GLUT_NORMAL); + + glViewport(0, 0, windW, windH); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluOrtho2D(-0.5, windW+0.5, -0.5, windH+0.5); + glMatrixMode(GL_MODELVIEW); +} + +static void Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + case 32: + flag = (flag == NORMAL) ? WEIRD : NORMAL; + break; + case 't': + nitro = 1; + break; + default: + return; + } +} + +void Idle(void) +{ + + if (overlayInit == GL_FALSE) { + glutUseLayer(GLUT_OVERLAY); + glClear(GL_COLOR_BUFFER_BIT); +/* glColor3f(1.0, 0.0, 0.0);*/ + + glIndexf( 2.0 ); + glBegin(GL_POLYGON); + glVertex2i(windW/4-10, windH/4-10); + glVertex2i(windW/2-10, windH/4-10); + glVertex2i(windW/2-10, windH/2-10); + glVertex2i(windW/4-10, windH/2-10); + glEnd(); + + glIndexf( 0.0 ); + glBegin(GL_POLYGON); + glVertex2i(windW/4, windH/4); + glVertex2i(windW/2, windH/4); + glVertex2i(windW/2, windH/2); + glVertex2i(windW/4, windH/2); + glEnd(); + + glIndexf( 1.0 ); + glBegin(GL_POLYGON); + glVertex2i(windW/4+10, windH/4+10); + glVertex2i(windW/2+10, windH/4+10); + glVertex2i(windW/2+10, windH/2+10); + glVertex2i(windW/4+10, windH/2+10); + glEnd(); + + glutUseLayer(GLUT_NORMAL); + overlayInit = GL_TRUE; + } + + MoveStars(); + ShowStars(); + if (nitro > 0) { + speed = (float)(nitro / 10) + 1.0; + if (speed > MAXWARP) { + speed = MAXWARP; + } + if (++nitro > MAXWARP*10) { + nitro = -nitro; + } + } else if (nitro < 0) { + nitro++; + speed = (float)(-nitro / 10) + 1.0; + if (speed > MAXWARP) { + speed = MAXWARP; + } + } + + glFlush(); + if (doubleBuffer) { + glutSwapBuffers(); + } +} + +static GLenum Args(int argc, char **argv) +{ + GLint i; + + doubleBuffer = GL_TRUE; + + 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; + } + } + return GL_TRUE; +} + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + if (!glutLayerGet(GLUT_OVERLAY_POSSIBLE)) + { + fprintf(stderr, "Overlay not available\n"); + return(1); + } + + if (Args(argc, argv) == GL_FALSE) { + return(1); + } + + windW = 300; + windH = 300; + glutInitWindowPosition(0, 0); glutInitWindowSize( 300, 300); + + type = GLUT_RGB; + type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("Overlay Test") == GL_FALSE) { + return(1); + } + + glutEstablishOverlay(); + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutIdleFunc(Idle); + glutMainLoop(); + return 0; +} diff --git a/progs/samples/point.c b/progs/samples/point.c new file mode 100644 index 00000000000..4cb6ad7d517 --- /dev/null +++ b/progs/samples/point.c @@ -0,0 +1,234 @@ +/* + * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the name of + * Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF + * ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#include +#include +#include +#include + + +#define CI_RED COLOR_RED +#define CI_ANTI_ALIAS_GREEN 16 +#define CI_ANTI_ALIAS_YELLOW 32 +#define CI_ANTI_ALIAS_RED 48 + + +GLenum rgb, doubleBuffer, windType; +GLint windW, windH; + +#include "tkmap.c" + +GLenum mode; +GLint size; +float point[3] = { + 1.0, 1.0, 0.0 +}; + + +static void Init(void) +{ + GLint i; + + glClearColor(0.0, 0.0, 0.0, 0.0); + + glBlendFunc(GL_SRC_ALPHA, GL_ZERO); + + if (!rgb) { + for (i = 0; i < 16; i++) { + glutSetColor(i+CI_ANTI_ALIAS_RED, i/15.0, 0.0, 0.0); + glutSetColor(i+CI_ANTI_ALIAS_YELLOW, i/15.0, i/15.0, 0.0); + glutSetColor(i+CI_ANTI_ALIAS_GREEN, 0.0, i/15.0, 0.0); + } + } + + mode = GL_FALSE; + size = 1; +} + +static void Reshape(int width, int height) +{ + + windW = (GLint)width; + windH = (GLint)height; + + glViewport(0, 0, width, height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluOrtho2D(-windW/2, windW/2, -windH/2, windH/2); + glMatrixMode(GL_MODELVIEW); +} + +static void Key2(int key, int x, int y) +{ + + switch (key) { + case GLUT_KEY_LEFT: + point[0] -= 0.25; + break; + case GLUT_KEY_RIGHT: + point[0] += 0.25; + break; + case GLUT_KEY_UP: + point[1] += 0.25; + break; + case GLUT_KEY_DOWN: + point[1] -= 0.25; + break; + default: + return; + } + + glutPostRedisplay(); +} + +static void Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + case '1': + mode = !mode; + break; + case 'W': + size++; + break; + case 'w': + size--; + if (size < 1) { + size = 1; + } + break; + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + + glClear(GL_COLOR_BUFFER_BIT); + + SetColor(COLOR_YELLOW); + glBegin(GL_LINE_STRIP); + glVertex2f(-windW/2, 0); + glVertex2f(windW/2, 0); + glEnd(); + glBegin(GL_LINE_STRIP); + glVertex2f(0, -windH/2); + glVertex2f(0, windH/2); + glEnd(); + + if (mode) { + glEnable(GL_BLEND); + glEnable(GL_POINT_SMOOTH); + } else { + glDisable(GL_BLEND); + glDisable(GL_POINT_SMOOTH); + } + + glPointSize(size); + if (mode) { + (rgb) ? glColor3f(1.0, 0.0, 0.0) : glIndexf(CI_ANTI_ALIAS_RED); + } else { + (rgb) ? glColor3f(1.0, 0.0, 0.0) : glIndexf(CI_RED); + } + glBegin(GL_POINTS); + glVertex3fv(point); + glEnd(); + + glDisable(GL_POINT_SMOOTH); + glDisable(GL_BLEND); + + glPointSize(1); + SetColor(COLOR_GREEN); + glBegin(GL_POINTS); + glVertex3fv(point); + glEnd(); + + glFlush(); + + if (doubleBuffer) { + glutSwapBuffers(); + } +} + +static GLenum Args(int argc, char **argv) +{ + GLint i; + + rgb = GL_TRUE; + doubleBuffer = GL_FALSE; + + for (i = 1; i < argc; i++) { + if (strcmp(argv[i], "-ci") == 0) { + rgb = GL_FALSE; + } else if (strcmp(argv[i], "-rgb") == 0) { + rgb = GL_TRUE; + } else 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; +} + +int main(int argc, char **argv) +{ + glutInit(&argc, argv); + + if (Args(argc, argv) == GL_FALSE) { + exit(1); + } + + windW = 300; + windH = 300; + glutInitWindowPosition(0, 0); glutInitWindowSize( windW, windH); + + windType = (rgb) ? GLUT_RGB : GLUT_INDEX; + windType |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; + glutInitDisplayMode(windType); + + if (glutCreateWindow("Point Test") == GL_FALSE) { + exit(1); + } + + InitMap(); + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutSpecialFunc(Key2); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/samples/prim.c b/progs/samples/prim.c new file mode 100644 index 00000000000..388e0153b4f --- /dev/null +++ b/progs/samples/prim.c @@ -0,0 +1,546 @@ +#include +#include +#include +#include + + +#define PIXEL_CENTER(x) ((long)(x) + 0.5) + +#define GAP 10 +#define ROWS 3 +#define COLS 4 + +#define OPENGL_WIDTH 48 +#define OPENGL_HEIGHT 13 + + +GLenum rgb, doubleBuffer, windType; +GLint windW, windH; + +GLenum mode1, mode2; +GLint boxW, boxH; +GLubyte OpenGL_bits[] = { + 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, + 0x7f, 0xfb, 0xff, 0xff, 0xff, 0x01, + 0x7f, 0xfb, 0xff, 0xff, 0xff, 0x01, + 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, + 0x3e, 0x8f, 0xb7, 0xf9, 0xfc, 0x01, + 0x63, 0xdb, 0xb0, 0x8d, 0x0d, 0x00, + 0x63, 0xdb, 0xb7, 0x8d, 0x0d, 0x00, + 0x63, 0xdb, 0xb6, 0x8d, 0x0d, 0x00, + 0x63, 0x8f, 0xf3, 0xcc, 0x0d, 0x00, + 0x63, 0x00, 0x00, 0x0c, 0x4c, 0x0a, + 0x63, 0x00, 0x00, 0x0c, 0x4c, 0x0e, + 0x63, 0x00, 0x00, 0x8c, 0xed, 0x0e, + 0x3e, 0x00, 0x00, 0xf8, 0x0c, 0x00, +}; + + +#include "tkmap.c" + +static void Init(void) +{ + + mode1 = GL_TRUE; + mode2 = GL_TRUE; +} + +static void Reshape(int width, int height) +{ + + windW = (GLint)width; + windH = (GLint)height; +} + +static void RotateColorMask(void) +{ + static GLint rotation = 0; + + rotation = (rotation + 1) & 0x3; + switch (rotation) { + case 0: + glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); + glIndexMask( 0xff ); + break; + case 1: + glColorMask(GL_FALSE, GL_TRUE, GL_TRUE, GL_TRUE); + glIndexMask(0xFE); + break; + case 2: + glColorMask(GL_TRUE, GL_FALSE, GL_TRUE, GL_TRUE); + glIndexMask(0xFD); + break; + case 3: + glColorMask(GL_TRUE, GL_TRUE, GL_FALSE, GL_TRUE); + glIndexMask(0xFB); + break; + } +} + +static void Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + case '1': + mode1 = !mode1; + break; + case '2': + mode2 = !mode2; + break; + case '3': + RotateColorMask(); + break; + default: + return; + } + + glutPostRedisplay(); +} + +static void Viewport(GLint row, GLint column) +{ + GLint x, y; + + boxW = (windW - (COLS + 1) * GAP) / COLS; + boxH = (windH - (ROWS + 1) * GAP) / ROWS; + + x = GAP + column * (boxW + GAP); + y = GAP + row * (boxH + GAP); + + glViewport(x, y, boxW, boxH); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-boxW/2, boxW/2, -boxH/2, boxH/2, 0.0, 1.0); + glMatrixMode(GL_MODELVIEW); + + glEnable(GL_SCISSOR_TEST); + glScissor(x, y, boxW, boxH); +} + +static void Point(void) +{ + GLint i; + + glBegin(GL_POINTS); + SetColor(COLOR_WHITE); + glVertex2i(0, 0); + for (i = 1; i < 8; i++) { + GLint j = i * 2; + SetColor(COLOR_BLACK+i); + glVertex2i(-j, -j); + glVertex2i(-j, 0); + glVertex2i(-j, j); + glVertex2i(0, j); + glVertex2i(j, j); + glVertex2i(j, 0); + glVertex2i(j, -j); + glVertex2i(0, -j); + } + glEnd(); +} + +static void Lines(void) +{ + GLint i; + + glPushMatrix(); + + glTranslatef(-12, 0, 0); + for (i = 1; i < 8; i++) { + SetColor(COLOR_BLACK+i); + glBegin(GL_LINES); + glVertex2i(-boxW/4, -boxH/4); + glVertex2i(boxW/4, boxH/4); + glEnd(); + glTranslatef(4, 0, 0); + } + + glPopMatrix(); + + glBegin(GL_LINES); + glVertex2i(0, 0); + glEnd(); +} + +static void LineStrip(void) +{ + + glBegin(GL_LINE_STRIP); + SetColor(COLOR_RED); + glVertex2f(PIXEL_CENTER(-boxW/4), PIXEL_CENTER(-boxH/4)); + SetColor(COLOR_GREEN); + glVertex2f(PIXEL_CENTER(-boxW/4), PIXEL_CENTER(boxH/4)); + SetColor(COLOR_BLUE); + glVertex2f(PIXEL_CENTER(boxW/4), PIXEL_CENTER(boxH/4)); + SetColor(COLOR_WHITE); + glVertex2f(PIXEL_CENTER(boxW/4), PIXEL_CENTER(-boxH/4)); + glEnd(); + + glBegin(GL_LINE_STRIP); + glVertex2i(0, 0); + glEnd(); +} + +static void LineLoop(void) +{ + + glBegin(GL_LINE_LOOP); + SetColor(COLOR_RED); + glVertex2f(PIXEL_CENTER(-boxW/4), PIXEL_CENTER(-boxH/4)); + SetColor(COLOR_GREEN); + glVertex2f(PIXEL_CENTER(-boxW/4), PIXEL_CENTER(boxH/4)); + SetColor(COLOR_BLUE); + glVertex2f(PIXEL_CENTER(boxW/4), PIXEL_CENTER(boxH/4)); + SetColor(COLOR_WHITE); + glVertex2f(PIXEL_CENTER(boxW/4), PIXEL_CENTER(-boxH/4)); + glEnd(); + + glEnable(GL_LOGIC_OP); + glLogicOp(GL_XOR); + + glEnable(GL_BLEND); + glBlendFunc(GL_ONE, GL_ONE); + + SetColor(COLOR_MAGENTA); + glBegin(GL_LINE_LOOP); + glVertex2f(PIXEL_CENTER(-boxW/8), PIXEL_CENTER(-boxH/8)); + glVertex2f(PIXEL_CENTER(-boxW/8), PIXEL_CENTER(boxH/8)); + glEnd(); + glBegin(GL_LINE_LOOP); + glVertex2f(PIXEL_CENTER(-boxW/8), PIXEL_CENTER(boxH/8+5)); + glVertex2f(PIXEL_CENTER(boxW/8), PIXEL_CENTER(boxH/8+5)); + glEnd(); + glDisable(GL_LOGIC_OP); + glDisable(GL_BLEND); + + SetColor(COLOR_GREEN); + glBegin(GL_POINTS); + glVertex2i(0, 0); + glEnd(); + + glBegin(GL_LINE_LOOP); + glVertex2i(0, 0); + glEnd(); +} + +static void Bitmap(void) +{ + + glBegin(GL_LINES); + SetColor(COLOR_GREEN); + glVertex2i(-boxW/2, 0); + glVertex2i(boxW/2, 0); + glVertex2i(0, -boxH/2); + glVertex2i(0, boxH/2); + SetColor(COLOR_RED); + glVertex2i(0, -3); + glVertex2i(0, -3+OPENGL_HEIGHT); + SetColor(COLOR_BLUE); + glVertex2i(0, -3); + glVertex2i(OPENGL_WIDTH, -3); + glEnd(); + + SetColor(COLOR_GREEN); + + glPixelStorei(GL_UNPACK_LSB_FIRST, GL_TRUE); + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + + glRasterPos2i(0, 0); + glBitmap(OPENGL_WIDTH, OPENGL_HEIGHT, 0, 3, 0.0, 0.0, OpenGL_bits); +} + +static void Triangles(void) +{ + + glBegin(GL_TRIANGLES); + SetColor(COLOR_GREEN); + glVertex2i(-boxW/4, -boxH/4); + SetColor(COLOR_RED); + glVertex2i(-boxW/8, -boxH/16); + SetColor(COLOR_BLUE); + glVertex2i(boxW/8, -boxH/16); + + SetColor(COLOR_GREEN); + glVertex2i(-boxW/4, boxH/4); + SetColor(COLOR_RED); + glVertex2i(-boxW/8, boxH/16); + SetColor(COLOR_BLUE); + glVertex2i(boxW/8, boxH/16); + glEnd(); + + glBegin(GL_TRIANGLES); + glVertex2i(0, 0); + glVertex2i(-100, 100); + glEnd(); +} + +static void TriangleStrip(void) +{ + + glBegin(GL_TRIANGLE_STRIP); + SetColor(COLOR_GREEN); + glVertex2i(-boxW/4, -boxH/4); + SetColor(COLOR_RED); + glVertex2i(-boxW/4, boxH/4); + SetColor(COLOR_BLUE); + glVertex2i(0, -boxH/4); + SetColor(COLOR_WHITE); + glVertex2i(0, boxH/4); + SetColor(COLOR_CYAN); + glVertex2i(boxW/4, -boxH/4); + SetColor(COLOR_YELLOW); + glVertex2i(boxW/4, boxH/4); + glEnd(); + + glBegin(GL_TRIANGLE_STRIP); + glVertex2i(0, 0); + glVertex2i(-100, 100); + glEnd(); +} + +static void TriangleFan(void) +{ + GLint vx[8][2]; + GLint x0, y0, x1, y1, x2, y2, x3, y3; + GLint i; + + y0 = -boxH/4; + y1 = y0 + boxH/2/3; + y2 = y1 + boxH/2/3; + y3 = boxH/4; + x0 = -boxW/4; + x1 = x0 + boxW/2/3; + x2 = x1 + boxW/2/3; + x3 = boxW/4; + + vx[0][0] = x0; vx[0][1] = y1; + vx[1][0] = x0; vx[1][1] = y2; + vx[2][0] = x1; vx[2][1] = y3; + vx[3][0] = x2; vx[3][1] = y3; + vx[4][0] = x3; vx[4][1] = y2; + vx[5][0] = x3; vx[5][1] = y1; + vx[6][0] = x2; vx[6][1] = y0; + vx[7][0] = x1; vx[7][1] = y0; + + glBegin(GL_TRIANGLE_FAN); + SetColor(COLOR_WHITE); + glVertex2i(0, 0); + for (i = 0; i < 8; i++) { + SetColor(COLOR_WHITE-i); + glVertex2iv(vx[i]); + } + glEnd(); + + glBegin(GL_TRIANGLE_FAN); + glVertex2i(0, 0); + glVertex2i(-100, 100); + glEnd(); +} + +static void Rect(void) +{ + + SetColor(COLOR_GREEN); + glRecti(-boxW/4, -boxH/4, boxW/4, boxH/4); +} + +static void PolygonFunc(void) +{ + GLint vx[8][2]; + GLint x0, y0, x1, y1, x2, y2, x3, y3; + GLint i; + + y0 = -boxH/4; + y1 = y0 + boxH/2/3; + y2 = y1 + boxH/2/3; + y3 = boxH/4; + x0 = -boxW/4; + x1 = x0 + boxW/2/3; + x2 = x1 + boxW/2/3; + x3 = boxW/4; + + vx[0][0] = x0; vx[0][1] = y1; + vx[1][0] = x0; vx[1][1] = y2; + vx[2][0] = x1; vx[2][1] = y3; + vx[3][0] = x2; vx[3][1] = y3; + vx[4][0] = x3; vx[4][1] = y2; + vx[5][0] = x3; vx[5][1] = y1; + vx[6][0] = x2; vx[6][1] = y0; + vx[7][0] = x1; vx[7][1] = y0; + + glBegin(GL_POLYGON); + for (i = 0; i < 8; i++) { + SetColor(COLOR_WHITE-i); + glVertex2iv(vx[i]); + } + glEnd(); + + glBegin(GL_POLYGON); + glVertex2i(0, 0); + glVertex2i(100, 100); + glEnd(); +} + +static void Quads(void) +{ + + glBegin(GL_QUADS); + SetColor(COLOR_GREEN); + glVertex2i(-boxW/4, -boxH/4); + SetColor(COLOR_RED); + glVertex2i(-boxW/8, -boxH/16); + SetColor(COLOR_BLUE); + glVertex2i(boxW/8, -boxH/16); + SetColor(COLOR_WHITE); + glVertex2i(boxW/4, -boxH/4); + + SetColor(COLOR_GREEN); + glVertex2i(-boxW/4, boxH/4); + SetColor(COLOR_RED); + glVertex2i(-boxW/8, boxH/16); + SetColor(COLOR_BLUE); + glVertex2i(boxW/8, boxH/16); + SetColor(COLOR_WHITE); + glVertex2i(boxW/4, boxH/4); + glEnd(); + + glBegin(GL_QUADS); + glVertex2i(0, 0); + glVertex2i(100, 100); + glVertex2i(-100, 100); + glEnd(); +} + +static void QuadStrip(void) +{ + + glBegin(GL_QUAD_STRIP); + SetColor(COLOR_GREEN); + glVertex2i(-boxW/4, -boxH/4); + SetColor(COLOR_RED); + glVertex2i(-boxW/4, boxH/4); + SetColor(COLOR_BLUE); + glVertex2i(0, -boxH/4); + SetColor(COLOR_WHITE); + glVertex2i(0, boxH/4); + SetColor(COLOR_CYAN); + glVertex2i(boxW/4, -boxH/4); + SetColor(COLOR_YELLOW); + glVertex2i(boxW/4, boxH/4); + glEnd(); + + glBegin(GL_QUAD_STRIP); + glVertex2i(0, 0); + glVertex2i(100, 100); + glVertex2i(-100, 100); + glEnd(); +} + +static void Draw(void) +{ + + glViewport(0, 0, windW, windH); + glDisable(GL_SCISSOR_TEST); + + glPushAttrib(GL_COLOR_BUFFER_BIT); + + glColorMask(1, 1, 1, 1); + glIndexMask(~0); + + glClearColor(0.0, 0.0, 0.0, 0.0); + glClear(GL_COLOR_BUFFER_BIT); + + glPopAttrib(); + + if (mode1) { + glShadeModel(GL_SMOOTH); + } else { + glShadeModel(GL_FLAT); + } + + if (mode2) { + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); + } else { + glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); + } + + Viewport(0, 0); Point(); + Viewport(0, 1); Lines(); + Viewport(0, 2); LineStrip(); + Viewport(0, 3); LineLoop(); + + Viewport(1, 0); Bitmap(); + + Viewport(1, 1); TriangleFan(); + Viewport(1, 2); Triangles(); + Viewport(1, 3); TriangleStrip(); + + Viewport(2, 0); Rect(); + Viewport(2, 1); PolygonFunc(); + Viewport(2, 2); Quads(); + Viewport(2, 3); QuadStrip(); + + glFlush(); + + if (doubleBuffer) { + glutSwapBuffers(); + } +} + +static GLenum Args(int argc, char **argv) +{ + GLint i; + + rgb = GL_TRUE; + doubleBuffer = GL_FALSE; + + for (i = 1; i < argc; i++) { + if (strcmp(argv[i], "-ci") == 0) { + rgb = GL_FALSE; + } else if (strcmp(argv[i], "-rgb") == 0) { + rgb = GL_TRUE; + } else 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; +} + +int main(int argc, char **argv) +{ + glutInit(&argc, argv); + + if (Args(argc, argv) == GL_FALSE) { + exit(1); + } + + windW = 600; + windH = 300; + glutInitWindowPosition(0, 0); glutInitWindowSize( windW, windH); + + windType = (rgb) ? GLUT_RGB : GLUT_INDEX; + windType |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; + glutInitDisplayMode(windType); + + if (glutCreateWindow("Primitive Test") == GL_FALSE) { + exit(1); + } + + InitMap(); + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/samples/quad.c b/progs/samples/quad.c new file mode 100644 index 00000000000..193850abc45 --- /dev/null +++ b/progs/samples/quad.c @@ -0,0 +1,457 @@ +/* + * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the name of + * Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF + * ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#include +#include +#include +#include + + +#ifndef CALLBACK +#define CALLBACK +#endif + + +#define PI 3.141592654 +#define BLACK 0 +#define GRAY 128 +#define WHITE 255 +#define RD 0xA4,0x00,0x00,0xFF +#define WT 0xFF,0xFF,0xFF,0xFF +#define brickImageWidth 16 +#define brickImageHeight 16 + + +#include "loadppm.c" + +GLenum rgb, doubleBuffer; + +#include "tkmap.c" + +float black[3] = { + 0.0, 0.0, 0.0 +}; +float blue[3] = { + 0.0, 0.0, 1.0 +}; +float gray[3] = { + 0.5, 0.5, 0.5 +}; +float white[3] = { + 1.0, 1.0, 1.0 +}; + +GLenum doDither = GL_TRUE; +GLenum shade = GL_TRUE; +GLenum texture = GL_TRUE; + +float xRotation = 30.0, yRotation = 30.0, zRotation = 0.0; +GLint radius1, radius2; +GLdouble angle1, angle2; +GLint slices, stacks; +GLint height; +GLint orientation = GLU_OUTSIDE; +GLint whichQuadric=0; +GLUquadricObj *quadObj; + +GLubyte brickImage[4*brickImageWidth*brickImageHeight] = { + RD, RD, RD, RD, RD, RD, RD, RD, RD, WT, RD, RD, RD, RD, RD, RD, + RD, RD, RD, RD, RD, RD, RD, RD, RD, WT, RD, RD, RD, RD, RD, RD, + RD, RD, RD, RD, RD, RD, RD, RD, RD, WT, RD, RD, RD, RD, RD, RD, + RD, RD, RD, RD, RD, RD, RD, RD, RD, WT, RD, RD, RD, RD, RD, RD, + WT, WT, WT, WT, WT, WT, WT, WT, WT, WT, WT, WT, WT, WT, WT, WT, + RD, RD, RD, WT, RD, RD, RD, RD, RD, RD, RD, RD, RD, WT, RD, RD, + RD, RD, RD, WT, RD, RD, RD, RD, RD, RD, RD, RD, RD, WT, RD, RD, + RD, RD, RD, WT, RD, RD, RD, RD, RD, RD, RD, RD, RD, WT, RD, RD, + RD, RD, RD, WT, RD, RD, RD, RD, RD, RD, RD, RD, RD, WT, RD, RD, + WT, WT, WT, WT, WT, WT, WT, WT, WT, WT, WT, WT, WT, WT, WT, WT, + RD, RD, RD, RD, RD, RD, RD, WT, RD, RD, RD, RD, RD, RD, RD, RD, + RD, RD, RD, RD, RD, RD, RD, WT, RD, RD, RD, RD, RD, RD, RD, RD, + RD, RD, RD, RD, RD, RD, RD, WT, RD, RD, RD, RD, RD, RD, RD, RD, + RD, RD, RD, RD, RD, RD, RD, WT, RD, RD, RD, RD, RD, RD, RD, RD, + WT, WT, WT, WT, WT, WT, WT, WT, WT, WT, WT, WT, WT, WT, WT, WT, + RD, RD, RD, RD, WT, RD, RD, RD, RD, RD, RD, RD, RD, RD, WT, RD +}; +char *texFileName = 0; + + +static void CALLBACK ErrorHandler(GLenum which) +{ + + fprintf(stderr, "Quad Error: %s\n", (char *) gluErrorString(which)); +} + +typedef void (GLAPIENTRY *callback_t)(); + +static void Init(void) +{ + static GLint colorIndexes[3] = {0, 200, 255}; + static float ambient[] = {0.1, 0.1, 0.1, 1.0}; + static float diffuse[] = {0.5, 1.0, 1.0, 1.0}; + static float position[] = {90.0, 90.0, 150.0, 0.0}; + static float front_mat_shininess[] = {30.0}; + static float front_mat_specular[] = {0.2, 0.2, 0.2, 1.0}; + static float front_mat_diffuse[] = {0.5, 0.28, 0.38, 1.0}; + static float back_mat_shininess[] = {50.0}; + static float back_mat_specular[] = {0.5, 0.5, 0.2, 1.0}; + static float back_mat_diffuse[] = {1.0, 1.0, 0.2, 1.0}; + static float lmodel_ambient[] = {1.0, 1.0, 1.0, 1.0}; + static float lmodel_twoside[] = {GL_TRUE}; + static float decal[] = {GL_DECAL}; + static float repeat[] = {GL_REPEAT}; + static float nearest[] = {GL_NEAREST}; + static PPMImage *image; + + if (!rgb) { + SetGreyRamp(); + } + glClearColor(0.0, 0.0, 0.0, 0.0); + + glEnable(GL_DEPTH_TEST); + + glLightfv(GL_LIGHT0, GL_AMBIENT, ambient); + glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse); + glLightfv(GL_LIGHT0, GL_POSITION, position); + glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient); + glLightModelfv(GL_LIGHT_MODEL_TWO_SIDE, lmodel_twoside); + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + + glMaterialfv(GL_FRONT, GL_SHININESS, front_mat_shininess); + glMaterialfv(GL_FRONT, GL_SPECULAR, front_mat_specular); + glMaterialfv(GL_FRONT, GL_DIFFUSE, front_mat_diffuse); + glMaterialfv(GL_BACK, GL_SHININESS, back_mat_shininess); + glMaterialfv(GL_BACK, GL_SPECULAR, back_mat_specular); + glMaterialfv(GL_BACK, GL_DIFFUSE, back_mat_diffuse); + if (!rgb) { + glMaterialiv( GL_FRONT_AND_BACK, GL_COLOR_INDEXES, colorIndexes); + } + + glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, decal); + glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, repeat); + glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, repeat); + glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, nearest); + glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, nearest); + if (texFileName) { + image = LoadPPM(texFileName); + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + gluBuild2DMipmaps(GL_TEXTURE_2D, 3, image->sizeX, image->sizeY, + GL_RGB, GL_UNSIGNED_BYTE, image->data); + } else { + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + glTexImage2D(GL_TEXTURE_2D, 0, 4, brickImageWidth, brickImageHeight, + 0, GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid *)brickImage); + } + + quadObj = gluNewQuadric(); + gluQuadricCallback(quadObj, GLU_ERROR, (callback_t) ErrorHandler); + + radius1 = 10; + radius2 = 5; + angle1 = 90; + angle2 = 180; + slices = 16; + stacks = 10; + height = 20; +} + +static void Reshape(int width, int height) +{ + + glViewport(0, 0, (GLint)width, (GLint)height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glFrustum(-1, 1, -1, 1, 1, 10); + gluLookAt(2, 2, 2, 0, 0, 0, 0, 0, 1); + glMatrixMode(GL_MODELVIEW); +} + +static void Key2(int key, int x, int y) +{ + + switch (key) { + case GLUT_KEY_LEFT: + yRotation += 5; + break; + case GLUT_KEY_RIGHT: + yRotation -= 5; + break; + case GLUT_KEY_UP: + xRotation += 5; + break; + case GLUT_KEY_DOWN: + xRotation -= 5; + break; + default: + return; + } + + glutPostRedisplay(); +} + +static void Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + + case 'X': + zRotation += 5; + break; + case 'x': + zRotation -= 5; + break; + + case '1': + gluQuadricDrawStyle(quadObj, GLU_FILL); + break; + case '2': + gluQuadricDrawStyle(quadObj, GLU_POINT); + break; + case '3': + gluQuadricDrawStyle(quadObj, GLU_LINE); + break; + case '4': + gluQuadricDrawStyle(quadObj, GLU_SILHOUETTE); + break; + + case '0': + shade = !shade; + if (shade) { + glShadeModel(GL_SMOOTH); + gluQuadricNormals(quadObj, GLU_SMOOTH); + } else { + glShadeModel(GL_FLAT); + gluQuadricNormals(quadObj, GLU_FLAT); + } + break; + + case 'A': + stacks++; + break; + case 'a': + stacks--; + break; + + case 'S': + slices++; + break; + case 's': + slices--; + break; + + case 'd': + switch(orientation) { + case GLU_OUTSIDE: + orientation = GLU_INSIDE; + break; + case GLU_INSIDE: + default: + orientation = GLU_OUTSIDE; + break; + } + gluQuadricOrientation(quadObj, orientation); + break; + + case 'f': + whichQuadric = (whichQuadric + 1) % 4; + break; + + case 'G': + radius1 += 1; + break; + case 'g': + radius1 -= 1; + break; + + case 'J': + radius2 += 1; + break; + case 'j': + radius2 -= 1; + break; + + case 'H': + height += 2; + break; + case 'h': + height -= 2; + break; + + case 'K': + angle1 += 5; + break; + case 'k': + angle1 -= 5; + break; + + case 'L': + angle2 += 5; + break; + case 'l': + angle2 -= 5; + break; + + case 'z': + texture = !texture; + if (texture) { + gluQuadricTexture(quadObj, GL_TRUE); + glEnable(GL_TEXTURE_2D); + } else { + gluQuadricTexture(quadObj, GL_FALSE); + glDisable(GL_TEXTURE_2D); + } + break; + + case 'q': + glDisable(GL_CULL_FACE); + break; + case 'w': + glEnable(GL_CULL_FACE); + glCullFace(GL_FRONT); + break; + case 'e': + glEnable(GL_CULL_FACE); + glCullFace(GL_BACK); + break; + + case 'r': + glFrontFace(GL_CW); + break; + case 't': + glFrontFace(GL_CCW); + break; + + case 'y': + doDither = !doDither; + (doDither) ? glEnable(GL_DITHER) : glDisable(GL_DITHER); + break; + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + + glLoadIdentity(); + glRotatef(xRotation, 1, 0, 0); + glRotatef(yRotation, 0, 1, 0); + glRotatef(zRotation, 0, 0, 1); + + glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); + + glColor3f(1.0, 1.0, 1.0); + switch (whichQuadric) { + case 0: + glTranslatef(0, 0, -height/20.0); + gluCylinder(quadObj, radius1/10.0, radius2/10.0, height/10.0, + slices, stacks); + break; + case 1: + gluSphere(quadObj, radius1/10.0, slices, stacks); + break; + case 2: + gluPartialDisk(quadObj, radius2/10.0, radius1/10.0, slices, + stacks, angle1, angle2); + break; + case 3: + gluDisk(quadObj, radius2/10.0, radius1/10.0, slices, stacks); + break; + } + + glFlush(); + + if (doubleBuffer) { + glutSwapBuffers(); + } +} + +static GLenum Args(int argc, char **argv) +{ + GLint i; + + rgb = GL_TRUE; + doubleBuffer = GL_FALSE; + + for (i = 1; i < argc; i++) { + if (strcmp(argv[i], "-ci") == 0) { + rgb = GL_FALSE; + } else if (strcmp(argv[i], "-rgb") == 0) { + rgb = GL_TRUE; + } else if (strcmp(argv[i], "-sb") == 0) { + doubleBuffer = GL_FALSE; + } else if (strcmp(argv[i], "-db") == 0) { + doubleBuffer = GL_TRUE; + } else if (strcmp(argv[i], "-f") == 0) { + if (i+1 >= argc || argv[i+1][0] == '-') { + printf("-f (No file name).\n"); + return GL_FALSE; + } else { + texFileName = argv[++i]; + } + } else { + printf("%s (Bad option).\n", argv[i]); + return GL_FALSE; + } + } + return GL_TRUE; +} + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + if (Args(argc, argv) == GL_FALSE) { + exit(1); + } + + glutInitWindowPosition(0, 0); glutInitWindowSize( 300, 300); + + type = GLUT_DEPTH; + type |= (rgb) ? GLUT_RGB : GLUT_INDEX; + type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("Quad Test") == GL_FALSE) { + exit(1); + } + + InitMap(); + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutSpecialFunc(Key2); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/samples/rgbtoppm.c b/progs/samples/rgbtoppm.c new file mode 100644 index 00000000000..116d9a8cfa5 --- /dev/null +++ b/progs/samples/rgbtoppm.c @@ -0,0 +1,285 @@ + +/* texture.c - by David Blythe, SGI */ + +/* texload is a simplistic routine for reading an SGI .rgb image file. */ + +#include +#include +#include + +#include + +typedef struct _ImageRec { + unsigned short imagic; + unsigned short type; + unsigned short dim; + unsigned short xsize, ysize, zsize; + unsigned int min, max; + unsigned int wasteBytes; + char name[80]; + unsigned long colorMap; + FILE *file; + unsigned char *tmp; + unsigned long rleEnd; + unsigned int *rowStart; + int *rowSize; +} ImageRec; + +void +rgbtorgb(unsigned char *r,unsigned char *g,unsigned char *b,unsigned char *l,int n) { + while(n--) { + l[0] = r[0]; + l[1] = g[0]; + l[2] = b[0]; + l += 3; r++; g++; b++; + } +} + +static void +ConvertShort(unsigned short *array, unsigned int length) { + unsigned short b1, b2; + unsigned char *ptr; + + ptr = (unsigned char *)array; + while (length--) { + b1 = *ptr++; + b2 = *ptr++; + *array++ = (b1 << 8) | (b2); + } +} + +static void +ConvertUint(unsigned *array, unsigned int length) { + unsigned int b1, b2, b3, b4; + unsigned char *ptr; + + ptr = (unsigned char *)array; + while (length--) { + b1 = *ptr++; + b2 = *ptr++; + b3 = *ptr++; + b4 = *ptr++; + *array++ = (b1 << 24) | (b2 << 16) | (b3 << 8) | (b4); + } +} + +static ImageRec *ImageOpen(char *fileName) +{ + union { + int testWord; + char testByte[4]; + } endianTest; + ImageRec *image; + int swapFlag; + int x; + + endianTest.testWord = 1; + if (endianTest.testByte[0] == 1) { + swapFlag = 1; + } else { + swapFlag = 0; + } + + image = (ImageRec *)malloc(sizeof(ImageRec)); + if (image == NULL) { + fprintf(stderr, "Out of memory!\n"); + exit(1); + } + if ((image->file = fopen(fileName, "rb")) == NULL) { + return NULL; + } + + fread(image, 1, 12, image->file); + + if (swapFlag) { + ConvertShort(&image->imagic, 6); + } + + image->tmp = (unsigned char *)malloc(image->xsize*256); + if (image->tmp == NULL) { + fprintf(stderr, "\nOut of memory!\n"); + exit(1); + } + + if ((image->type & 0xFF00) == 0x0100) { + x = image->ysize * image->zsize * (int) sizeof(unsigned); + image->rowStart = (unsigned *)malloc(x); + image->rowSize = (int *)malloc(x); + if (image->rowStart == NULL || image->rowSize == NULL) { + fprintf(stderr, "\nOut of memory!\n"); + exit(1); + } + image->rleEnd = 512 + (2 * x); + fseek(image->file, 512, SEEK_SET); + fread(image->rowStart, 1, x, image->file); + fread(image->rowSize, 1, x, image->file); + if (swapFlag) { + ConvertUint(image->rowStart, x/(int) sizeof(unsigned)); + ConvertUint((unsigned *)image->rowSize, x/(int) sizeof(int)); + } + } + return image; +} + +static void +ImageClose(ImageRec *image) { + fclose(image->file); + free(image->tmp); + free(image); +} + +static void +ImageGetRow(ImageRec *image, unsigned char *buf, int y, int z) { + unsigned char *iPtr, *oPtr, pixel; + int count; + + if ((image->type & 0xFF00) == 0x0100) { + fseek(image->file, (long) image->rowStart[y+z*image->ysize], SEEK_SET); + fread(image->tmp, 1, (unsigned int)image->rowSize[y+z*image->ysize], + image->file); + + iPtr = image->tmp; + oPtr = buf; + for (;;) { + pixel = *iPtr++; + count = (int)(pixel & 0x7F); + if (!count) { + return; + } + if (pixel & 0x80) { + while (count--) { + *oPtr++ = *iPtr++; + } + } else { + pixel = *iPtr++; + while (count--) { + *oPtr++ = pixel; + } + } + } + } else { + fseek(image->file, 512+(y*image->xsize)+(z*image->xsize*image->ysize), + SEEK_SET); + fread(buf, 1, image->xsize, image->file); + } +} + +GLubyte * +read_alpha_texture(char *name, int *width, int *height) +{ + unsigned char *base, *lptr; + ImageRec *image; + int y; + + image = ImageOpen(name); + if(!image) { + return NULL; + } + + (*width)=image->xsize; + (*height)=image->ysize; + if (image->zsize != 1) { + ImageClose(image); + return NULL; + } + + base = (unsigned char *)malloc(image->xsize*image->ysize*sizeof(unsigned char)); + lptr = base; + for(y=0; yysize; y++) { + ImageGetRow(image,lptr,y,0); + lptr += image->xsize; + } + ImageClose(image); + + return (unsigned char *) base; +} + +GLubyte * +read_rgb_texture(char *name, int *width, int *height) +{ + unsigned char *base, *ptr; + unsigned char *rbuf, *gbuf, *bbuf, *abuf; + ImageRec *image; + int y; + + image = ImageOpen(name); + + if(!image) + return NULL; + (*width)=image->xsize; + (*height)=image->ysize; + if (image->zsize != 3 && image->zsize != 4) { + ImageClose(image); + return NULL; + } + + base = (unsigned char*)malloc(image->xsize*image->ysize*sizeof(unsigned int)*3); + rbuf = (unsigned char *)malloc(image->xsize*sizeof(unsigned char)); + gbuf = (unsigned char *)malloc(image->xsize*sizeof(unsigned char)); + bbuf = (unsigned char *)malloc(image->xsize*sizeof(unsigned char)); + abuf = (unsigned char *)malloc(image->xsize*sizeof(unsigned char)); + if(!base || !rbuf || !gbuf || !bbuf || !abuf) { + if (base) free(base); + if (rbuf) free(rbuf); + if (gbuf) free(gbuf); + if (bbuf) free(bbuf); + if (abuf) free(abuf); + return NULL; + } + ptr = base; + for(y=0; yysize; y++) { + if(image->zsize == 4) { + ImageGetRow(image,rbuf,y,0); + ImageGetRow(image,gbuf,y,1); + ImageGetRow(image,bbuf,y,2); + ImageGetRow(image,abuf,y,3); /* Discard. */ + rgbtorgb(rbuf,gbuf,bbuf,ptr,image->xsize); + ptr += (image->xsize * 3); + } else { + ImageGetRow(image,rbuf,y,0); + ImageGetRow(image,gbuf,y,1); + ImageGetRow(image,bbuf,y,2); + rgbtorgb(rbuf,gbuf,bbuf,ptr,image->xsize); + ptr += (image->xsize * 3); + } + } + ImageClose(image); + free(rbuf); + free(gbuf); + free(bbuf); + free(abuf); + + return (GLubyte *) base; +} + +int main(int argc, char **argv) +{ + int width, height; + GLubyte *data; + char buff[32]; + int n; + FILE *fo; + + if (argc != 3) + { + fprintf(stderr, "usage: %s \n", argv[0]); + return 1; + } + + data = read_rgb_texture(argv[1], &width, &height); + + n = sprintf(buff, "P6\n%d %d\n255\n", width, height); + + /* [dBorca] avoid LF to CRLF conversion */ + if ((fo = fopen(argv[2], "wb")) == NULL) { + fprintf(stderr, "Cannot open output file!\n"); + exit(1); + } + + fwrite(buff, n, 1, fo); + fwrite(data, width * 3, height, fo); + + fclose(fo); + + return 0; +} diff --git a/progs/samples/select.c b/progs/samples/select.c new file mode 100644 index 00000000000..2c8f333bfa9 --- /dev/null +++ b/progs/samples/select.c @@ -0,0 +1,456 @@ +/* + * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the name of + * Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF + * ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#include +#include +#include +#include +#include +#include + + +#define MAXOBJS 10000 +#define MAXSELECT 100 +#define MAXFEED 300 +#define SOLID 1 +#define LINE 2 +#define POINT 3 + + +GLint windW, windH; + +GLuint selectBuf[MAXSELECT]; +GLfloat feedBuf[MAXFEED]; +GLint vp[4]; +float zRotation = 90.0; +float zoom = 1.0; +GLint objectCount; +GLint numObjects; +struct object { + float v1[2]; + float v2[2]; + float v3[2]; + float color[3]; +} objects[MAXOBJS]; +GLenum linePoly = GL_FALSE; + + +static void InitObjects(GLint num) +{ + GLint i; + float x, y; + + if (num > MAXOBJS) { + num = MAXOBJS; + } + if (num < 1) { + num = 1; + } + objectCount = num; + + srand((unsigned int)time(NULL)); + for (i = 0; i < num; i++) { + x = (rand() % 300) - 150; + y = (rand() % 300) - 150; + + objects[i].v1[0] = x + (rand() % 50) - 25; + objects[i].v2[0] = x + (rand() % 50) - 25; + objects[i].v3[0] = x + (rand() % 50) - 25; + objects[i].v1[1] = y + (rand() % 50) - 25; + objects[i].v2[1] = y + (rand() % 50) - 25; + objects[i].v3[1] = y + (rand() % 50) - 25; + objects[i].color[0] = ((rand() % 100) + 50) / 150.0; + objects[i].color[1] = ((rand() % 100) + 50) / 150.0; + objects[i].color[2] = ((rand() % 100) + 50) / 150.0; + } +} + +static void Init(void) +{ + + numObjects = 10; + InitObjects(numObjects); + glGetIntegerv(GL_VIEWPORT, vp); +} + +static void Reshape(int width, int height) +{ + + windW = (GLint)width; + windH = (GLint)height; +} + +static void Render(GLenum mode) +{ + GLint i; + + for (i = 0; i < objectCount; i++) { + if (mode == GL_SELECT) { + glLoadName(i); + } + glColor3fv(objects[i].color); + glBegin(GL_POLYGON); + glVertex2fv(objects[i].v1); + glVertex2fv(objects[i].v2); + glVertex2fv(objects[i].v3); + glEnd(); + } +} + +static GLint DoSelect(GLint x, GLint y) +{ + GLint hits; + + glSelectBuffer(MAXSELECT, selectBuf); + (void)glRenderMode(GL_SELECT); + glInitNames(); + glPushName(~0); + + glPushMatrix(); + + glViewport(0, 0, windW, windH); + glGetIntegerv(GL_VIEWPORT, vp); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluPickMatrix(x, windH-y, 4, 4, vp); + gluOrtho2D(-175, 175, -175, 175); + glMatrixMode(GL_MODELVIEW); + + glClearColor(0.0, 0.0, 0.0, 0.0); + glClear(GL_COLOR_BUFFER_BIT); + + glScalef(zoom, zoom, zoom); + glRotatef(zRotation, 0, 0, 1); + + Render(GL_SELECT); + + glPopMatrix(); + + hits = glRenderMode(GL_RENDER); + if (hits <= 0) { + return -1; + } + + return selectBuf[(hits-1)*4+3]; +} + +static void RecolorTri(GLint h) +{ + + objects[h].color[0] = ((rand() % 100) + 50) / 150.0; + objects[h].color[1] = ((rand() % 100) + 50) / 150.0; + objects[h].color[2] = ((rand() % 100) + 50) / 150.0; +} + +static void DeleteTri(GLint h) +{ + + objects[h] = objects[objectCount-1]; + objectCount--; +} + +static void GrowTri(GLint h) +{ + float v[2]; + float *oldV = NULL; + GLint i; + + v[0] = objects[h].v1[0] + objects[h].v2[0] + objects[h].v3[0]; + v[1] = objects[h].v1[1] + objects[h].v2[1] + objects[h].v3[1]; + v[0] /= 3; + v[1] /= 3; + + for (i = 0; i < 3; i++) { + switch (i) { + case 0: + oldV = objects[h].v1; + break; + case 1: + oldV = objects[h].v2; + break; + case 2: + oldV = objects[h].v3; + break; + } + oldV[0] = 1.5 * (oldV[0] - v[0]) + v[0]; + oldV[1] = 1.5 * (oldV[1] - v[1]) + v[1]; + } +} + +static void Mouse(int button, int state, int mouseX, int mouseY) +{ + GLint hit; + + if (state != GLUT_DOWN) + return; + + hit = DoSelect((GLint)mouseX, (GLint)mouseY); + if (hit != -1) { + if (button == GLUT_LEFT_BUTTON) { + RecolorTri(hit); + } + if (button == GLUT_MIDDLE_BUTTON) { + GrowTri(hit); + } + if (button == GLUT_RIGHT_BUTTON) { + DeleteTri(hit); + } + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + + glPushMatrix(); + + glViewport(0, 0, windW, windH); + glGetIntegerv(GL_VIEWPORT, vp); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluOrtho2D(-175, 175, -175, 175); + glMatrixMode(GL_MODELVIEW); + + glClearColor(0.0, 0.0, 0.0, 0.0); + glClear(GL_COLOR_BUFFER_BIT); + + glScalef(zoom, zoom, zoom); + glRotatef(zRotation, 0, 0, 1); + + Render(GL_RENDER); + + glPopMatrix(); + + glFlush(); +} + +static void DrawZoom(GLint x, GLint y) +{ + + glPushMatrix(); + + glViewport(0, 0, windW, windH); + glGetIntegerv(GL_VIEWPORT, vp); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluPickMatrix(x, windH-y, 4, 4, vp); + gluOrtho2D(-175, 175, -175, 175); + glMatrixMode(GL_MODELVIEW); + + glClearColor(0.0, 0.0, 0.0, 0.0); + glClear(GL_COLOR_BUFFER_BIT); + + glScalef(zoom, zoom, zoom); + glRotatef(zRotation, 0, 0, 1); + + Render(GL_RENDER); + + glPopMatrix(); +} + +static void DumpFeedbackVert(GLint *i, GLint n) +{ + GLint index; + + index = *i; + if (index+7 > n) { + *i = n; + printf(" ???\n"); + return; + } + printf(" (%g %g %g), color = (%4.2f %4.2f %4.2f)\n", + feedBuf[index], + feedBuf[index+1], + feedBuf[index+2], + feedBuf[index+3], + feedBuf[index+4], + feedBuf[index+5]); + index += 7; + *i = index; +} + +static void DrawFeedback(GLint n) +{ + GLint i; + GLint verts; + + printf("Feedback results (%d floats):\n", n); + for (i = 0; i < n; i++) { + switch ((GLint)feedBuf[i]) { + case GL_POLYGON_TOKEN: + printf("Polygon"); + i++; + if (i < n) { + verts = (GLint)feedBuf[i]; + i++; + printf(": %d vertices", verts); + } else { + verts = 0; + } + printf("\n"); + while (verts) { + DumpFeedbackVert(&i, n); + verts--; + } + i--; + break; + case GL_LINE_TOKEN: + printf("Line:\n"); + i++; + DumpFeedbackVert(&i, n); + DumpFeedbackVert(&i, n); + i--; + break; + case GL_LINE_RESET_TOKEN: + printf("Line Reset:\n"); + i++; + DumpFeedbackVert(&i, n); + DumpFeedbackVert(&i, n); + i--; + break; + default: + printf("%9.2f\n", feedBuf[i]); + break; + } + } + if (i == MAXFEED) { + printf("...\n"); + } + printf("\n"); +} + +static void DoFeedback(void) +{ + GLint x; + + glFeedbackBuffer(MAXFEED, GL_3D_COLOR, feedBuf); + (void)glRenderMode(GL_FEEDBACK); + + glPushMatrix(); + + glViewport(0, 0, windW, windH); + glGetIntegerv(GL_VIEWPORT, vp); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluOrtho2D(-175, 175, -175, 175); + glMatrixMode(GL_MODELVIEW); + + glClearColor(0.0, 0.0, 0.0, 0.0); + glClear(GL_COLOR_BUFFER_BIT); + + glScalef(zoom, zoom, zoom); + glRotatef(zRotation, 0, 0, 1); + + Render(GL_FEEDBACK); + + glPopMatrix(); + + x = glRenderMode(GL_RENDER); + if (x == -1) { + x = MAXFEED; + } + + DrawFeedback((GLint)x); +} + +static void Key2(int key, int x, int y) +{ + switch (key) { + case GLUT_KEY_LEFT: + zRotation += 0.5; + break; + case GLUT_KEY_RIGHT: + zRotation -= 0.5; + break; + default: + return; + } + + glutPostRedisplay(); +} + +static void Key(unsigned char key, int x, int y) +{ + switch (key) { + case 27: + exit(1); + case 'Z': + zoom /= 0.75; + break; + case 'z': + zoom *= 0.75; + break; + case 'f': + DoFeedback(); + break; + case 'd': + DrawZoom(x, y); + break; + case 'l': + linePoly = !linePoly; + if (linePoly) { + glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); + } else { + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); + } + break; + default: + return; + } + + glutPostRedisplay(); +} + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + windW = 300; + windH = 300; + glutInitWindowPosition(0, 0); glutInitWindowSize( windW, windH); + + type = GLUT_RGB | GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("Select Test") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutSpecialFunc(Key2); + glutMouseFunc(Mouse); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/samples/shape.c b/progs/samples/shape.c new file mode 100644 index 00000000000..d342ee5b07b --- /dev/null +++ b/progs/samples/shape.c @@ -0,0 +1,345 @@ +/* + * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the name of + * Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF + * ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#include +#include +#include +#include + + +#define OPENGL_WIDTH 24 +#define OPENGL_HEIGHT 13 + + +GLenum rgb, doubleBuffer, windType; +GLint objectIndex = 0; +GLuint bases[20]; +float angleX = 0.0, angleY = 0.0, angleZ = 0.0; +float scaleX = 1.0, scaleY = 1.0, scaleZ = 1.0; +float shiftX = 0.0, shiftY = 0.0, shiftZ = 0.0; + + +#include "tkmap.c" + +static void Init(void) +{ + + bases[0] = glGenLists(1); + glNewList(bases[0], GL_COMPILE); + glutWireSphere(1.0, 20, 10); + glEndList(); + + bases[1] = glGenLists(1); + glNewList(bases[1], GL_COMPILE); + glutSolidSphere(1.0, 20, 10); + glEndList(); + + bases[2] = glGenLists(1); + glNewList(bases[2], GL_COMPILE); + glutWireCube(1.0); + glEndList(); + + bases[3] = glGenLists(1); + glNewList(bases[3], GL_COMPILE); + glutSolidCube(1.0); + glEndList(); + + bases[4] = glGenLists(1); + glNewList(bases[4], GL_COMPILE); + glutWireTorus(1.0, 1.0, 10, 20); + glEndList(); + + bases[5] = glGenLists(1); + glNewList(bases[5], GL_COMPILE); + glutSolidTorus(1.0, 1.0, 10, 20); + glEndList(); + + bases[6] = glGenLists(1); + glNewList(bases[6], GL_COMPILE); + glutWireIcosahedron(); + glEndList(); + + bases[7] = glGenLists(1); + glNewList(bases[7], GL_COMPILE); + glutSolidIcosahedron(); + glEndList(); + + bases[8] = glGenLists(1); + glNewList(bases[8], GL_COMPILE); + glutWireOctahedron(); + glEndList(); + + bases[9] = glGenLists(1); + glNewList(bases[9], GL_COMPILE); + glutSolidOctahedron(); + glEndList(); + + bases[10] = glGenLists(1); + glNewList(bases[10], GL_COMPILE); + glutWireTetrahedron(); + glEndList(); + + bases[11] = glGenLists(1); + glNewList(bases[11], GL_COMPILE); + glutSolidTetrahedron(); + glEndList(); + + bases[12] = glGenLists(1); + glNewList(bases[12], GL_COMPILE); + glutWireDodecahedron(); + glEndList(); + + bases[13] = glGenLists(1); + glNewList(bases[13], GL_COMPILE); + glutSolidDodecahedron(); + glEndList(); + + bases[14] = glGenLists(1); + glNewList(bases[14], GL_COMPILE); + glutWireCone(5.0, 5.0, 20, 10); + glEndList(); + + bases[15] = glGenLists(1); + glNewList(bases[15], GL_COMPILE); + glutSolidCone(5.0, 5.0, 20, 10); + glEndList(); + + bases[16] = glGenLists(1); + glNewList(bases[16], GL_COMPILE); + glutWireTeapot(1.0); + glEndList(); + + bases[17] = glGenLists(1); + glNewList(bases[17], GL_COMPILE); + glutSolidTeapot(1.0); + glEndList(); + + glClearColor(0.0, 0.0, 0.0, 0.0); + glClearIndex(0.0); +} + +static void Reshape(int width, int height) +{ + + glViewport(0, 0, (GLint)width, (GLint)height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-400.0, 400.0, -200.0, 200.0, -400.0, 400.0); + glMatrixMode(GL_MODELVIEW); +} + +static void Key2(int key, int x, int y) +{ + + switch (key) { + case GLUT_KEY_LEFT: + shiftX -= 20.0; + break; + case GLUT_KEY_RIGHT: + shiftX += 20.0; + break; + case GLUT_KEY_UP: + shiftY += 20.0; + break; + case GLUT_KEY_DOWN: + shiftY -= 20.0; + break; + default: + return; + } + + glutPostRedisplay(); +} + +static void Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + + case 32: + objectIndex++; + if (objectIndex > 17) { + objectIndex = 0; + } + break; + + case 'n': + shiftZ += 20.0; + break; + case 'm': + shiftZ -= 20.0; + break; + + case 'q': + scaleX -= 0.1; + if (scaleX < 0.1) { + scaleX = 0.1; + } + break; + case 'w': + scaleX += 0.1; + break; + case 'a': + scaleY -= 0.1; + if (scaleY < 0.1) { + scaleY = 0.1; + } + break; + case 's': + scaleY += 0.1; + break; + case 'z': + scaleZ -= 0.1; + if (scaleZ < 0.1) { + scaleZ = 0.1; + } + break; + case 'x': + scaleZ += 0.1; + break; + + case 'e': + angleX -= 5.0; + if (angleX < 0.0) { + angleX = 360.0 + angleX; + } + break; + case 'r': + angleX += 5.0; + if (angleX > 360.0) { + angleX = angleX - 360.0; + } + break; + case 'd': + angleY -= 5.0; + if (angleY < 0.0) { + angleY = 360.0 + angleY; + } + break; + case 'f': + angleY += 5.0; + if (angleY > 360.0) { + angleY = angleY - 360.0; + } + break; + case 'c': + angleZ -= 5.0; + if (angleZ < 0.0) { + angleZ = 360.0 + angleZ; + } + break; + case 'v': + angleZ += 5.0; + if (angleZ > 360.0) { + angleZ = angleZ - 360.0; + } + break; + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + + glClear(GL_COLOR_BUFFER_BIT); + + SetColor(COLOR_WHITE); + + glPushMatrix(); + + glTranslatef(shiftX, shiftY, shiftZ); + glRotatef(angleX, 1.0, 0.0, 0.0); + glRotatef(angleY, 0.0, 1.0, 0.0); + glRotatef(angleZ, 0.0, 0.0, 1.0); + glScalef(scaleX, scaleY, scaleZ); + + glCallList(bases[objectIndex]); + glPopMatrix(); + + glFlush(); + + if (doubleBuffer) { + glutSwapBuffers(); + } +} + +static GLenum Args(int argc, char **argv) +{ + GLint i; + + rgb = GL_TRUE; + doubleBuffer = GL_FALSE; + + for (i = 1; i < argc; i++) { + if (strcmp(argv[i], "-ci") == 0) { + rgb = GL_FALSE; + } else if (strcmp(argv[i], "-rgb") == 0) { + rgb = GL_TRUE; + } else 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; +} + +int main(int argc, char **argv) +{ + glutInit(&argc, argv); + + if (Args(argc, argv) == GL_FALSE) { + exit(1); + } + + glutInitWindowPosition(0, 0); glutInitWindowSize( 400, 400); + + windType = (rgb) ? GLUT_RGB : GLUT_INDEX; + windType |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; + glutInitDisplayMode(windType); + + if (glutCreateWindow("Font Test") == GL_FALSE) { + exit(1); + } + + InitMap(); + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutSpecialFunc(Key2); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/samples/sphere.c b/progs/samples/sphere.c new file mode 100644 index 00000000000..7d0508dee9f --- /dev/null +++ b/progs/samples/sphere.c @@ -0,0 +1,1014 @@ +/* + * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the name of + * Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF + * ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +/* BEP: renamed "nearest" as "nnearest" to avoid math.h collision on AIX */ + +#include +#include +#include +#include +#include +#include "readtex.h" + + +#ifndef PI +#define PI 3.14159265358979323846 +#endif + + +GLenum doubleBuffer; +int W = 400, H = 400; + +char *imageFileName = "../images/reflect.rgb"; + +float *minFilter, *magFilter, *sWrapMode, *tWrapMode; +float decal[] = {GL_DECAL}; +float modulate[] = {GL_MODULATE}; +float repeat[] = {GL_REPEAT}; +float clamp[] = {GL_CLAMP}; +float nnearest[] = {GL_NEAREST}; +float linear[] = {GL_LINEAR}; +float nearest_mipmap_nearest[] = {GL_NEAREST_MIPMAP_NEAREST}; +float nearest_mipmap_linear[] = {GL_NEAREST_MIPMAP_LINEAR}; +float linear_mipmap_nearest[] = {GL_LINEAR_MIPMAP_NEAREST}; +float linear_mipmap_linear[] = {GL_LINEAR_MIPMAP_LINEAR}; +GLint sphereMap[] = {GL_SPHERE_MAP}; + +float xRotation = 0.0, yRotation = 0.0; +float zTranslate = -3.0; +GLenum autoRotate = GL_TRUE; +GLboolean isLit = GL_TRUE; +GLboolean isFogged = GL_FALSE; +GLboolean doTexture = GL_TRUE; +float *textureEnvironment = modulate; + +int cube, cage, cylinder, torus, genericObject; + +float c[6][4][4][3] = { + { + { + { + 1.0, 1.0, -1.0 + }, + { + 0.0, 1.0, -1.0 + }, + { + 0.0, 0.0, -1.0 + }, + { + 1.0, 0.0, -1.0 + }, + }, + { + { + 0.0, 1.0, -1.0 + }, + { + -1.0, 1.0, -1.0 + }, + { + -1.0, 0.0, -1.0 + }, + { + 0.0, 0.0, -1.0 + }, + }, + { + { + 0.0, 0.0, -1.0 + }, + { + -1.0, 0.0, -1.0 + }, + { + -1.0, -1.0, -1.0 + }, + { + 0.0, -1.0, -1.0 + }, + }, + { + { + 1.0, 0.0, -1.0 + }, + { + 0.0, 0.0, -1.0 + }, + { + 0.0, -1.0, -1.0 + }, + { + 1.0, -1.0, -1.0 + }, + }, + }, + { + { + { + 1.0, 1.0, 1.0 + }, + { + 1.0, 1.0, 0.0 + }, + { + 1.0, 0.0, 0.0 + }, + { + 1.0, 0.0, 1.0 + }, + }, + { + { + 1.0, 1.0, 0.0 + }, + { + 1.0, 1.0, -1.0 + }, + { + 1.0, 0.0, -1.0 + }, + { + 1.0, 0.0, 0.0 + }, + }, + { + { + 1.0, 0.0, -1.0 + }, + { + 1.0, -1.0, -1.0 + }, + { + 1.0, -1.0, 0.0 + }, + { + 1.0, 0.0, 0.0 + }, + }, + { + { + 1.0, 0.0, 0.0 + }, + { + 1.0, -1.0, 0.0 + }, + { + 1.0, -1.0, 1.0 + }, + { + 1.0, 0.0, 1.0 + }, + }, + }, + { + { + { + -1.0, 1.0, 1.0 + }, + { + 0.0, 1.0, 1.0 + }, + { + 0.0, 0.0, 1.0 + }, + { + -1.0, 0.0, 1.0 + }, + }, + { + { + 0.0, 1.0, 1.0 + }, + { + 1.0, 1.0, 1.0 + }, + { + 1.0, 0.0, 1.0 + }, + { + 0.0, 0.0, 1.0 + }, + }, + { + { + 1.0, 0.0, 1.0 + }, + { + 1.0, -1.0, 1.0 + }, + { + 0.0, -1.0, 1.0 + }, + { + 0.0, 0.0, 1.0 + }, + }, + { + { + 0.0, -1.0, 1.0 + }, + { + -1.0, -1.0, 1.0 + }, + { + -1.0, 0.0, 1.0 + }, + { + 0.0, 0.0, 1.0 + }, + }, + }, + { + { + { + -1.0, 1.0, -1.0 + }, + { + -1.0, 1.0, 0.0 + }, + { + -1.0, 0.0, 0.0 + }, + { + -1.0, 0.0, -1.0 + }, + }, + { + { + -1.0, 1.0, 0.0 + }, + { + -1.0, 1.0, 1.0 + }, + { + -1.0, 0.0, 1.0 + }, + { + -1.0, 0.0, 0.0 + }, + }, + { + { + -1.0, 0.0, 1.0 + }, + { + -1.0, -1.0, 1.0 + }, + { + -1.0, -1.0, 0.0 + }, + { + -1.0, 0.0, 0.0 + }, + }, + { + { + -1.0, -1.0, 0.0 + }, + { + -1.0, -1.0, -1.0 + }, + { + -1.0, 0.0, -1.0 + }, + { + -1.0, 0.0, 0.0 + }, + }, + }, + { + { + { + -1.0, 1.0, 1.0 + }, + { + -1.0, 1.0, 0.0 + }, + { + 0.0, 1.0, 0.0 + }, + { + 0.0, 1.0, 1.0 + }, + }, + { + { + -1.0, 1.0, 0.0 + }, + { + -1.0, 1.0, -1.0 + }, + { + 0.0, 1.0, -1.0 + }, + { + 0.0, 1.0, 0.0 + }, + }, + { + { + 0.0, 1.0, -1.0 + }, + { + 1.0, 1.0, -1.0 + }, + { + 1.0, 1.0, 0.0 + }, + { + 0.0, 1.0, 0.0 + }, + }, + { + { + 1.0, 1.0, 0.0 + }, + { + 1.0, 1.0, 1.0 + }, + { + 0.0, 1.0, 1.0 + }, + { + 0.0, 1.0, 0.0 + }, + }, + }, + { + { + { + -1.0, -1.0, -1.0 + }, + { + -1.0, -1.0, 0.0 + }, + { + 0.0, -1.0, 0.0 + }, + { + 0.0, -1.0, -1.0 + }, + }, + { + { + -1.0, -1.0, 0.0 + }, + { + -1.0, -1.0, 1.0 + }, + { + 0.0, -1.0, 1.0 + }, + { + 0.0, -1.0, 0.0 + }, + }, + { + { + 0.0, -1.0, 1.0 + }, + { + 1.0, -1.0, 1.0 + }, + { + 1.0, -1.0, 0.0 + }, + { + 0.0, -1.0, 0.0 + }, + }, + { + { + 1.0, -1.0, 0.0 + }, + { + 1.0, -1.0, -1.0 + }, + { + 0.0, -1.0, -1.0 + }, + { + 0.0, -1.0, 0.0 + }, + }, + } +}; + +float n[6][3] = { + { + 0.0, 0.0, -1.0 + }, + { + 1.0, 0.0, 0.0 + }, + { + 0.0, 0.0, 1.0 + }, + { + -1.0, 0.0, 0.0 + }, + { + 0.0, 1.0, 0.0 + }, + { + 0.0, -1.0, 0.0 + } +}; + +GLfloat identity[16] = { + 1, 0, 0, 0, + 0, 1, 0, 0, + 0, 0, 1, 0, + 0, 0, 0, 1, +}; + + +void BuildCylinder(int numEdges) +{ + int i, top = 1.0, bottom = -1.0; + float x[100], y[100], angle; + + for (i = 0; i <= numEdges; i++) { + angle = i * 2.0 * PI / numEdges; + x[i] = cos(angle); /* was cosf() */ + y[i] = sin(angle); /* was sinf() */ + } + + glNewList(cylinder, GL_COMPILE); + glBegin(GL_TRIANGLE_STRIP); + for (i = 0; i <= numEdges; i++) { + glNormal3f(x[i], y[i], 0.0); + glVertex3f(x[i], y[i], bottom); + glVertex3f(x[i], y[i], top); + } + glEnd(); + glBegin(GL_TRIANGLE_FAN); + glNormal3f(0.0, 0.0, 1.0); + glVertex3f(0.0, 0.0, top); + for (i = 0; i <= numEdges; i++) { + glVertex3f(x[i], -y[i], top); + } + glEnd(); + glBegin(GL_TRIANGLE_FAN); + glNormal3f(0.0, 0.0, -1.0); + glVertex3f(0.0, 0.0, bottom); + for (i = 0; i <= numEdges; i++) { + glVertex3f(x[i], y[i], bottom); + } + glEnd(); + glEndList(); +} + +void BuildTorus(float rc, int numc, float rt, int numt) +{ + int i, j, k; + double s, t; + double x, y, z; + double pi, twopi; + + pi = 3.14159265358979323846; + twopi = 2.0 * pi; + + glNewList(torus, GL_COMPILE); + for (i = 0; i < numc; i++) { + glBegin(GL_QUAD_STRIP); + for (j = 0; j <= numt; j++) { + for (k = 0; k <= 1; k++) { + s = (i + k) % numc + 0.5; + t = j % numt; + + x = cos(t*twopi/numt) * cos(s*twopi/numc); + y = sin(t*twopi/numt) * cos(s*twopi/numc); + z = sin(s*twopi/numc); + glNormal3f(x, y, z); + + x = (rt + rc * cos(s*twopi/numc)) * cos(t*twopi/numt); + y = (rt + rc * cos(s*twopi/numc)) * sin(t*twopi/numt); + z = rc * sin(s*twopi/numc); + glVertex3f(x, y, z); + } + } + glEnd(); + } + glEndList(); +} + +void BuildCage(void) +{ + int i; + float inc; + float right, left, top, bottom, front, back; + + front = 0.0; + back = -8.0; + + left = -4.0; + bottom = -4.0; + right = 4.0; + top = 4.0; + + inc = 2.0 * 4.0 * 0.1; + + glNewList(cage, GL_COMPILE); + for (i = 0; i < 10; i++) { + + /* + ** Back + */ + glBegin(GL_LINES); + glVertex3f(left+i*inc, top, back); + glVertex3f(left+i*inc, bottom, back); + glEnd(); + glBegin(GL_LINES); + glVertex3f(right, bottom+i*inc, back); + glVertex3f(left, bottom+i*inc, back); + glEnd(); + + /* + ** Front + */ + glBegin(GL_LINES); + glVertex3f(left+i*inc, top, front); + glVertex3f(left+i*inc, bottom, front); + glEnd(); + glBegin(GL_LINES); + glVertex3f(right, bottom+i*inc, front); + glVertex3f(left, bottom+i*inc, front); + glEnd(); + + /* + ** Left + */ + glBegin(GL_LINES); + glVertex3f(left, bottom+i*inc, front); + glVertex3f(left, bottom+i*inc, back); + glEnd(); + glBegin(GL_LINES); + glVertex3f(left, top, back+i*inc); + glVertex3f(left, bottom, back+i*inc); + glEnd(); + + /* + ** Right + */ + glBegin(GL_LINES); + glVertex3f(right, top-i*inc, front); + glVertex3f(right, top-i*inc, back); + glEnd(); + glBegin(GL_LINES); + glVertex3f(right, top, back+i*inc); + glVertex3f(right, bottom, back+i*inc); + glEnd(); + + /* + ** Top + */ + glBegin(GL_LINES); + glVertex3f(left+i*inc, top, front); + glVertex3f(left+i*inc, top, back); + glEnd(); + glBegin(GL_LINES); + glVertex3f(right, top, back+i*inc); + glVertex3f(left, top, back+i*inc); + glEnd(); + + /* + ** Bottom + */ + glBegin(GL_LINES); + glVertex3f(right-i*inc, bottom, front); + glVertex3f(right-i*inc, bottom, back); + glEnd(); + glBegin(GL_LINES); + glVertex3f(right, bottom, back+i*inc); + glVertex3f(left, bottom, back+i*inc); + glEnd(); + } + glEndList(); +} + +void BuildCube(void) +{ + int i, j; + + glNewList(cube, GL_COMPILE); + for (i = 0; i < 6; i++) { + for (j = 0; j < 4; j++) { + glNormal3fv(n[i]); + glBegin(GL_POLYGON); + glVertex3fv(c[i][j][0]); + glVertex3fv(c[i][j][1]); + glVertex3fv(c[i][j][2]); + glVertex3fv(c[i][j][3]); + glEnd(); + } + } + glEndList(); +} + +void BuildLists(void) +{ + + cube = glGenLists(1); + BuildCube(); + + cage = glGenLists(2); + BuildCage(); + + cylinder = glGenLists(3); + BuildCylinder(60); + + torus = glGenLists(4); + BuildTorus(0.65, 20, .85, 65); + + genericObject = torus; +} + +void SetDefaultSettings(void) +{ + + magFilter = nnearest; + minFilter = nnearest; + sWrapMode = repeat; + tWrapMode = repeat; + textureEnvironment = modulate; + autoRotate = GL_TRUE; +} + +unsigned char *AlphaPadImage(int bufSize, unsigned char *inData, int alpha) +{ + unsigned char *outData, *out_ptr, *in_ptr; + int i; + + outData = (unsigned char *) malloc(bufSize * 4); + out_ptr = outData; + in_ptr = inData; + + for (i = 0; i < bufSize; i++) { + *out_ptr++ = *in_ptr++; + *out_ptr++ = *in_ptr++; + *out_ptr++ = *in_ptr++; + *out_ptr++ = alpha; + } + + free (inData); + return outData; +} + +void Init(void) +{ + float ambient[] = {0.0, 0.0, 0.0, 1.0}; + float diffuse[] = {1.0, 1.0, 1.0, 1.0}; + float specular[] = {1.0, 1.0, 1.0, 1.0}; + float position[] = {0.0, 0.0, 4.0, 0.0}; + float fog_color[] = {0.0, 0.0, 0.0, 1.0}; + float mat_ambient[] = {0.0, 0.0, 0.0, 1.0}; + float mat_shininess[] = {90.0}; + float mat_specular[] = {1.0, 1.0, 1.0, 1.0}; + float mat_diffuse[] = {0.8, 0.8, 0.8, 1.0}; + float lmodel_ambient[] = {0.2, 0.2, 0.2, 1.0}; + float lmodel_twoside[] = {GL_TRUE}; + int w, h; + GLenum format; + GLubyte *image; + + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + SetDefaultSettings(); + + image = LoadRGBImage(imageFileName, &w, &h, &format); + if (!image) { + printf("Error: couldn't load %s\n", imageFileName); + exit(1); + } + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + gluBuild2DMipmaps(GL_TEXTURE_2D, format, w, h, + GL_RGB, GL_UNSIGNED_BYTE, image); + + free(image); + + glFogf(GL_FOG_DENSITY, 0.125); + glFogi(GL_FOG_MODE, GL_LINEAR); + glFogf(GL_FOG_START, 4.0); + glFogf(GL_FOG_END, 8.5); + glFogfv(GL_FOG_COLOR, fog_color); + + glLightfv(GL_LIGHT0, GL_AMBIENT, ambient); + glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse); + glLightfv(GL_LIGHT0, GL_SPECULAR, specular); + glLightfv(GL_LIGHT0, GL_POSITION, position); + glEnable(GL_LIGHT0); + + glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, mat_shininess); + glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, mat_specular); + glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mat_diffuse); + glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, mat_ambient); + + glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient); + glLightModelfv(GL_LIGHT_MODEL_TWO_SIDE, lmodel_twoside); + glShadeModel(GL_SMOOTH); + + + glClearColor(0.0, 0.0, 0.0, 0.0); + glEnable(GL_DEPTH_TEST); + + glFrontFace(GL_CW); + glEnable(GL_CULL_FACE); + glCullFace(GL_BACK); + + glTexGeniv(GL_S, GL_TEXTURE_GEN_MODE, sphereMap); + glTexGeniv(GL_T, GL_TEXTURE_GEN_MODE, sphereMap); + glEnable(GL_TEXTURE_GEN_S); + glEnable(GL_TEXTURE_GEN_T); + + glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, magFilter); + glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, minFilter); + glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, sWrapMode); + glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, tWrapMode); + + glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, textureEnvironment); + + BuildLists(); +} + +void ReInit(void) +{ + if (genericObject == torus) { + glEnable(GL_DEPTH_TEST); + } else { + glDisable(GL_DEPTH_TEST); + } + glEnable(GL_DEPTH_TEST); + +#if 0 + if (isFogged) { + textureEnvironment = modulate; + } +#endif + + glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, magFilter); + glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, minFilter); + glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, textureEnvironment); +} + +void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); + + /* draw cage */ + if (isFogged) + glEnable(GL_FOG); + else + glDisable(GL_FOG); + glColor3f(1, 1, 1); + glDisable(GL_LIGHTING); + glDisable(GL_TEXTURE_2D); + glCallList(cage); + + /* draw object */ + if (isLit) + glEnable(GL_LIGHTING); + else + glColor3f(1.0, 0.5, 0.2); + if (doTexture) + glEnable(GL_TEXTURE_2D); + + glPushMatrix(); + glTranslatef(0.0, 0.0, zTranslate); + glRotatef(xRotation, 1, 0, 0); + glRotatef(yRotation, 0, 1, 0); + glCallList(genericObject); + glPopMatrix(); + + glFlush(); + glutSwapBuffers(); +} + +void Reshape(int width, int height) +{ + W = width; + H = height; + ReInit(); + glViewport( 0, 0, width, height ); /*new*/ + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glFrustum(-0.2, 0.2, -0.2, 0.2, 0.15, 9.0); + glMatrixMode(GL_MODELVIEW); +} + +void Idle(void) +{ + static double t0 = -1.; + double t, dt; + t = glutGet(GLUT_ELAPSED_TIME) / 1000.; + if (t0 < 0.) + t0 = t; + dt = t - t0; + t0 = t; + + xRotation += .75*60.*dt; + yRotation += .375*60.*dt; + glutPostRedisplay(); +} + +void Key2(int key, int x, int y) +{ + + switch (key) { + case GLUT_KEY_LEFT: + yRotation -= 0.5; + autoRotate = GL_FALSE; + ReInit(); + break; + case GLUT_KEY_RIGHT: + yRotation += 0.5; + autoRotate = GL_FALSE; + ReInit(); + break; + case GLUT_KEY_UP: + xRotation -= 0.5; + autoRotate = GL_FALSE; + ReInit(); + break; + case GLUT_KEY_DOWN: + xRotation += 0.5; + autoRotate = GL_FALSE; + ReInit(); + break; + default: + return; + } + glutPostRedisplay(); +} + +void Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + /* free(image->data);*/ + exit(1); + + case 'a': + autoRotate = !autoRotate; + if (autoRotate) + glutIdleFunc(Idle); + else + glutIdleFunc(NULL); + + ReInit(); + break; + case 'o': + if (genericObject == cube) { + genericObject = cylinder; + } + else if (genericObject == cylinder) { + genericObject = torus; + } + else { + genericObject = cube; + } + ReInit(); + break; + case 'd': + textureEnvironment = decal; + ReInit(); + break; + case 'm': + textureEnvironment = modulate; + ReInit(); + break; + case 'l': + isLit = !isLit; + ReInit(); + break; + case 'f': + isFogged = !isFogged; + ReInit(); + break; + case 't': + doTexture = !doTexture; + ReInit(); + break; + case '0': + magFilter = nnearest; + ReInit(); + break; + case '1': + magFilter = linear; + ReInit(); + break; + case '2': + minFilter = nnearest; + ReInit(); + break; + case '3': + minFilter = linear; + ReInit(); + break; + case '4': + minFilter = nearest_mipmap_nearest; + ReInit(); + break; + case '5': + minFilter = nearest_mipmap_linear; + ReInit(); + break; + case '6': + minFilter = linear_mipmap_nearest; + ReInit(); + break; + case '7': + minFilter = linear_mipmap_linear; + ReInit(); + break; + default: + return; + } + glutPostRedisplay(); +} + +GLenum Args(int argc, char **argv) +{ + GLint i; + + doubleBuffer = GL_TRUE; + + 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 if (strcmp(argv[i], "-f") == 0) { + if (i+1 >= argc || argv[i+1][0] == '-') { + printf("-f (No file name).\n"); + return GL_FALSE; + } else { + imageFileName = argv[++i]; + } + } else { + printf("%s (Bad option).\n", argv[i]); + return GL_FALSE; + } + } + return GL_TRUE; +} + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + if (Args(argc, argv) == GL_FALSE) { + exit(1); + } + + if (imageFileName == 0) { + printf("No image file.\n"); + exit(1); + } + + glutInitWindowPosition(0, 0); glutInitWindowSize( W, H); + + type = GLUT_RGB | GLUT_DEPTH; + type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("Texture Test") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutSpecialFunc(Key2); + glutDisplayFunc(Draw); + glutIdleFunc(Idle); + + glutMainLoop(); + return 0; +} diff --git a/progs/samples/star.c b/progs/samples/star.c new file mode 100644 index 00000000000..2cf470e2a2f --- /dev/null +++ b/progs/samples/star.c @@ -0,0 +1,345 @@ +/* + * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the name of + * Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF + * ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#include +#include +#include +#include +#include + + +#ifndef PI +#define PI 3.141592657 +#endif + +enum { + NORMAL = 0, + WEIRD = 1 +}; + +enum { + STREAK = 0, + CIRCLE = 1 +}; + +#define MAXSTARS 400 +#define MAXPOS 10000 +#define MAXWARP 500 +#define MAXANGLES 6000 + + +typedef struct _starRec { + GLint type; + float x[2], y[2], z[2]; + float offsetX, offsetY, offsetR, rotation; +} starRec; + + +GLenum doubleBuffer; +GLint windW, windH; + +GLenum flag = NORMAL; +GLint starCount = MAXSTARS / 2; +float speed = 1.0; +GLint nitro = 0; +starRec stars[MAXSTARS]; +float sinTable[MAXANGLES]; + + +float Sin(float angle) +{ + + return (sinTable[(GLint)angle]); +} + +float Cos(float angle) +{ + + return (sinTable[((GLint)angle+(MAXANGLES/4))%MAXANGLES]); +} + +void NewStar(GLint n, GLint d) +{ + + if (rand()%4 == 0) { + stars[n].type = CIRCLE; + } else { + stars[n].type = STREAK; + } + stars[n].x[0] = (float)(rand() % MAXPOS - MAXPOS / 2); + stars[n].y[0] = (float)(rand() % MAXPOS - MAXPOS / 2); + stars[n].z[0] = (float)(rand() % MAXPOS + d); + if (rand()%4 == 0 && flag == WEIRD) { + stars[n].offsetX = (float)(rand() % 100 - 100 / 2); + stars[n].offsetY = (float)(rand() % 100 - 100 / 2); + stars[n].offsetR = (float)(rand() % 25 - 25 / 2); + } else { + stars[n].offsetX = 0.0; + stars[n].offsetY = 0.0; + stars[n].offsetR = 0.0; + } +} + +void RotatePoint(float *x, float *y, float rotation) +{ + float tmpX, tmpY; + + tmpX = *x * Cos(rotation) - *y * Sin(rotation); + tmpY = *y * Cos(rotation) + *x * Sin(rotation); + *x = tmpX; + *y = tmpY; +} + +void MoveStars(void) +{ + float offset; + GLint n; + static double t0 = -1.; + double t, dt; + t = glutGet(GLUT_ELAPSED_TIME) / 1000.; + if (t0 < 0.) + t0 = t; + dt = 85.*(t - t0); + t0 = t; + + offset = speed * 60.0; + + for (n = 0; n < starCount; n++) { + stars[n].x[1] = stars[n].x[0]; + stars[n].y[1] = stars[n].y[0]; + stars[n].z[1] = stars[n].z[0]; + stars[n].x[0] += stars[n].offsetX*dt; + stars[n].y[0] += stars[n].offsetY*dt; + stars[n].z[0] -= offset*dt; + stars[n].rotation += stars[n].offsetR*dt; + if (stars[n].rotation > MAXANGLES) { + stars[n].rotation = 0.0; + } + else if (stars[n].rotation < 0.0) { + stars[n].rotation += 360.0; + } + } +} + +GLenum StarPoint(GLint n) +{ + float x0, y0, x1, y1, width; + GLint i; + + x0 = stars[n].x[0] * windW / stars[n].z[0]; + y0 = stars[n].y[0] * windH / stars[n].z[0]; + RotatePoint(&x0, &y0, stars[n].rotation); + x0 += windW / 2.0; + y0 += windH / 2.0; + + if (x0 >= 0.0 && x0 < windW && y0 >= 0.0 && y0 < windH) { + if (stars[n].type == STREAK) { + x1 = stars[n].x[1] * windW / stars[n].z[1]; + y1 = stars[n].y[1] * windH / stars[n].z[1]; + RotatePoint(&x1, &y1, stars[n].rotation); + x1 += windW / 2.0; + y1 += windH / 2.0; + + glLineWidth(MAXPOS/100.0/stars[n].z[0]+1.0); + glColor3f(1.0, (MAXWARP-speed)/MAXWARP, (MAXWARP-speed)/MAXWARP); + if (fabs(x0-x1) < 1.0 && fabs(y0-y1) < 1.0) { + glBegin(GL_POINTS); + glVertex2f(x0, y0); + glEnd(); + } else { + glBegin(GL_LINES); + glVertex2f(x0, y0); + glVertex2f(x1, y1); + glEnd(); + } + } else { + width = MAXPOS / 10.0 / stars[n].z[0] + 1.0; + glColor3f(1.0, 0.0, 0.0); + glBegin(GL_POLYGON); + for (i = 0; i < 8; i++) { + float x = x0 + width * Cos((float)i*MAXANGLES/8.0); + float y = y0 + width * Sin((float)i*MAXANGLES/8.0); + glVertex2f(x, y); + }; + glEnd(); + } + return GL_TRUE; + } else { + return GL_FALSE; + } +} + +void ShowStars(void) +{ + GLint n; + + glClear(GL_COLOR_BUFFER_BIT); + + for (n = 0; n < starCount; n++) { + if (stars[n].z[0] > speed || (stars[n].z[0] > 0.0 && speed < MAXWARP)) { + if (StarPoint(n) == GL_FALSE) { + NewStar(n, MAXPOS); + } + } else { + NewStar(n, MAXPOS); + } + } +} + +static void Init(void) +{ + float angle; + GLint n; + + srand((unsigned int) glutGet(GLUT_ELAPSED_TIME) ); + + for (n = 0; n < MAXSTARS; n++) { + NewStar(n, 100); + } + + angle = 0.0; + for (n = 0; n < MAXANGLES ; n++) { + sinTable[n] = sin(angle); + angle += PI / (MAXANGLES / 2.0); + } + + glClearColor(0.0, 0.0, 0.0, 0.0); + + glDisable(GL_DITHER); +} + +void Reshape(int width, int height) +{ + + windW = (GLint)width; + windH = (GLint)height; + + glViewport(0, 0, windW, windH); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluOrtho2D(-0.5, windW+0.5, -0.5, windH+0.5); + glMatrixMode(GL_MODELVIEW); +} + +static void Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + case 32: + flag = (flag == NORMAL) ? WEIRD : NORMAL; + break; + case 't': + nitro = 1; + break; + default: + return; + } +} + +void Draw(void) +{ + + MoveStars(); + ShowStars(); + if (nitro > 0) { + speed = (float)(nitro / 10) + 1.0; + if (speed > MAXWARP) { + speed = MAXWARP; + } + if (++nitro > MAXWARP*10) { + nitro = -nitro; + } + } else if (nitro < 0) { + nitro++; + speed = (float)(-nitro / 10) + 1.0; + if (speed > MAXWARP) { + speed = MAXWARP; + } + } + + glFlush(); + if (doubleBuffer) { + glutSwapBuffers(); + } +} + +static GLenum Args(int argc, char **argv) +{ + GLint i; + + doubleBuffer = GL_TRUE; + + 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; + } + } + return GL_TRUE; +} + +#if !defined(GLUTCALLBACK) +#define GLUTCALLBACK +#endif + +void GLUTCALLBACK glut_post_redisplay_p(void) +{ + glutPostRedisplay(); +} + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + if (Args(argc, argv) == GL_FALSE) { + exit(1); + } + + windW = 300; + windH = 300; + glutInitWindowPosition(0, 0); glutInitWindowSize( 300, 300); + + type = GLUT_RGB; + type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("Stars") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutIdleFunc(glut_post_redisplay_p); + glutMainLoop(); + return 0; +} diff --git a/progs/samples/stencil.c b/progs/samples/stencil.c new file mode 100644 index 00000000000..e00bbb61b0d --- /dev/null +++ b/progs/samples/stencil.c @@ -0,0 +1,143 @@ +/* + * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the name of + * Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF + * ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#include +#include +#include +#include +#include + + +static void Init(void) +{ + glShadeModel(GL_FLAT); + glClearColor(0.0, 0.0, 0.0, 0.0); + + glClearStencil(0); + glStencilMask(1); + glEnable(GL_STENCIL_TEST); +} + +static void Reshape(int width, int height) +{ + + glViewport(0, 0, (GLint)width, (GLint)height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-5.0, 5.0, -5.0, 5.0, -5.0, 5.0); + glMatrixMode(GL_MODELVIEW); +} + +static void Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + } +} + +static void Draw(void) +{ + + glClear(GL_COLOR_BUFFER_BIT|GL_STENCIL_BUFFER_BIT); + + glStencilFunc(GL_ALWAYS, 1, 1); + glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE); + + glColor3ub(200, 0, 0); + glBegin(GL_POLYGON); + glVertex3i(-4, -4, 0); + glVertex3i( 4, -4, 0); + glVertex3i( 0, 4, 0); + glEnd(); + + glStencilFunc(GL_EQUAL, 1, 1); + glStencilOp(GL_INCR, GL_KEEP, GL_DECR); + + glColor3ub(0, 200, 0); + glBegin(GL_POLYGON); + glVertex3i(3, 3, 0); + glVertex3i(-3, 3, 0); + glVertex3i(-3, -3, 0); + glVertex3i(3, -3, 0); + glEnd(); + + glStencilFunc(GL_EQUAL, 1, 1); + glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); + + glColor3ub(0, 0, 200); + glBegin(GL_POLYGON); + glVertex3i(3, 3, 0); + glVertex3i(-3, 3, 0); + glVertex3i(-3, -3, 0); + glVertex3i(3, -3, 0); + glEnd(); + + glFlush(); +} + +static GLenum Args(int argc, char **argv) +{ + GLint i; + + + for (i = 1; i < argc; i++) { + if (strcmp(argv[i], "-dr") == 0) { + } else { + printf("%s (Bad option).\n", argv[i]); + return GL_FALSE; + } + } + return GL_TRUE; +} + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + if (Args(argc, argv) == GL_FALSE) { + exit(1); + } + + glutInitWindowPosition(0, 0); glutInitWindowSize( 300, 300); + + type = GLUT_RGB | GLUT_SINGLE | GLUT_STENCIL; + glutInitDisplayMode(type); + + if (glutCreateWindow("Stencil Test") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/samples/stretch.c b/progs/samples/stretch.c new file mode 100644 index 00000000000..1fd015d794a --- /dev/null +++ b/progs/samples/stretch.c @@ -0,0 +1,390 @@ +/* + * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the name of + * Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF + * ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#include +#include +#include +#include +#include + + +#define STEPCOUNT 40 +#define FALSE 0 +#define TRUE 1 +#define MAX(a, b) (((a) > (b)) ? (a) : (b)) +#define MIN(a, b) (((a) < (b)) ? (a) : (b)) + + +enum { + OP_NOOP = 0, + OP_STRETCH, + OP_DRAWPOINT, + OP_DRAWIMAGE +}; + + +typedef struct _cRec { + float x, y; +} cRec; + +typedef struct _vertexRec { + float x, y; + float dX, dY; + float tX, tY; +} vertexRec; + + +#include "loadppm.c" + +GLenum doubleBuffer; +int imageSizeX, imageSizeY; +char *fileName = 0; +PPMImage *image; +cRec cList[50]; +vertexRec vList[5]; +int cCount, cIndex[2], cStep; +GLenum op = OP_NOOP; + + +void DrawImage(void) +{ + + glRasterPos2i(0, 0); + glDrawPixels(image->sizeX, image->sizeY, GL_RGB, GL_UNSIGNED_BYTE, + image->data); + + glFlush(); + if (doubleBuffer) { + glutSwapBuffers(); + } + + glRasterPos2i(0, 0); + glDrawPixels(image->sizeX, image->sizeY, GL_RGB, GL_UNSIGNED_BYTE, + image->data); +} + +void DrawPoint(void) +{ + int i; + + glColor3f(1.0, 0.0, 1.0); + glPointSize(3.0); + glBegin(GL_POINTS); + for (i = 0; i < cCount; i++) { + glVertex2f(cList[i].x, cList[i].y); + } + glEnd(); + + glFlush(); + if (doubleBuffer) { + glutSwapBuffers(); + } +} + +void InitVList(void) +{ + + vList[0].x = 0.0; + vList[0].y = 0.0; + vList[0].dX = 0.0; + vList[0].dY = 0.0; + vList[0].tX = 0.0; + vList[0].tY = 0.0; + + vList[1].x = (float)imageSizeX; + vList[1].y = 0.0; + vList[1].dX = 0.0; + vList[1].dY = 0.0; + vList[1].tX = 1.0; + vList[1].tY = 0.0; + + vList[2].x = (float)imageSizeX; + vList[2].y = (float)imageSizeY; + vList[2].dX = 0.0; + vList[2].dY = 0.0; + vList[2].tX = 1.0; + vList[2].tY = 1.0; + + vList[3].x = 0.0; + vList[3].y = (float)imageSizeY; + vList[3].dX = 0.0; + vList[3].dY = 0.0; + vList[3].tX = 0.0; + vList[3].tY = 1.0; + + vList[4].x = cList[0].x; + vList[4].y = cList[0].y; + vList[4].dX = (cList[1].x - cList[0].x) / STEPCOUNT; + vList[4].dY = (cList[1].y - cList[0].y) / STEPCOUNT; + vList[4].tX = cList[0].x / (float)imageSizeX; + vList[4].tY = cList[0].y / (float)imageSizeY; +} + +void ScaleImage(int sizeX, int sizeY) +{ + GLubyte *buf; + + buf = (GLubyte *)malloc(3*sizeX*sizeY); + gluScaleImage(GL_RGB, image->sizeX, image->sizeY, GL_UNSIGNED_BYTE, + image->data, sizeX, sizeY, GL_UNSIGNED_BYTE, buf); + free(image->data); + image->data = buf; + image->sizeX = sizeX; + image->sizeY = sizeY; +} + +void SetPoint(int x, int y) +{ + + cList[cCount].x = (float)x; + cList[cCount].y = (float)y; + cCount++; +} + +void Stretch(void) +{ + + glBegin(GL_TRIANGLES); + glTexCoord2f(vList[0].tX, vList[0].tY); + glVertex2f(vList[0].x, vList[0].y); + glTexCoord2f(vList[1].tX, vList[1].tY); + glVertex2f(vList[1].x, vList[1].y); + glTexCoord2f(vList[4].tX, vList[4].tY); + glVertex2f(vList[4].x, vList[4].y); + glEnd(); + + glBegin(GL_TRIANGLES); + glTexCoord2f(vList[1].tX, vList[1].tY); + glVertex2f(vList[1].x, vList[1].y); + glTexCoord2f(vList[2].tX, vList[2].tY); + glVertex2f(vList[2].x, vList[2].y); + glTexCoord2f(vList[4].tX, vList[4].tY); + glVertex2f(vList[4].x, vList[4].y); + glEnd(); + + glBegin(GL_TRIANGLES); + glTexCoord2f(vList[2].tX, vList[2].tY); + glVertex2f(vList[2].x, vList[2].y); + glTexCoord2f(vList[3].tX, vList[3].tY); + glVertex2f(vList[3].x, vList[3].y); + glTexCoord2f(vList[4].tX, vList[4].tY); + glVertex2f(vList[4].x, vList[4].y); + glEnd(); + + glBegin(GL_TRIANGLES); + glTexCoord2f(vList[3].tX, vList[3].tY); + glVertex2f(vList[3].x, vList[3].y); + glTexCoord2f(vList[0].tX, vList[0].tY); + glVertex2f(vList[0].x, vList[0].y); + glTexCoord2f(vList[4].tX, vList[4].tY); + glVertex2f(vList[4].x, vList[4].y); + glEnd(); + + glFlush(); + if (doubleBuffer) { + glutSwapBuffers(); + } + + if (++cStep < STEPCOUNT) { + vList[4].x += vList[4].dX; + vList[4].y += vList[4].dY; + } else { + cIndex[0] = cIndex[1]; + cIndex[1] = cIndex[1] + 1; + if (cIndex[1] == cCount) { + cIndex[1] = 0; + } + vList[4].dX = (cList[cIndex[1]].x - cList[cIndex[0]].x) / STEPCOUNT; + vList[4].dY = (cList[cIndex[1]].y - cList[cIndex[0]].y) / STEPCOUNT; + cStep = 0; + } +} + +void Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + free(image->data); + exit(1); + case 32: + if (cCount > 1) { + InitVList(); + cIndex[0] = 0; + cIndex[1] = 1; + cStep = 0; + glEnable(GL_TEXTURE_2D); + op = OP_STRETCH; + } + break; + default: + return; + } + + glutPostRedisplay(); +} + +void Mouse(int button, int state, int mouseX, int mouseY) +{ + + if (state != GLUT_DOWN) + return; + + if (op == OP_STRETCH) { + glDisable(GL_TEXTURE_2D); + cCount = 0; + op = OP_DRAWIMAGE; + } else { + SetPoint(mouseX, imageSizeY-mouseY); + op = OP_DRAWPOINT; + } + + glutPostRedisplay(); +} + +void Animate(void) +{ + static double t0 = -1.; + double t, dt; + t = glutGet(GLUT_ELAPSED_TIME) / 1000.; + if (t0 < 0.) + t0 = t; + dt = t - t0; + + if (dt < 1./60.) + return; + + t0 = t; + + switch (op) { + case OP_STRETCH: + Stretch(); + break; + case OP_DRAWPOINT: + DrawPoint(); + break; + case OP_DRAWIMAGE: + DrawImage(); + break; + default: + break; + } +} + +static GLenum Args(int argc, char **argv) +{ + GLint i; + + doubleBuffer = GL_TRUE; + + 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 if (strcmp(argv[i], "-f") == 0) { + if (i+1 >= argc || argv[i+1][0] == '-') { + printf("-f (No file name).\n"); + return GL_FALSE; + } else { + fileName = argv[++i]; + } + } else { + printf("%s (Bad option).\n", argv[i]); + return GL_FALSE; + } + } + return GL_TRUE; +} + +#if !defined(GLUTCALLBACK) +#define GLUTCALLBACK +#endif + +void GLUTCALLBACK glut_post_redisplay_p(void) +{ + glutPostRedisplay(); +} + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + if (Args(argc, argv) == GL_FALSE) { + exit(1); + } + + if (fileName == 0) { + printf("No image file.\n"); + exit(1); + } + + image = LoadPPM(fileName); + + /* changed powf and logf to pow and log -Brian */ + imageSizeX = (int)pow(2.0, (float)((int)(log(image->sizeX)/log(2.0)))); + imageSizeY = (int)pow(2.0, (float)((int)(log(image->sizeY)/log(2.0)))); + + glutInitWindowPosition(0, 0); glutInitWindowSize( imageSizeX, imageSizeY); + + type = GLUT_RGB; + type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("Stretch") == GL_FALSE) { + exit(1); + } + + glViewport(0, 0, imageSizeX, imageSizeY); + gluOrtho2D(0, imageSizeX, 0, imageSizeY); + glClearColor(0.0, 0.0, 0.0, 0.0); + + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + glPixelStorei(GL_PACK_ALIGNMENT, 1); + + ScaleImage(imageSizeX, imageSizeY); + + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexImage2D(GL_TEXTURE_2D, 0, 3, image->sizeX, image->sizeY, 0, + GL_RGB, GL_UNSIGNED_BYTE, (unsigned char *)image->data); + + cCount = 0; + cIndex[0] = 0; + cIndex[1] = 0; + cStep = 0; + op = OP_DRAWIMAGE; + + glutKeyboardFunc(Key); + glutMouseFunc(Mouse); + glutDisplayFunc(Animate); + glutIdleFunc(glut_post_redisplay_p); + glutMainLoop(); + return 0; +} diff --git a/progs/samples/texture.c b/progs/samples/texture.c new file mode 100644 index 00000000000..7ee41eef28b --- /dev/null +++ b/progs/samples/texture.c @@ -0,0 +1,474 @@ +/* + * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the name of + * Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF + * ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#include +#include +#include +#include +#include + + +#include "loadppm.c" + +GLenum doubleBuffer; + +char *texFileName = 0; +PPMImage *image; + +float *minFilter, *magFilter, *sWrapMode, *tWrapMode; +float decal[] = {GL_DECAL}; +float modulate[] = {GL_MODULATE}; +float repeat[] = {GL_REPEAT}; +float clamp[] = {GL_CLAMP}; +float nr[] = {GL_NEAREST}; +float ln[] = {GL_LINEAR}; +float nr_mipmap_nr[] = {GL_NEAREST_MIPMAP_NEAREST}; +float nr_mipmap_ln[] = {GL_NEAREST_MIPMAP_LINEAR}; +float ln_mipmap_nr[] = {GL_LINEAR_MIPMAP_NEAREST}; +float ln_mipmap_ln[] = {GL_LINEAR_MIPMAP_LINEAR}; +GLint sphereMap[] = {GL_SPHERE_MAP}; + +GLenum doSphere = GL_FALSE; +float xRotation = 0.0, yRotation = 0.0, zTranslate = -3.125; + +GLint cube; +float c[6][4][3] = { + { + { + 1.0, 1.0, -1.0 + }, + { + -1.0, 1.0, -1.0 + }, + { + -1.0, -1.0, -1.0 + }, + { + 1.0, -1.0, -1.0 + } + }, + { + { + 1.0, 1.0, 1.0 + }, + { + 1.0, 1.0, -1.0 + }, + { + 1.0, -1.0, -1.0 + }, + { + 1.0, -1.0, 1.0 + } + }, + { + { + -1.0, 1.0, 1.0 + }, + { + 1.0, 1.0, 1.0 + }, + { + 1.0, -1.0, 1.0 + }, + { + -1.0, -1.0, 1.0 + } + }, + { + { + -1.0, 1.0, -1.0 + }, + { + -1.0, 1.0, 1.0 + }, + { + -1.0, -1.0, 1.0 + }, + { + -1.0, -1.0, -1.0 + } + }, + { + { + -1.0, 1.0, 1.0 + }, + { + -1.0, 1.0, -1.0 + }, + { + 1.0, 1.0, -1.0 + }, + { + 1.0, 1.0, 1.0 + } + }, + { + { + -1.0, -1.0, -1.0 + }, + { + -1.0, -1.0, 1.0 + }, + { + 1.0, -1.0, 1.0 + }, + { + 1.0, -1.0, -1.0 + } + } +}; +static float n[6][3] = { + { + 0.0, 0.0, -1.0 + }, + { + 1.0, 0.0, 0.0 + }, + { + 0.0, 0.0, 1.0 + }, + { + -1.0, 0.0, 0.0 + }, + { + 0.0, 1.0, 0.0 + }, + { + 0.0, -1.0, 0.0 + } +}; +static float t[6][4][2] = { + { + { + 1.1, 1.1 + }, + { + -0.1, 1.1 + }, + { + -0.1, -0.1 + }, + { + 1.1, -0.1 + } + }, + { + { + 1.1, 1.1 + }, + { + -0.1, 1.1 + }, + { + -0.1, -0.1 + }, + { + 1.1, -0.1 + } + }, + { + { + -0.1, 1.1 + }, + { + 1.1, 1.1 + }, + { + 1.1, -0.1 + }, + { + -0.1, -0.1 + } + }, + { + { + 1.1, 1.1 + }, + { + -0.1, 1.1 + }, + { + -0.1, -0.1 + }, + { + 1.1, -0.1 + } + }, + { + { + 1.1, 1.1 + }, + { + -0.1, 1.1 + }, + { + -0.1, -0.1 + }, + { + 1.1, -0.1 + } + }, + { + { + 1.1, 1.1 + }, + { + -0.1, 1.1 + }, + { + -0.1, -0.1 + }, + { + 1.1, -0.1 + } + }, +}; + +static void BuildCube(void) +{ + GLint i; + + glNewList(cube, GL_COMPILE); + for (i = 0; i < 6; i++) { + glBegin(GL_POLYGON); + glNormal3fv(n[i]); glTexCoord2fv(t[i][0]); glVertex3fv(c[i][0]); + glNormal3fv(n[i]); glTexCoord2fv(t[i][1]); glVertex3fv(c[i][1]); + glNormal3fv(n[i]); glTexCoord2fv(t[i][2]); glVertex3fv(c[i][2]); + glNormal3fv(n[i]); glTexCoord2fv(t[i][3]); glVertex3fv(c[i][3]); + glEnd(); + } + glEndList(); +} + +static void BuildLists(void) +{ + + cube = glGenLists(1); + BuildCube(); +} + +static void Init(void) +{ + + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + gluBuild2DMipmaps(GL_TEXTURE_2D, 3, image->sizeX, image->sizeY, + GL_RGB, GL_UNSIGNED_BYTE, image->data); + glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, decal); + glEnable(GL_TEXTURE_2D); + + glFrontFace(GL_CCW); + glCullFace(GL_FRONT); + glEnable(GL_CULL_FACE); + + BuildLists(); + + glClearColor(0.0, 0.0, 0.0, 0.0); + + magFilter = nr; + minFilter = nr; + sWrapMode = repeat; + tWrapMode = repeat; +} + +static void Reshape(int width, int height) +{ + + glViewport(0, 0, (GLint)width, (GLint)height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluPerspective(145.0, 1.0, 0.01, 1000); + glMatrixMode(GL_MODELVIEW); +} + +static void Key2(int key, int x, int y) +{ + + switch (key) { + case GLUT_KEY_LEFT: + yRotation -= 0.5; + break; + case GLUT_KEY_RIGHT: + yRotation += 0.5; + break; + case GLUT_KEY_UP: + xRotation -= 0.5; + break; + case GLUT_KEY_DOWN: + xRotation += 0.5; + break; + default: + return; + } + + glutPostRedisplay(); +} + +static void Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + + case 'T': + zTranslate += 0.25; + break; + case 't': + zTranslate -= 0.25; + break; + + case 's': + doSphere = !doSphere; + if (doSphere) { + glTexGeniv(GL_S, GL_TEXTURE_GEN_MODE, sphereMap); + glTexGeniv(GL_T, GL_TEXTURE_GEN_MODE, sphereMap); + glEnable(GL_TEXTURE_GEN_S); + glEnable(GL_TEXTURE_GEN_T); + } else { + glDisable(GL_TEXTURE_GEN_S); + glDisable(GL_TEXTURE_GEN_T); + } + break; + + case '0': + magFilter = nr; + break; + case '1': + magFilter = ln; + break; + case '2': + minFilter = nr; + break; + case '3': + minFilter = ln; + break; + case '4': + minFilter = nr_mipmap_nr; + break; + case '5': + minFilter = nr_mipmap_ln; + break; + case '6': + minFilter = ln_mipmap_nr; + break; + case '7': + minFilter = ln_mipmap_ln; + break; + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + + glClear(GL_COLOR_BUFFER_BIT); + + glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, sWrapMode); + glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, tWrapMode); + glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, magFilter); + glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, minFilter); + + glPushMatrix(); + + glTranslatef(0.0, 0.0, zTranslate); + glRotatef(xRotation, 1, 0, 0); + glRotatef(yRotation, 0, 1, 0); + glCallList(cube); + + glPopMatrix(); + + glFlush(); + + if (doubleBuffer) { + glutSwapBuffers(); + } +} + +static GLenum Args(int argc, char **argv) +{ + GLint i; + + doubleBuffer = GL_FALSE; + + for (i = 1; i < argc; i++) { + if (strcmp(argv[i], "-sb") == 0) { + doubleBuffer = GL_FALSE; + } else if (strcmp(argv[i], "-db") == 0) { + doubleBuffer = GL_TRUE; + } else if (strcmp(argv[i], "-f") == 0) { + if (i+1 >= argc || argv[i+1][0] == '-') { + printf("-f (No file name).\n"); + return GL_FALSE; + } else { + texFileName = argv[++i]; + } + } else { + printf("%s (Bad option).\n", argv[i]); + return GL_FALSE; + } + } + return GL_TRUE; +} + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + if (Args(argc, argv) == GL_FALSE) { + exit(1); + } + + if (texFileName == 0) { + printf("No image file.\n"); + exit(1); + } + + image = LoadPPM(texFileName); + + glutInitWindowPosition(0, 0); glutInitWindowSize( 300, 300); + + type = GLUT_RGB; + type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("Texture Test") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutSpecialFunc(Key2); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/samples/tkmap.c b/progs/samples/tkmap.c new file mode 100644 index 00000000000..3ded79cacaa --- /dev/null +++ b/progs/samples/tkmap.c @@ -0,0 +1,71 @@ + +enum { + COLOR_BLACK = 0, + COLOR_RED, + COLOR_GREEN, + COLOR_YELLOW, + COLOR_BLUE, + COLOR_MAGENTA, + COLOR_CYAN, + COLOR_WHITE +}; + +static float RGBMap[9][3] = { + {0, 0, 0}, + {1, 0, 0}, + {0, 1, 0}, + {1, 1, 0}, + {0, 0, 1}, + {1, 0, 1}, + {0, 1, 1}, + {1, 1, 1}, + {0.5, 0.5, 0.5} +}; + +static void SetColor(int c) +{ + if (glutGet(GLUT_WINDOW_RGBA)) + glColor3fv(RGBMap[c]); + else + glIndexf(c); +} + +static void InitMap(void) +{ + int i; + + if (rgb) + return; + + for (i = 0; i < 9; i++) + glutSetColor(i, RGBMap[i][0], RGBMap[i][1], RGBMap[i][2]); +} + +static void SetFogRamp(int density, int startIndex) +{ + int fogValues, colorValues; + int i, j, k; + float intensity; + + fogValues = 1 << density; + colorValues = 1 << startIndex; + for (i = 0; i < colorValues; i++) { + for (j = 0; j < fogValues; j++) { + k = i * fogValues + j; + intensity = (i * fogValues + j * colorValues) / 255.0; + glutSetColor(k, intensity, intensity, intensity); + } + } +} + +static void SetGreyRamp(void) +{ + int i; + float intensity; + + for (i = 0; i < 255; i++) { + intensity = i / 255.0; + glutSetColor(i, intensity, intensity, intensity); + } +} + diff --git a/progs/samples/tri.c b/progs/samples/tri.c new file mode 100644 index 00000000000..700325132ef --- /dev/null +++ b/progs/samples/tri.c @@ -0,0 +1,403 @@ +/* + * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the name of + * Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF + * ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#include +#include +#include +#include + + +#define SOLID 1 +#define LINE 2 +#define POINT 3 + + +GLenum rgb, doubleBuffer, windType; +GLint windW, windH; + +GLenum dithering = GL_TRUE; +GLenum showVerticies = GL_TRUE; +GLenum hideBottomTriangle = GL_FALSE; +GLenum outline = GL_TRUE; +GLenum culling = GL_FALSE; +GLenum winding = GL_FALSE; +GLenum face = GL_FALSE; +GLenum state = SOLID; +GLenum aaMode = GL_FALSE; +GLenum shade = GL_TRUE; + +GLint color1, color2, color3; + +float zRotation = 90.0; +float zoom = 1.0; + +float boxA[3] = {-100, -100, 0}; +float boxB[3] = { 100, -100, 0}; +float boxC[3] = { 100, 100, 0}; +float boxD[3] = {-100, 100, 0}; + +float p0[3] = {-125,-80, 0}; +float p1[3] = {-125, 80, 0}; +float p2[3] = { 172, 0, 0}; + + +#include "tkmap.c" + +static void Init(void) +{ + float r, g, b; + float percent1, percent2; + GLint i, j; + + glClearColor(0.0, 0.0, 0.0, 0.0); + + glLineStipple(1, 0xF0F0); + + glEnable(GL_SCISSOR_TEST); + + if (!rgb) { + for (j = 0; j <= 12; j++) { + if (j <= 6) { + percent1 = j / 6.0; + r = 1.0 - 0.8 * percent1; + g = 0.2 + 0.8 * percent1; + b = 0.2; + } else { + percent1 = (j - 6) / 6.0; + r = 0.2; + g = 1.0 - 0.8 * percent1; + b = 0.2 + 0.8 * percent1; + } + glutSetColor(j+18, r, g, b); + for (i = 0; i < 16; i++) { + percent2 = i / 15.0; + glutSetColor(j*16+1+32, r*percent2, g*percent2, b*percent2); + } + } + color1 = 18; + color2 = 24; + color3 = 30; + } +} + +static void Reshape(int width, int height) +{ + + windW = (GLint)width; + windH = (GLint)height; +} + +static void Key2(int key, int x, int y) +{ + + switch (key) { + case GLUT_KEY_LEFT: + zRotation += 0.5; + break; + case GLUT_KEY_RIGHT: + zRotation -= 0.5; + break; + default: + return; + } + + glutPostRedisplay(); +} + +static void Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + case 'Z': + zoom *= 0.75; + break; + case 'z': + zoom /= 0.75; + if (zoom > 10) { + zoom = 10; + } + break; + case '1': + glPolygonMode(GL_FRONT_AND_BACK, GL_POINT); + break; + case '2': + glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); + break; + case '3': + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); + break; + case '4': + state = POINT; + break; + case '5': + state = LINE; + break; + case '6': + state = SOLID; + break; + case '7': + culling = !culling; + break; + case '8': + winding = !winding; + break; + case '9': + face = !face; + break; + case 'v': + showVerticies = !showVerticies; + break; + case 's': + shade = !shade; + (shade) ? glShadeModel(GL_SMOOTH) : glShadeModel(GL_FLAT); + break; + case 'h': + hideBottomTriangle = !hideBottomTriangle; + break; + case 'o': + outline = !outline; + break; + case 'm': + dithering = !dithering; + break; + case '0': + aaMode = !aaMode; + if (aaMode) { + glEnable(GL_POLYGON_SMOOTH); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE); + if (!rgb) { + color1 = 32; + color2 = 128; + color3 = 224; + } + } else { + glDisable(GL_POLYGON_SMOOTH); + glDisable(GL_BLEND); + if (!rgb) { + color1 = 18; + color2 = 24; + color3 = 30; + } + } + break; + default: + return; + } + + glutPostRedisplay(); +} + +static void BeginPrim(void) +{ + + switch (state) { + case SOLID: + glBegin(GL_POLYGON); + break; + case LINE: + glBegin(GL_LINE_LOOP); + break; + case POINT: + glBegin(GL_POINTS); + break; + default: + break; + } +} + +static void EndPrim(void) +{ + + glEnd(); +} + +static void Draw(void) +{ + float scaleX, scaleY; + + glViewport(0, 0, windW, windH); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluOrtho2D(-175, 175, -175, 175); + glMatrixMode(GL_MODELVIEW); + + glScissor(0, 0, windW, windH); + + (culling) ? glEnable(GL_CULL_FACE) : glDisable(GL_CULL_FACE); + (winding) ? glFrontFace(GL_CCW) : glFrontFace(GL_CW); + (face) ? glCullFace(GL_FRONT) : glCullFace(GL_BACK); + + (dithering) ? glEnable(GL_DITHER) : glDisable(GL_DITHER); + + glClear(GL_COLOR_BUFFER_BIT); + + SetColor(COLOR_GREEN); + glBegin(GL_LINE_LOOP); + glVertex3fv(boxA); + glVertex3fv(boxB); + glVertex3fv(boxC); + glVertex3fv(boxD); + glEnd(); + + if (!hideBottomTriangle) { + glPushMatrix(); + + glScalef(zoom, zoom, zoom); + glRotatef(zRotation, 0, 0, 1); + + SetColor(COLOR_BLUE); + BeginPrim(); + glVertex3fv(p0); + glVertex3fv(p1); + glVertex3fv(p2); + EndPrim(); + + if (showVerticies) { + (rgb) ? glColor3fv(RGBMap[COLOR_RED]) : glIndexf(color1); + glRectf(p0[0]-2, p0[1]-2, p0[0]+2, p0[1]+2); + (rgb) ? glColor3fv(RGBMap[COLOR_GREEN]) : glIndexf(color2); + glRectf(p1[0]-2, p1[1]-2, p1[0]+2, p1[1]+2); + (rgb) ? glColor3fv(RGBMap[COLOR_BLUE]) : glIndexf(color3); + glRectf(p2[0]-2, p2[1]-2, p2[0]+2, p2[1]+2); + } + + glPopMatrix(); + } + + scaleX = (float)(windW - 20) / 2 / 175 * (175 - 100) + 10; + scaleY = (float)(windH - 20) / 2 / 175 * (175 - 100) + 10; + + glViewport(scaleX, scaleY, windW-2*scaleX, windH-2*scaleY); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluOrtho2D(-100, 100, -100, 100); + glMatrixMode(GL_MODELVIEW); + + glScissor(scaleX, scaleY, windW-2*scaleX, windH-2*scaleY); + + glPushMatrix(); + + glScalef(zoom, zoom, zoom); + glRotatef(zRotation, 0,0,1); + + glPointSize(10); + glLineWidth(5); + glEnable(GL_POINT_SMOOTH); + glEnable(GL_LINE_STIPPLE); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + SetColor(COLOR_RED); + BeginPrim(); + (rgb) ? glColor3fv(RGBMap[COLOR_RED]) : glIndexf(color1); + glVertex3fv(p0); + (rgb) ? glColor3fv(RGBMap[COLOR_GREEN]) : glIndexf(color2); + glVertex3fv(p1); + (rgb) ? glColor3fv(RGBMap[COLOR_BLUE]) : glIndexf(color3); + glVertex3fv(p2); + EndPrim(); + + glPointSize(1); + glLineWidth(1); + glDisable(GL_POINT_SMOOTH); + glDisable(GL_LINE_STIPPLE); + glBlendFunc(GL_ONE, GL_ZERO); + + if (outline) { + SetColor(COLOR_WHITE); + glBegin(GL_LINE_LOOP); + glVertex3fv(p0); + glVertex3fv(p1); + glVertex3fv(p2); + glEnd(); + } + + glPopMatrix(); + + glFlush(); + + if (doubleBuffer) { + glutSwapBuffers(); + } +} + +static GLenum Args(int argc, char **argv) +{ + GLint i; + + rgb = GL_TRUE; + doubleBuffer = GL_FALSE; + + for (i = 1; i < argc; i++) { + if (strcmp(argv[i], "-ci") == 0) { + rgb = GL_FALSE; + } else if (strcmp(argv[i], "-rgb") == 0) { + rgb = GL_TRUE; + } else 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; +} + +int main(int argc, char **argv) +{ + glutInit(&argc, argv); + + if (Args(argc, argv) == GL_FALSE) { + exit(1); + } + + windW = 600; + windH = 300; + glutInitWindowPosition(0, 0); glutInitWindowSize( windW, windH); + + windType = (rgb) ? GLUT_RGB : GLUT_INDEX; + windType |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; + glutInitDisplayMode(windType); + + if (glutCreateWindow("Triangle Test") == GL_FALSE) { + exit(1); + } + + InitMap(); + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutSpecialFunc(Key2); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/samples/wave.c b/progs/samples/wave.c new file mode 100644 index 00000000000..d3c4687459e --- /dev/null +++ b/progs/samples/wave.c @@ -0,0 +1,619 @@ +/* + * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the name of + * Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF + * ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#include +#include +#include +#include +#include + +#ifndef PI +#define PI 3.14159265358979323846 +#endif + +#define GETCOORD(frame, x, y) (&(theMesh.coords[frame*theMesh.numCoords+(x)+(y)*(theMesh.widthX+1)])) +#define GETFACET(frame, x, y) (&(theMesh.facets[frame*theMesh.numFacets+(x)+(y)*theMesh.widthX])) + + +GLenum rgb, doubleBuffer; + +#include "tkmap.c" + +GLint colorIndexes1[3]; +GLint colorIndexes2[3]; +GLenum clearMask = GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT; + +GLenum smooth = GL_FALSE; +GLenum lighting = GL_TRUE; +GLenum depth = GL_TRUE; +GLenum stepMode = GL_FALSE; +GLenum spinMode = GL_FALSE; +GLint contouring = 0; + +GLint widthX, widthY; +GLint checkerSize; +float height; + +GLint frames, curFrame = 0, nextFrame = 0; + +struct facet { + float color[3]; + float normal[3]; +}; +struct coord { + float vertex[3]; + float normal[3]; +}; +struct mesh { + GLint widthX, widthY; + GLint numFacets; + GLint numCoords; + GLint frames; + struct coord *coords; + struct facet *facets; +} theMesh; + +GLubyte contourTexture1[] = { + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 127, 127, 127, 127, +}; +GLubyte contourTexture2[] = { + 255, 255, 255, 255, + 255, 127, 127, 127, + 255, 127, 127, 127, + 255, 127, 127, 127, +}; + +#if !defined(GLUTCALLBACK) +#define GLUTCALLBACK +#endif + + +void GLUTCALLBACK glut_post_redisplay_p(void) +{ + static double t0 = -1.; + double t, dt; + t = glutGet(GLUT_ELAPSED_TIME) / 1000.; + if (t0 < 0.) + t0 = t; + dt = t - t0; + + if (dt < 1./30.) + return; + + t0 = t; + + glutPostRedisplay(); +} + +static void Animate(void) +{ + struct coord *coord; + struct facet *facet; + float *lastColor; + float *thisColor; + GLint i, j; + + glClear(clearMask); + + if (nextFrame || !stepMode) { + curFrame++; + } + if (curFrame >= theMesh.frames) { + curFrame = 0; + } + + if ((nextFrame || !stepMode) && spinMode) { + glRotatef(5.0, 0.0, 0.0, 1.0); + } + nextFrame = 0; + + for (i = 0; i < theMesh.widthX; i++) { + glBegin(GL_QUAD_STRIP); + lastColor = NULL; + for (j = 0; j < theMesh.widthY; j++) { + facet = GETFACET(curFrame, i, j); + if (!smooth && lighting) { + glNormal3fv(facet->normal); + } + if (lighting) { + if (rgb) { + thisColor = facet->color; + glColor3fv(facet->color); + } else { + thisColor = facet->color; + glMaterialfv(GL_FRONT_AND_BACK, GL_COLOR_INDEXES, + facet->color); + } + } else { + if (rgb) { + thisColor = facet->color; + glColor3fv(facet->color); + } else { + thisColor = facet->color; + glIndexf(facet->color[1]); + } + } + + if (!lastColor || (thisColor[0] != lastColor[0] && smooth)) { + if (lastColor) { + glEnd(); + glBegin(GL_QUAD_STRIP); + } + coord = GETCOORD(curFrame, i, j); + if (smooth && lighting) { + glNormal3fv(coord->normal); + } + glVertex3fv(coord->vertex); + + coord = GETCOORD(curFrame, i+1, j); + if (smooth && lighting) { + glNormal3fv(coord->normal); + } + glVertex3fv(coord->vertex); + } + + coord = GETCOORD(curFrame, i, j+1); + if (smooth && lighting) { + glNormal3fv(coord->normal); + } + glVertex3fv(coord->vertex); + + coord = GETCOORD(curFrame, i+1, j+1); + if (smooth && lighting) { + glNormal3fv(coord->normal); + } + glVertex3fv(coord->vertex); + + lastColor = thisColor; + } + glEnd(); + } + + glFlush(); + if (doubleBuffer) { + glutSwapBuffers(); + } +} + +static void SetColorMap(void) +{ + static float green[3] = {0.2, 1.0, 0.2}; + static float red[3] = {1.0, 0.2, 0.2}; + float *color = 0, percent; + GLint *indexes = 0, entries, i, j; + + entries = glutGet(GLUT_WINDOW_COLORMAP_SIZE); + + colorIndexes1[0] = 1; + colorIndexes1[1] = 1 + (GLint)((entries - 1) * 0.3); + colorIndexes1[2] = (GLint)((entries - 1) * 0.5); + colorIndexes2[0] = 1 + (GLint)((entries - 1) * 0.5); + colorIndexes2[1] = 1 + (GLint)((entries - 1) * 0.8); + colorIndexes2[2] = entries - 1; + + for (i = 0; i < 2; i++) { + switch (i) { + case 0: + color = green; + indexes = colorIndexes1; + break; + case 1: + color = red; + indexes = colorIndexes2; + break; + } + + for (j = indexes[0]; j < indexes[1]; j++) { + percent = 0.2 + 0.8 * (j - indexes[0]) / + (float)(indexes[1] - indexes[0]); + glutSetColor(j, percent*color[0], percent*color[1], + percent*color[2]); + } + for (j=indexes[1]; j<=indexes[2]; j++) { + percent = (j - indexes[1]) / (float)(indexes[2] - indexes[1]); + glutSetColor(j, percent*(1-color[0])+color[0], + percent*(1-color[1])+color[1], + percent*(1-color[2])+color[2]); + } + } +} + +static void InitMesh(void) +{ + struct coord *coord; + struct facet *facet; + float dp1[3], dp2[3]; + float *pt1, *pt2, *pt3; + float angle, d, x, y; + GLint numFacets, numCoords, frameNum, i, j; + + theMesh.widthX = widthX; + theMesh.widthY = widthY; + theMesh.frames = frames; + + numFacets = widthX * widthY; + numCoords = (widthX + 1) * (widthY + 1); + + theMesh.numCoords = numCoords; + theMesh.numFacets = numFacets; + + theMesh.coords = (struct coord *)malloc(frames*numCoords* + sizeof(struct coord)); + theMesh.facets = (struct facet *)malloc(frames*numFacets* + sizeof(struct facet)); + if (theMesh.coords == NULL || theMesh.facets == NULL) { + printf("Out of memory.\n"); + exit(1); + } + + for (frameNum = 0; frameNum < frames; frameNum++) { + for (i = 0; i <= widthX; i++) { + x = i / (float)widthX; + for (j = 0; j <= widthY; j++) { + y = j / (float)widthY; + + d = sqrt(x*x+y*y); + if (d == 0.0) { + d = 0.0001; + } + angle = 2 * PI * d + (2 * PI / frames * frameNum); + + coord = GETCOORD(frameNum, i, j); + + coord->vertex[0] = x - 0.5; + coord->vertex[1] = y - 0.5; + coord->vertex[2] = (height - height * d) * cos(angle); + + coord->normal[0] = -(height / d) * x * ((1 - d) * 2 * PI * + sin(angle) + cos(angle)); + coord->normal[1] = -(height / d) * y * ((1 - d) * 2 * PI * + sin(angle) + cos(angle)); + coord->normal[2] = -1; + + d = 1.0 / sqrt(coord->normal[0]*coord->normal[0]+ + coord->normal[1]*coord->normal[1]+1); + coord->normal[0] *= d; + coord->normal[1] *= d; + coord->normal[2] *= d; + } + } + for (i = 0; i < widthX; i++) { + for (j = 0; j < widthY; j++) { + facet = GETFACET(frameNum, i, j); + if (((i/checkerSize)%2)^(j/checkerSize)%2) { + if (rgb) { + facet->color[0] = 1.0; + facet->color[1] = 0.2; + facet->color[2] = 0.2; + } else { + facet->color[0] = colorIndexes1[0]; + facet->color[1] = colorIndexes1[1]; + facet->color[2] = colorIndexes1[2]; + } + } else { + if (rgb) { + facet->color[0] = 0.2; + facet->color[1] = 1.0; + facet->color[2] = 0.2; + } else { + facet->color[0] = colorIndexes2[0]; + facet->color[1] = colorIndexes2[1]; + facet->color[2] = colorIndexes2[2]; + } + } + pt1 = GETCOORD(frameNum, i, j)->vertex; + pt2 = GETCOORD(frameNum, i, j+1)->vertex; + pt3 = GETCOORD(frameNum, i+1, j+1)->vertex; + + dp1[0] = pt2[0] - pt1[0]; + dp1[1] = pt2[1] - pt1[1]; + dp1[2] = pt2[2] - pt1[2]; + + dp2[0] = pt3[0] - pt2[0]; + dp2[1] = pt3[1] - pt2[1]; + dp2[2] = pt3[2] - pt2[2]; + + facet->normal[0] = dp1[1] * dp2[2] - dp1[2] * dp2[1]; + facet->normal[1] = dp1[2] * dp2[0] - dp1[0] * dp2[2]; + facet->normal[2] = dp1[0] * dp2[1] - dp1[1] * dp2[0]; + + d = 1.0 / sqrt(facet->normal[0]*facet->normal[0]+ + facet->normal[1]*facet->normal[1]+ + facet->normal[2]*facet->normal[2]); + + facet->normal[0] *= d; + facet->normal[1] *= d; + facet->normal[2] *= d; + } + } + } +} + +static void InitMaterials(void) +{ + static float ambient[] = {0.1, 0.1, 0.1, 1.0}; + static float diffuse[] = {0.5, 1.0, 1.0, 1.0}; + static float position[] = {90.0, 90.0, 150.0, 0.0}; + static float front_mat_shininess[] = {60.0}; + static float front_mat_specular[] = {0.2, 0.2, 0.2, 1.0}; + static float front_mat_diffuse[] = {0.5, 0.28, 0.38, 1.0}; + static float back_mat_shininess[] = {60.0}; + static float back_mat_specular[] = {0.5, 0.5, 0.2, 1.0}; + static float back_mat_diffuse[] = {1.0, 1.0, 0.2, 1.0}; + static float lmodel_ambient[] = {1.0, 1.0, 1.0, 1.0}; + static float lmodel_twoside[] = {GL_TRUE}; + + glMatrixMode(GL_PROJECTION); + gluPerspective(90.0, 1.0, 0.5, 10.0); + + glLightfv(GL_LIGHT0, GL_AMBIENT, ambient); + glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse); + glLightfv(GL_LIGHT0, GL_POSITION, position); + glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient); + glLightModelfv(GL_LIGHT_MODEL_TWO_SIDE, lmodel_twoside); + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + + glMaterialfv(GL_FRONT, GL_SHININESS, front_mat_shininess); + glMaterialfv(GL_FRONT, GL_SPECULAR, front_mat_specular); + glMaterialfv(GL_FRONT, GL_DIFFUSE, front_mat_diffuse); + glMaterialfv(GL_BACK, GL_SHININESS, back_mat_shininess); + glMaterialfv(GL_BACK, GL_SPECULAR, back_mat_specular); + glMaterialfv(GL_BACK, GL_DIFFUSE, back_mat_diffuse); + if (rgb) { + glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE); + } + + if (rgb) { + glEnable(GL_COLOR_MATERIAL); + } else { + SetColorMap(); + } +} + +static void InitTexture(void) +{ + + 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_MAG_FILTER, GL_NEAREST); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); +} + +static void Init(void) +{ + + glClearColor(0.0, 0.0, 0.0, 0.0); + + glShadeModel(GL_FLAT); + + glFrontFace(GL_CW); + + glEnable(GL_DEPTH_TEST); + + InitMaterials(); + InitTexture(); + InitMesh(); + + glMatrixMode(GL_MODELVIEW); + glTranslatef(0.0, 0.4, -1.8); + glScalef(2.0, 2.0, 2.0); + glRotatef(-35.0, 1.0, 0.0, 0.0); + glRotatef(35.0, 0.0, 0.0, 1.0); +} + +static void Reshape(int width, int height) +{ + + glViewport(0, 0, (GLint)width, (GLint)height); +} + +static void Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + case 'c': + contouring++; + if (contouring == 1) { + static GLfloat map[4] = {0, 0, 20, 0}; + + glTexImage2D(GL_TEXTURE_2D, 0, 3, 4, 4, 0, GL_LUMINANCE, + GL_UNSIGNED_BYTE, (GLvoid *)contourTexture1); + glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); + glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); + glTexGenfv(GL_S, GL_OBJECT_PLANE, map); + glTexGenfv(GL_T, GL_OBJECT_PLANE, map); + glEnable(GL_TEXTURE_2D); + glEnable(GL_TEXTURE_GEN_S); + glEnable(GL_TEXTURE_GEN_T); + } else if (contouring == 2) { + static GLfloat map[4] = {0, 0, 20, 0}; + + glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR); + glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR); + glPushMatrix(); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTexGenfv(GL_S, GL_EYE_PLANE, map); + glTexGenfv(GL_T, GL_EYE_PLANE, map); + glPopMatrix(); + } else { + contouring = 0; + glDisable(GL_TEXTURE_GEN_S); + glDisable(GL_TEXTURE_GEN_T); + glDisable(GL_TEXTURE_2D); + } + break; + case 's': + smooth = !smooth; + if (smooth) { + glShadeModel(GL_SMOOTH); + } else { + glShadeModel(GL_FLAT); + } + break; + case 'l': + lighting = !lighting; + if (lighting) { + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + if (rgb) { + glEnable(GL_COLOR_MATERIAL); + } + } else { + glDisable(GL_LIGHTING); + glDisable(GL_LIGHT0); + if (rgb) { + glDisable(GL_COLOR_MATERIAL); + } + } + break; + case 'd': + depth = !depth; + if (depth) { + glEnable(GL_DEPTH_TEST); + clearMask |= GL_DEPTH_BUFFER_BIT; + } else { + glDisable(GL_DEPTH_TEST); + clearMask &= ~GL_DEPTH_BUFFER_BIT; + } + break; + case 32: + stepMode = !stepMode; + if (stepMode) { + glutIdleFunc(0); + } else { + glutIdleFunc(glut_post_redisplay_p); + } + break; + case 'n': + if (stepMode) { + nextFrame = 1; + } + break; + case 'a': + spinMode = !spinMode; + break; + default: + return; + } + glutPostRedisplay(); +} + +static GLenum Args(int argc, char **argv) +{ + GLint i; + + rgb = GL_TRUE; + doubleBuffer = GL_TRUE; + frames = 10; + widthX = 10; + widthY = 10; + checkerSize = 2; + height = 0.2; + + for (i = 1; i < argc; i++) { + if (strcmp(argv[i], "-ci") == 0) { + rgb = GL_FALSE; + } else if (strcmp(argv[i], "-rgb") == 0) { + rgb = GL_TRUE; + } else if (strcmp(argv[i], "-sb") == 0) { + doubleBuffer = GL_FALSE; + } else if (strcmp(argv[i], "-db") == 0) { + doubleBuffer = GL_TRUE; + } else if (strcmp(argv[i], "-grid") == 0) { + if (i+2 >= argc || argv[i+1][0] == '-' || argv[i+2][0] == '-') { + printf("-grid (No numbers).\n"); + return GL_FALSE; + } else { + widthX = atoi(argv[++i]); + widthY = atoi(argv[++i]); + } + } else if (strcmp(argv[i], "-size") == 0) { + if (i+1 >= argc || argv[i+1][0] == '-') { + printf("-checker (No number).\n"); + return GL_FALSE; + } else { + checkerSize = atoi(argv[++i]); + } + } else if (strcmp(argv[i], "-wave") == 0) { + if (i+1 >= argc || argv[i+1][0] == '-') { + printf("-wave (No number).\n"); + return GL_FALSE; + } else { + height = atof(argv[++i]); + } + } else if (strcmp(argv[i], "-frames") == 0) { + if (i+1 >= argc || argv[i+1][0] == '-') { + printf("-frames (No number).\n"); + return GL_FALSE; + } else { + frames = atoi(argv[++i]); + } + } else { + printf("%s (Bad option).\n", argv[i]); + return GL_FALSE; + } + } + return GL_TRUE; +} + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + if (Args(argc, argv) == GL_FALSE) { + exit(1); + } + + glutInitWindowPosition(0, 0); glutInitWindowSize( 300, 300); + + type = GLUT_DEPTH; + type |= (rgb) ? GLUT_RGB : GLUT_INDEX; + type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("Wave Demo") == GL_FALSE) { + exit(1); + } + + InitMap(); + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Animate); + glutIdleFunc(glut_post_redisplay_p); + glutMainLoop(); + return 0; +} diff --git a/progs/tests/.cvsignore b/progs/tests/.cvsignore new file mode 100644 index 00000000000..2c0e16c35ec --- /dev/null +++ b/progs/tests/.cvsignore @@ -0,0 +1,54 @@ +.cvsignore +getproclist.h +antialias +arbfpspec +arbfptest1 +arbfptexture +arbfptrig +arbvptest1 +arbvptest3 +arbvptorus +arbvpwarpmesh +blendminmax +blendsquare +bufferobj +bug_3101 +bug_3195 +crossbar +cva +dinoshade +fbotest1 +fbotexture +floattex +fog +fogcoord +fptest1 +fptexture +getprocaddress +invert +manytex +multipal +no_s3tc +packedpixels +pbo +projtex +seccolor +sharedtex +stencil_wrap +stencilwrap +tex1d +texcmp +texgenmix +texline +texobjshare +texrect +texwrap +vparray +vptest1 +vptest2 +vptest3 +vptorus +vpwarpmesh +yuvrect +yuvsquare +zreaddraw diff --git a/progs/tests/Makefile b/progs/tests/Makefile new file mode 100644 index 00000000000..7f6655dd54b --- /dev/null +++ b/progs/tests/Makefile @@ -0,0 +1,154 @@ +# progs/tests/Makefile + + +# These programs aren't intended to be included with the normal distro. +# They're not too interesting but they're good for testing. + +TOP = ../.. +include $(TOP)/configs/current + + +LIBS = $(APP_LIB_DEPS) + +SOURCES = \ + afsmultiarb.c \ + antialias.c \ + arbfpspec.c \ + arbfptest1.c \ + arbfptexture.c \ + arbfptrig.c \ + arbnpot.c \ + arbvptest1.c \ + arbvptest3.c \ + arbvptorus.c \ + arbvpwarpmesh.c \ + blendminmax.c \ + blendsquare.c \ + bufferobj.c \ + bug_3050.c \ + bug_3101.c \ + bug_3195.c \ + copypixrate.c \ + crossbar.c \ + cva.c \ + dinoshade.c \ + floattex.c \ + fbotest1.c \ + fbotest2.c \ + fbotexture.c \ + fog.c \ + fogcoord.c \ + fptest1.c \ + fptexture.c \ + getprocaddress.c \ + interleave.c \ + invert.c \ + jkrahntest.c \ + manytex.c \ + mipmap_limits.c \ + multipal.c \ + no_s3tc.c \ + packedpixels.c \ + pbo.c \ + projtex.c \ + readrate.c \ + seccolor.c \ + sharedtex.c \ + stencilwrap.c \ + stencil_wrap.c \ + subtexrate.c \ + tex1d.c \ + texcompress2.c \ + texfilt.c \ + texline.c \ + texobjshare.c \ + texrect.c \ + texwrap.c \ + vparray.c \ + vptest1.c \ + vptest2.c \ + vptest3.c \ + vptorus.c \ + vpwarpmesh.c \ + yuvrect.c \ + yuvsquare.c \ + zreaddraw.c + +PROGS = $(SOURCES:%.c=%) + +INCLUDES = -I. -I$(TOP)/include + +UTIL_FILES = readtex.h readtex.c + + +##### RULES ##### + +.SUFFIXES: +.SUFFIXES: .c + +.c: + $(CC) $(INCLUDES) $(CFLAGS) $< $(LIBS) -o $@ + +.c.o: + $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ + +.S.o: + $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ + + +##### TARGETS ##### + +default: $(UTIL_FILES) $(PROGS) + +clean: + rm -f $(PROGS) + rm -f *.o + rm -f getproclist.h + + +# auto code generation +getprocaddress: getprocaddress.c getproclist.h + +getproclist.h: $(TOP)/src/mesa/glapi/gl_API.xml getprocaddress.c getprocaddress.py + python getprocaddress.py > getproclist.h + +afsmultiarb: afsmultiarb.o readtex.o + $(CC) $(CFLAGS) afsmultiarb.o readtex.o $(LIBS) -o $@ + +afsmultiarb.o: afsmultiarb.c readtex.h + $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ + +texrect: texrect.o readtex.o + $(CC) $(CFLAGS) texrect.o readtex.o $(LIBS) -o $@ + +texrect.o: texrect.c readtex.h + $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ + +bug_3195: bug_3195.o readtex.o + $(CC) $(CFLAGS) bug_3195.o readtex.o $(LIBS) -o $@ + +bug_3195.o: bug_3195.c readtex.h + $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ + +invert: invert.o readtex.o + $(CC) $(CFLAGS) invert.o readtex.o $(LIBS) -o $@ + +invert.o: invert.c readtex.h + $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ + +readtex.o: readtex.c + $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ + + +readtex.h: $(TOP)/progs/util/readtex.h + ln -s $(TOP)/progs/util/readtex.h . + +readtex.c: $(TOP)/progs/util/readtex.c + ln -s $(TOP)/progs/util/readtex.c . + + + + +# Emacs tags +tags: + etags `find . -name \*.[ch]` `find ../include` diff --git a/progs/tests/Makefile.win b/progs/tests/Makefile.win new file mode 100644 index 00000000000..ff5b1e626e8 --- /dev/null +++ b/progs/tests/Makefile.win @@ -0,0 +1,44 @@ +# $Id: Makefile.win,v 1.1 2002-01-16 01:03:25 kschultz Exp $ + +# Mesa 3-D graphics library +# Version: 3.5 +# Copyright (C) 1995-2001 Brian Paul + +# Makefile for GLUT-based demo programs for Windows + +!include + +##### MACROS ##### + +TOP = .. +INCDIR = ..\include +LIBDIR = ..\lib + +SRCS = cva.c \ + dinoshade.c \ + fogcoord.c \ + manytex.c \ + multipal.c \ + projtex.c \ + seccolor.c \ +# sharedtex.c \ + texline.c \ + texwrap.c \ + vptest1.c \ + vptest2.c \ + vptest3.c \ + vptorus.c \ + vpwarpmesh.c + +!include "../mesawin32.mak" + +##### TARGETS ##### + +clean:: + +clobber:: + @del readtex.c readtex.h + +$(EXES) :$*.obj + @echo $@ + $(link) -out:$@ $* /LIBPATH:$(LIBDIR) $(LIBS) diff --git a/progs/tests/afsmultiarb.c b/progs/tests/afsmultiarb.c new file mode 100644 index 00000000000..c026ecd4ce2 --- /dev/null +++ b/progs/tests/afsmultiarb.c @@ -0,0 +1,469 @@ +/* + * GL_ATI_fragment_shader test + * Roland Scheidegger + * + * Command line options: + * -info print GL implementation information + */ + + +#include +#include +#include +#include +#define GL_GLEXT_PROTOTYPES +#include + +#include "readtex.h" + +#define TEXTURE_1_FILE "../images/girl.rgb" +#define TEXTURE_2_FILE "../images/reflect.rgb" + +#define TEX0 1 +#define TEX7 8 +#define ANIMATE 10 +#define SHADER 20 +#define QUIT 100 + +static GLboolean Animate = GL_TRUE; +static GLint NumUnits = 6; +static GLboolean TexEnabled[8]; +static GLuint boringshaderID = 0; +static GLuint boring2passID = 0; +static GLboolean Shader = GL_FALSE; + +static GLfloat Drift = 0.0; +static GLfloat drift_increment = 0.005; +static GLfloat Xrot = 20.0, Yrot = 30.0, Zrot = 0.0; +static GLfloat shaderconstant[4] = {0.5, 0.0, 0.0, 0.0}; + +static void Idle( void ) +{ + if (Animate) { + GLint i; + + Drift += drift_increment; + if (Drift >= 1.0) + Drift = 0.0; + + for (i = 0; i < NumUnits; i++) { + glActiveTextureARB(GL_TEXTURE0_ARB + i); + glMatrixMode(GL_TEXTURE); + glLoadIdentity(); + if (i == 0) { + glTranslatef(Drift, 0.0, 0.0); + glScalef(2, 2, 1); + } + else if (i == 1) { + glTranslatef(0.0, Drift, 0.0); + } + else { + glTranslatef(0.5, 0.5, 0.0); + glRotatef(180.0 * Drift, 0, 0, 1); + glScalef(1.0/i, 1.0/i, 1.0/i); + glTranslatef(-0.5, -0.5, 0.0); + } + } + glMatrixMode(GL_MODELVIEW); + + glutPostRedisplay(); + } +} + + +static void DrawObject(void) +{ + GLint i; + GLint j; + static const GLfloat tex_coords[] = { 0.0, 0.0, 1.0, 1.0, 0.0 }; + static const GLfloat vtx_coords[] = { -1.0, -1.0, 1.0, 1.0, -1.0 }; + + if (!TexEnabled[0] && !TexEnabled[1]) + glColor3f(0.1, 0.1, 0.1); /* add onto this */ + else + glColor3f(1, 1, 1); /* modulate this */ + + glBegin(GL_QUADS); + + /* Toggle between the vector and scalar entry points. This is done purely + * to hit multiple paths in the driver. + */ + if ( Drift > 0.49 ) { + for (j = 0; j < 4; j++ ) { + for (i = 0; i < NumUnits; i++) + glMultiTexCoord2fARB(GL_TEXTURE0_ARB + i, + tex_coords[j], tex_coords[j+1]); + glVertex2f( vtx_coords[j], vtx_coords[j+1] ); + } + } + else { + for (j = 0; j < 4; j++ ) { + for (i = 0; i < NumUnits; i++) + glMultiTexCoord2fvARB(GL_TEXTURE0_ARB + i, & tex_coords[j]); + glVertex2fv( & vtx_coords[j] ); + } + } + + glEnd(); +} + + + +static void Display( void ) +{ + static GLint T0 = 0; + static GLint Frames = 0; + GLint t; + + glClear( GL_COLOR_BUFFER_BIT ); + + glPushMatrix(); + glRotatef(Xrot, 1.0, 0.0, 0.0); + glRotatef(Yrot, 0.0, 1.0, 0.0); + glRotatef(Zrot, 0.0, 0.0, 1.0); + glScalef(5.0, 5.0, 5.0); + DrawObject(); + glPopMatrix(); + + glutSwapBuffers(); + + Frames++; + + t = glutGet(GLUT_ELAPSED_TIME); + if (t - T0 >= 2500) { + GLfloat seconds = (t - T0) / 1000.0; + GLfloat fps = Frames / seconds; + drift_increment = 2.2 * seconds / Frames; + printf("%d frames in %6.3f seconds = %6.3f FPS\n", Frames, seconds, fps); + T0 = t; + Frames = 0; + } +} + + +static void Reshape( int width, int height ) +{ + glViewport( 0, 0, width, height ); + glMatrixMode( GL_PROJECTION ); + glLoadIdentity(); + glFrustum( -1.0, 1.0, -1.0, 1.0, 10.0, 100.0 ); + /*glOrtho( -6.0, 6.0, -6.0, 6.0, 10.0, 100.0 );*/ + glMatrixMode( GL_MODELVIEW ); + glLoadIdentity(); + glTranslatef( 0.0, 0.0, -70.0 ); +} + + +static void ModeMenu(int entry) +{ + if (entry >= TEX0 && entry <= TEX7) { + /* toggle */ + GLint i = entry - TEX0; + TexEnabled[i] = !TexEnabled[i]; + glActiveTextureARB(GL_TEXTURE0_ARB + i); + if (TexEnabled[i]) + glEnable(GL_TEXTURE_2D); + else + glDisable(GL_TEXTURE_2D); + printf("Enabled: "); + for (i = 0; i < NumUnits; i++) + printf("%d ", (int) TexEnabled[i]); + printf("\n"); + } + else if (entry==ANIMATE) { + Animate = !Animate; + } + else if (entry==SHADER) { + Shader = !Shader; + if (Shader) { + fprintf(stderr, "using 2-pass shader\n"); + glBindFragmentShaderATI(boring2passID); + } + else { + fprintf(stderr, "using 1-pass shader\n"); + glBindFragmentShaderATI(boringshaderID); + } + } + else if (entry==QUIT) { + exit(0); + } + + glutPostRedisplay(); +} + + +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 ) +{ + float 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( int argc, char *argv[] ) +{ + GLuint texObj[8]; + GLint size, i; + + const char *exten = (const char *) glGetString(GL_EXTENSIONS); + if (!strstr(exten, "GL_ATI_fragment_shader")) { + printf("Sorry, GL_ATI_fragment_shader not supported by this renderer.\n"); + exit(1); + } + + + glGetIntegerv(GL_MAX_TEXTURE_SIZE, &size); + printf("%d x %d max texture size\n", size, size); + + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + + for (i = 0; i < NumUnits; i++) { + if (i < 6) + TexEnabled[i] = GL_TRUE; + else + TexEnabled[i] = GL_FALSE; + } + + /* allocate two texture objects */ + glGenTextures(NumUnits, texObj); + + /* setup the texture objects */ + for (i = 0; i < NumUnits; i++) { + + glActiveTextureARB(GL_TEXTURE0_ARB + i); + glBindTexture(GL_TEXTURE_2D, texObj[i]); + + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + + if (i == 0) { + if (!LoadRGBMipmaps(TEXTURE_1_FILE, GL_RGB)) { + printf("Error: couldn't load texture image\n"); + exit(1); + } + } + else if (i == 1) { + if (!LoadRGBMipmaps(TEXTURE_2_FILE, GL_RGB)) { + printf("Error: couldn't load texture image\n"); + exit(1); + } + } + else { + /* checker */ + GLubyte image[8][8][3]; + GLint i, j; + for (i = 0; i < 8; i++) { + for (j = 0; j < 8; j++) { + if ((i + j) & 1) { + image[i][j][0] = 50; + image[i][j][1] = 50; + image[i][j][2] = 50; + } + else { + image[i][j][0] = 25; + image[i][j][1] = 25; + image[i][j][2] = 25; + } + } + } + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 8, 8, 0, + GL_RGB, GL_UNSIGNED_BYTE, (GLvoid *) image); + } + + /* Bind texObj[i] to ith texture unit */ +/* if (i < 2) + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + else + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_ADD);*/ + + if (TexEnabled[i]) + glEnable(GL_TEXTURE_2D); + } + + boringshaderID = glGenFragmentShadersATI(1); + boring2passID = glGenFragmentShadersATI(1); + if (boring2passID == 0) + { + fprintf(stderr, "couldn't get frag shader id\n"); + exit(1); + } + glBindFragmentShaderATI(boringshaderID); +/* maybe not the most creative shader but at least I know how it should look like! */ + glBeginFragmentShaderATI(); + glSampleMapATI(GL_REG_0_ATI, GL_TEXTURE0_ARB, GL_SWIZZLE_STR_ATI); + glSampleMapATI(GL_REG_1_ATI, GL_TEXTURE1_ARB, GL_SWIZZLE_STR_ATI); + glSampleMapATI(GL_REG_2_ATI, GL_TEXTURE2_ARB, GL_SWIZZLE_STR_ATI); + glSampleMapATI(GL_REG_3_ATI, GL_TEXTURE3_ARB, GL_SWIZZLE_STR_ATI); + glSampleMapATI(GL_REG_4_ATI, GL_TEXTURE4_ARB, GL_SWIZZLE_STR_ATI); + glSampleMapATI(GL_REG_5_ATI, GL_TEXTURE5_ARB, GL_SWIZZLE_STR_ATI); + glColorFragmentOp2ATI(GL_MUL_ATI, + GL_REG_0_ATI, GL_NONE, GL_SATURATE_BIT_ATI, + GL_REG_0_ATI, GL_NONE, GL_NONE, + GL_PRIMARY_COLOR, GL_NONE, GL_NONE); + glAlphaFragmentOp1ATI(GL_MOV_ATI, + GL_REG_0_ATI, GL_NONE, + GL_PRIMARY_COLOR, GL_NONE, GL_NONE); + glColorFragmentOp3ATI(GL_MAD_ATI, + GL_REG_0_ATI, GL_NONE, GL_SATURATE_BIT_ATI, + GL_REG_0_ATI, GL_NONE, GL_NONE, + GL_REG_1_ATI, GL_NONE, GL_NONE, + GL_REG_2_ATI, GL_NONE, GL_NONE); + glColorFragmentOp2ATI(GL_ADD_ATI, + GL_REG_0_ATI, GL_NONE, GL_SATURATE_BIT_ATI, + GL_REG_0_ATI, GL_NONE, GL_NONE, + GL_REG_3_ATI, GL_NONE, GL_NONE); + glColorFragmentOp2ATI(GL_ADD_ATI, + GL_REG_0_ATI, GL_NONE, GL_SATURATE_BIT_ATI, + GL_REG_0_ATI, GL_NONE, GL_NONE, + GL_REG_4_ATI, GL_NONE, GL_NONE); + glColorFragmentOp2ATI(GL_ADD_ATI, + GL_REG_0_ATI, GL_NONE, GL_SATURATE_BIT_ATI, + GL_REG_0_ATI, GL_NONE, GL_NONE, + GL_REG_5_ATI, GL_NONE, GL_NONE); + glEndFragmentShaderATI(); + +/* mathematically equivalent to first shader but using 2 passes together with + some tex coord rerouting */ + glBindFragmentShaderATI(boring2passID); + glBeginFragmentShaderATI(); + glPassTexCoordATI(GL_REG_1_ATI, GL_TEXTURE0_ARB, GL_SWIZZLE_STR_ATI); + glSampleMapATI(GL_REG_2_ATI, GL_TEXTURE2_ARB, GL_SWIZZLE_STR_ATI); + glSampleMapATI(GL_REG_3_ATI, GL_TEXTURE3_ARB, GL_SWIZZLE_STR_ATI); + glSampleMapATI(GL_REG_4_ATI, GL_TEXTURE4_ARB, GL_SWIZZLE_STR_ATI); + glSampleMapATI(GL_REG_5_ATI, GL_TEXTURE5_ARB, GL_SWIZZLE_STR_ATI); + glColorFragmentOp2ATI(GL_ADD_ATI, + GL_REG_0_ATI, GL_NONE, GL_SATURATE_BIT_ATI, + GL_REG_2_ATI, GL_NONE, GL_NONE, + GL_REG_3_ATI, GL_NONE, GL_NONE); + glColorFragmentOp2ATI(GL_ADD_ATI, + GL_REG_0_ATI, GL_NONE, GL_SATURATE_BIT_ATI, + GL_REG_0_ATI, GL_NONE, GL_NONE, + GL_REG_4_ATI, GL_NONE, GL_NONE); + glColorFragmentOp2ATI(GL_ADD_ATI, + GL_REG_0_ATI, GL_NONE, GL_SATURATE_BIT_ATI, + GL_REG_0_ATI, GL_NONE, GL_NONE, + GL_REG_5_ATI, GL_NONE, GL_NONE); + /* not really a dependant read */ + glSampleMapATI(GL_REG_0_ATI, GL_REG_1_ATI, GL_SWIZZLE_STR_ATI); + glSampleMapATI(GL_REG_1_ATI, GL_TEXTURE1_ARB, GL_SWIZZLE_STR_ATI); + glPassTexCoordATI(GL_REG_5_ATI, GL_REG_0_ATI, GL_SWIZZLE_STR_ATI); + glColorFragmentOp2ATI(GL_MUL_ATI, + GL_REG_0_ATI, GL_NONE, GL_SATURATE_BIT_ATI, + GL_REG_0_ATI, GL_NONE, GL_NONE, + GL_PRIMARY_COLOR, GL_NONE, GL_NONE); + glAlphaFragmentOp1ATI(GL_MOV_ATI, + GL_REG_0_ATI, GL_NONE, + GL_PRIMARY_COLOR, GL_NONE, GL_NONE); + glColorFragmentOp3ATI(GL_MAD_ATI, + GL_REG_0_ATI, GL_NONE, GL_SATURATE_BIT_ATI, + GL_REG_0_ATI, GL_NONE, GL_NONE, + GL_REG_1_ATI, GL_NONE, GL_NONE, + GL_REG_5_ATI, GL_NONE, GL_NONE); + /* in principle we're finished here, but to test a bit more + we do some fun with dot ops, replication et al. */ + glSetFragmentShaderConstantATI(GL_CON_3_ATI, shaderconstant); + glColorFragmentOp2ATI(GL_DOT4_ATI, + GL_REG_3_ATI, GL_GREEN_BIT_ATI, GL_EIGHTH_BIT_ATI, + GL_ZERO, GL_NONE, GL_COMP_BIT_ATI | GL_NEGATE_BIT_ATI, + GL_CON_3_ATI, GL_RED, GL_2X_BIT_ATI); + /* those args must get ignored, except dstReg */ + glAlphaFragmentOp2ATI(GL_DOT4_ATI, + GL_REG_4_ATI, GL_NONE, + GL_ZERO, GL_NONE, GL_NONE, + GL_ZERO, GL_NONE, GL_NONE); + /* -> reg3 g = reg4 alpha = -0.5 */ + glAlphaFragmentOp2ATI(GL_ADD_ATI, + GL_REG_5_ATI, GL_NONE, + GL_REG_3_ATI, GL_GREEN, GL_NONE, + GL_REG_4_ATI, GL_NONE, GL_NONE); + /* -> reg5 a = -1 */ + glColorFragmentOp3ATI(GL_DOT2_ADD_ATI, + GL_REG_4_ATI, GL_BLUE_BIT_ATI, GL_HALF_BIT_ATI, + GL_REG_5_ATI, GL_ALPHA, GL_NEGATE_BIT_ATI, + GL_ONE, GL_NONE, GL_BIAS_BIT_ATI, + GL_ONE, GL_ALPHA, GL_2X_BIT_ATI | GL_NEGATE_BIT_ATI); + /* -> reg 4 b = -0.5 */ + glColorFragmentOp2ATI(GL_MUL_ATI, + GL_REG_0_ATI, GL_NONE, GL_NONE, + GL_REG_4_ATI, GL_BLUE, GL_NEGATE_BIT_ATI | GL_2X_BIT_ATI, + GL_REG_0_ATI, GL_NONE, GL_NONE); + glEndFragmentShaderATI(); + + glBindFragmentShaderATI(boringshaderID); + glEnable(GL_FRAGMENT_SHADER_ATI); + + glShadeModel(GL_FLAT); + glClearColor(0.3, 0.3, 0.4, 1.0); + + 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)); + } + printf("output should be identical with both shaders to multiarb demo when 6 textures are enabled\n"); +} + + +int main( int argc, char *argv[] ) +{ +/* GLint i;*/ + + glutInit( &argc, argv ); + glutInitWindowSize( 300, 300 ); + glutInitWindowPosition( 0, 0 ); + glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE ); + glutCreateWindow(argv[0] ); + + Init( argc, argv ); + + glutReshapeFunc( Reshape ); + glutKeyboardFunc( Key ); + glutSpecialFunc( SpecialKey ); + glutDisplayFunc( Display ); + glutIdleFunc( Idle ); + + glutCreateMenu(ModeMenu); + +/* for (i = 0; i < NumUnits; i++) { + char s[100]; + sprintf(s, "Toggle Texture %d", i); + glutAddMenuEntry(s, TEX0 + i); + }*/ + glutAddMenuEntry("Toggle 1/2 Pass Shader", SHADER); + glutAddMenuEntry("Toggle Animation", ANIMATE); + glutAddMenuEntry("Quit", QUIT); + glutAttachMenu(GLUT_RIGHT_BUTTON); + + glutMainLoop(); + return 0; +} diff --git a/progs/tests/antialias.c b/progs/tests/antialias.c new file mode 100644 index 00000000000..d8269a3ee12 --- /dev/null +++ b/progs/tests/antialias.c @@ -0,0 +1,229 @@ +/* $Id: antialias.c,v 1.2 2003-03-29 16:42:57 brianp Exp $ */ + +/* + * Test multisampling and polygon smoothing. + * + * Brian Paul + * 4 November 2002 + */ + +#include +#include +#include +#include + + +static GLfloat Zrot = 0; +static GLboolean Anim = GL_TRUE; +static GLboolean HaveMultisample = GL_TRUE; + + +static void +PrintString(const char *s) +{ + while (*s) { + glutBitmapCharacter(GLUT_BITMAP_8_BY_13, (int) *s); + s++; + } +} + + +static void +Polygon( GLint verts, GLfloat radius, GLfloat z ) +{ + int i; + for (i = 0; i < verts; i++) { + float a = (i * 2.0 * 3.14159) / verts; + float x = radius * cos(a); + float y = radius * sin(a); + glVertex3f(x, y, z); + } +} + + +static void +DrawObject( void ) +{ + glLineWidth(3.0); + glColor3f(1, 1, 1); + glBegin(GL_LINE_LOOP); + Polygon(12, 1.2, 0); + glEnd(); + + glLineWidth(1.0); + glColor3f(1, 1, 1); + glBegin(GL_LINE_LOOP); + Polygon(12, 1.1, 0); + glEnd(); + + glColor3f(1, 0, 0); + glBegin(GL_POLYGON); + Polygon(12, 0.4, 0.3); + glEnd(); + + glColor3f(0, 1, 0); + glBegin(GL_POLYGON); + Polygon(12, 0.6, 0.2); + glEnd(); + + glColor3f(0, 0, 1); + glBegin(GL_POLYGON); + Polygon(12, 0.8, 0.1); + glEnd(); + + glColor3f(1, 1, 1); + glBegin(GL_POLYGON); + Polygon(12, 1.0, 0); + glEnd(); +} + + +static void +Display( void ) +{ + glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); + + glColor3f(1, 1, 1); + if (HaveMultisample) { + glRasterPos2f(-3.1, -1.6); + PrintString("MULTISAMPLE"); + } + glRasterPos2f(-0.8, -1.6); + PrintString("No antialiasing"); + glRasterPos2f(1.6, -1.6); + PrintString("GL_POLYGON_SMOOTH"); + + /* multisample */ + if (HaveMultisample) { + glEnable(GL_DEPTH_TEST); + glEnable(GL_MULTISAMPLE_ARB); + glPushMatrix(); + glTranslatef(-2.5, 0, 0); + glPushMatrix(); + glRotatef(Zrot, 0, 0, 1); + DrawObject(); + glPopMatrix(); + glPopMatrix(); + glDisable(GL_MULTISAMPLE_ARB); + glDisable(GL_DEPTH_TEST); + } + + /* non-aa */ + glEnable(GL_DEPTH_TEST); + glPushMatrix(); + glTranslatef(0, 0, 0); + glPushMatrix(); + glRotatef(Zrot, 0, 0, 1); + DrawObject(); + glPopMatrix(); + glPopMatrix(); + glDisable(GL_DEPTH_TEST); + + /* polygon smooth */ + glEnable(GL_POLYGON_SMOOTH); + glEnable(GL_LINE_SMOOTH); + glEnable(GL_BLEND); + glPushMatrix(); + glTranslatef(2.5, 0, 0); + glPushMatrix(); + glRotatef(Zrot, 0, 0, 1); + DrawObject(); + glPopMatrix(); + glPopMatrix(); + glDisable(GL_LINE_SMOOTH); + glDisable(GL_POLYGON_SMOOTH); + glDisable(GL_BLEND); + + glutSwapBuffers(); +} + + +static void +Reshape( int width, int height ) +{ + GLfloat ar = (float) width / (float) height; + glViewport( 0, 0, width, height ); + glMatrixMode( GL_PROJECTION ); + glLoadIdentity(); + glOrtho(-2.0*ar, 2.0*ar, -2.0, 2.0, -1.0, 1.0); + glMatrixMode( GL_MODELVIEW ); + glLoadIdentity(); +} + + +static void +Idle( void ) +{ + Zrot = 0.01 * glutGet(GLUT_ELAPSED_TIME); + glutPostRedisplay(); +} + + +static void +Key( unsigned char key, int x, int y ) +{ + const GLfloat step = 1.0; + (void) x; + (void) y; + switch (key) { + case 'a': + Anim = !Anim; + if (Anim) + glutIdleFunc(Idle); + else + glutIdleFunc(NULL); + break; + case 'z': + Zrot = (int) (Zrot - step); + break; + case 'Z': + Zrot = (int) (Zrot + step); + break; + case 27: + exit(0); + break; + } + glutPostRedisplay(); +} + + +static void +Init( void ) +{ + /* GLUT imposes the four samples/pixel requirement */ + int s; + glGetIntegerv(GL_SAMPLES_ARB, &s); + if (!glutExtensionSupported("GL_ARB_multisample") || s < 1) { + printf("Warning: multisample antialiasing not supported.\n"); + HaveMultisample = GL_FALSE; + } + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + printf("GL_SAMPLES_ARB = %d\n", s); + + glBlendFunc(GL_SRC_ALPHA, GL_ONE); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glBlendFunc(GL_SRC_ALPHA_SATURATE, GL_ONE); + + glGetIntegerv(GL_MULTISAMPLE_ARB, &s); + printf("GL_MULTISAMPLE_ARB = %d\n", s); +} + + +int +main( int argc, char *argv[] ) +{ + glutInit( &argc, argv ); + glutInitWindowPosition( 0, 0 ); + glutInitWindowSize( 600, 300 ); + glutInitDisplayMode( GLUT_RGB | GLUT_ALPHA | GLUT_DOUBLE | + GLUT_DEPTH | GLUT_MULTISAMPLE ); + glutCreateWindow(argv[0]); + glutReshapeFunc( Reshape ); + glutKeyboardFunc( Key ); + glutDisplayFunc( Display ); + if (Anim) + glutIdleFunc( Idle ); + Init(); + glutMainLoop(); + return 0; +} diff --git a/progs/tests/api_speed.c b/progs/tests/api_speed.c new file mode 100644 index 00000000000..aed65b35fe3 --- /dev/null +++ b/progs/tests/api_speed.c @@ -0,0 +1,146 @@ +/* + * (C) Copyright IBM Corporation 2002 + * 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 + * on the rights to use, copy, modify, merge, publish, distribute, sub + * license, 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 (including the next + * paragraph) 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 NON-INFRINGEMENT. IN NO EVENT SHALL + * VA LINUX SYSTEM, IBM AND/OR THEIR SUPPLIERS 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. + */ + +/** + * \file api_speed.c + * Simple test to measure the overhead of making GL calls. + * + * The main purpose of this test is to measure the difference in calling + * overhead of different dispatch methods. Since it uses asm/timex.h to + * access the Pentium's cycle counters, it will probably only compile on + * Linux (though most architectures have a get_cycles function in timex.h). + * That is why it isn't in the default Makefile. + * + * \author Ian Romanick + */ + +#include +#include +#define GL_GLEXT_PROTOTYPES +#include +#include +#include + +#define inline __inline__ +#include + +static float Width = 400; +static float Height = 400; +static unsigned count = 1000000; + + +static void Idle( void ) +{ + glutPostRedisplay(); +} + +#define DO_FUNC(f,p) \ + do { \ + t0 = get_cycles(); \ + for ( i = 0 ; i < count ; i++ ) { \ + f p ; \ + } \ + t1 = get_cycles(); \ + printf("%u calls to % 20s required %llu cycles.\n", count, # f, t1 - t0); \ + } while( 0 ) + +/** + * Main display function. This is the place to add more API calls. + */ +static void Display( void ) +{ + int i; + const float v[3] = { 1.0, 0.0, 0.0 }; + cycles_t t0; + cycles_t t1; + + glBegin(GL_TRIANGLE_STRIP); + + DO_FUNC( glColor3fv, (v) ); + DO_FUNC( glNormal3fv, (v) ); + DO_FUNC( glTexCoord2fv, (v) ); + DO_FUNC( glTexCoord3fv, (v) ); + DO_FUNC( glMultiTexCoord2fv, (GL_TEXTURE0, v) ); + DO_FUNC( glMultiTexCoord2f, (GL_TEXTURE0, 0.0, 0.0) ); + DO_FUNC( glFogCoordfvEXT, (v) ); + DO_FUNC( glFogCoordfEXT, (0.5) ); + + glEnd(); + + exit(0); +} + + +static void Reshape( int width, int height ) +{ + Width = width; + Height = 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 27: + exit(0); + break; + } + glutPostRedisplay(); +} + + +int main( int argc, char *argv[] ) +{ + glutInit( &argc, argv ); + glutInitWindowSize( (int) Width, (int) Height ); + glutInitWindowPosition( 0, 0 ); + + glutInitDisplayMode( GLUT_RGB ); + + glutCreateWindow( argv[0] ); + + if ( argc > 1 ) { + count = strtoul( argv[1], NULL, 0 ); + if ( count == 0 ) { + fprintf( stderr, "Usage: %s [iterations]\n", argv[0] ); + exit(1); + } + } + + glutReshapeFunc( Reshape ); + glutKeyboardFunc( Key ); + glutDisplayFunc( Display ); + glutIdleFunc( Idle ); + + glutMainLoop(); + return 0; +} diff --git a/progs/tests/api_speed.py b/progs/tests/api_speed.py new file mode 100755 index 00000000000..0ddaf5836c9 --- /dev/null +++ b/progs/tests/api_speed.py @@ -0,0 +1,143 @@ +#!/usr/bin/env python2 + +# (C) Copyright IBM Corporation 2004 +# 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 +# on the rights to use, copy, modify, merge, publish, distribute, sub +# license, 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 (including the next +# paragraph) 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 NON-INFRINGEMENT. IN NO EVENT SHALL +# IBM AND/OR ITS SUPPLIERS 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. +# +# Authors: +# Ian Romanick + + +# This script is used to run api_speed against several different libGL +# libraries and compare the results. See the show_usage function for more +# details on how to use it. + + +import re, os, sys, getopt + +class results: + def process_file(self, f): + self.cycles = {} + self.iterations = -1 + + for line in f.readlines(): + m = re.match("(\d+) calls to (.{20}) required (\d+) cycles.", line) + + if self.iterations != -1 and int(m.group(1)) != self.iterations: + raise + + # This could be done with lstrip, but the version of + # the Python library on my system doesn't have it. + # The installed version of Python is quite old. :( + + temp = m.group(2) + function_name = None + for i in range(len(temp)): + if temp[i] != ' ': + function_name = temp[i:] + break + + if function_name == None: + raise + + self.cycles[ function_name ] = int(m.group(3)) + self.iterations = int(m.group(1)) + + + def show_results(self): + for name in self.cycles: + print "%s -> %f" % (name, float(self.cycles[name]) / self.iterations) + + + def compare_results(self, other): + for name in self.cycles: + if other.cycles.has_key(name): + a = float(self.cycles[name]) / float(self.iterations) + b = float(other.cycles[name]) / float(other.iterations) + if abs( a ) < 0.000001: + print "a = %f, b = %f" % (a, b) + else: + p = (100.0 * b / a) - 100.0 + print "%- 20s %7.2f - %7.2f = % -6.2f (%+.1f%%)" % (name, a, b, a - b, p) + return + + +def make_execution_string(lib, iterations): + if lib == None: + return "./api_speed %u" % (iterations) + else: + return "LD_PRELOAD=%s ./api_speed %u" % (lib, iterations) + + +def show_usage(): + print """Usage: %s [-i iterations] {library ...} + +The full path to one or more libGL libraries (including the full name of the +library) can be included on the command-line. Each library will be tested, +and the results compared. The first library listed will be used as the +"base line" for all comparisons.""" % (sys.argv[0]) + sys.exit(1) + + +if __name__ == '__main__': + try: + (args, trail) = getopt.getopt(sys.argv[1:], "i:") + except Exception,e: + show_usage() + + iterations = 1000000 + try: + for (arg,val) in args: + if arg == "-i": + iterations = int(val) + except Exception,e: + show_usage() + + + # If no libraries were specifically named, just run the test against + # the default system libGL. + + if len(trail) == 0: + trail.append(None) + + + result_array = [] + names = [] + + for lib in trail: + s = make_execution_string( lib, iterations ) + r = results() + r.process_file( os.popen(s) ) + names.append(lib) + result_array.append(r) + + + # If the test was only run against one library, just show the results + # of the test run. Otherwise, compare each successive run against + # the first run. + + if len( result_array ) == 1: + result_array[0].show_results() + else: + for i in range(1, len( result_array )): + print "%s vs. %s" % (names[0], names[i]) + result_array[0].compare_results( result_array[i] ) + print "" diff --git a/progs/tests/arbfpspec.c b/progs/tests/arbfpspec.c new file mode 100644 index 00000000000..eac2a9100f5 --- /dev/null +++ b/progs/tests/arbfpspec.c @@ -0,0 +1,192 @@ +/* + * To demo that specular color gets lost someplace after vertex + * program completion and fragment program startup + */ + +#include +#include +#include +#include +#include +#define GL_GLEXT_PROTOTYPES +#include + +static float Xrot = 0.0, Yrot = 0.0, Zrot = 0.0; +static GLboolean Anim = GL_TRUE; + + +static void Idle( void ) +{ + Xrot += .3; + Yrot += .4; + Zrot += .2; + glutPostRedisplay(); +} + + +static void Display( void ) +{ + glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); + + glPushMatrix(); + glRotatef(Xrot, 1, 0, 0); + glRotatef(Yrot, 0, 1, 0); + glRotatef(Zrot, 0, 0, 1); + glutSolidTorus(0.75, 2.0, 10, 20); + glPopMatrix(); + + glutSwapBuffers(); +} + + +static void Reshape( int width, int height ) +{ + glViewport( 0, 0, width, height ); + glMatrixMode( GL_PROJECTION ); + glLoadIdentity(); + glFrustum( -2.0, 2.0, -2.0, 2.0, 5.0, 25.0 ); + glMatrixMode( GL_MODELVIEW ); + glLoadIdentity(); + glTranslatef( 0.0, 0.0, -12.0 ); +} + + +static void Key( unsigned char key, int x, int y ) +{ + (void) x; + (void) y; + switch (key) { + case ' ': + Xrot = Yrot = Zrot = 0; + break; + case 'a': + Anim = !Anim; + if (Anim) + glutIdleFunc(Idle); + else + glutIdleFunc(NULL); + break; + case 'z': + Zrot -= 5.0; + break; + case 'Z': + Zrot += 5.0; + 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 ) +{ + GLint errno; + GLuint prognum, fprognum; + + static const char prog[] = + "!!ARBvp1.0\n" + "DP4 result.position.x, state.matrix.mvp.row[0], vertex.position ;\n" + "DP4 result.position.y, state.matrix.mvp.row[1], vertex.position ;\n" + "DP4 result.position.z, state.matrix.mvp.row[2], vertex.position ;\n" + "DP4 result.position.w, state.matrix.mvp.row[3], vertex.position ;\n" + "MOV result.color.front.primary, {.5, .5, .5, 1};\n" + "MOV result.color.front.secondary, {1, 1, 1, 1};\n" + "END"; + + static const char fprog[] = + "!!ARBfp1.0\n" + "MOV result.color, fragment.color.secondary;\n" + "END"; + + if (!glutExtensionSupported("GL_ARB_vertex_program")) { + printf("Sorry, this program requires GL_ARB_vertex_program"); + exit(1); + } + + if (!glutExtensionSupported("GL_ARB_fragment_program")) { + printf("Sorry, this program requires GL_ARB_fragment_program"); + exit(1); + } + + glGenProgramsARB(1, &prognum); + glGenProgramsARB(1, &fprognum); + + glBindProgramARB(GL_VERTEX_PROGRAM_ARB, prognum); + glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(prog), (const GLubyte *) prog); + + assert(glIsProgramARB(prognum)); + errno = glGetError(); + printf("glGetError = %d\n", errno); + if (errno != GL_NO_ERROR) + { + GLint errorpos; + + glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errorpos); + printf("errorpos: %d\n", errorpos); + printf("%s\n", (char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + } + + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, fprognum); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(fprog), (const GLubyte *) fprog); + errno = glGetError(); + printf("glGetError = %d\n", errno); + if (errno != GL_NO_ERROR) + { + GLint errorpos; + + glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errorpos); + printf("errorpos: %d\n", errorpos); + printf("%s\n", (char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + } + + glEnable(GL_VERTEX_PROGRAM_ARB); + glEnable(GL_FRAGMENT_PROGRAM_ARB); + glEnable(GL_DEPTH_TEST); + glClearColor(0.3, 0.3, 0.3, 1); +} + + +int main( int argc, char *argv[] ) +{ + glutInit( &argc, argv ); + glutInitWindowPosition( 0, 0 ); + glutInitWindowSize( 250, 250 ); + glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ); + glutCreateWindow(argv[0]); + glutReshapeFunc( Reshape ); + glutKeyboardFunc( Key ); + glutSpecialFunc( SpecialKey ); + glutDisplayFunc( Display ); + if (Anim) + glutIdleFunc(Idle); + Init(); + glutMainLoop(); + return 0; +} diff --git a/progs/tests/arbfptest1.c b/progs/tests/arbfptest1.c new file mode 100644 index 00000000000..45d05125b26 --- /dev/null +++ b/progs/tests/arbfptest1.c @@ -0,0 +1,210 @@ +/* Test GL_ARB_fragment_program */ + +#include +#include +#include +#include +#include +#define GL_GLEXT_PROTOTYPES +#include + + + +static void Display( void ) +{ + glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); + + glPushMatrix(); + + glColor4f(0, 0.5, 0, 1); + glColor4f(0, 1, 0, 1); + glBegin(GL_POLYGON); + glVertex2f(-1, -1); + glVertex2f( 1, -1); + glVertex2f( 0, 1); + glEnd(); + + glPopMatrix(); + + glutSwapBuffers(); +} + + +static void Reshape( int width, int height ) +{ + glViewport( 0, 0, width, height ); + glMatrixMode( GL_PROJECTION ); + glLoadIdentity(); + glFrustum( -1.0, 1.0, -1.0, 1.0, 5.0, 25.0 ); + glMatrixMode( GL_MODELVIEW ); + glLoadIdentity(); + glTranslatef( 0.0, 0.0, -15.0 ); +} + + +static void Key( unsigned char key, int x, int y ) +{ + (void) x; + (void) y; + switch (key) { + case 27: + exit(0); + break; + } + glutPostRedisplay(); +} + +static void load_program(const char *prog, GLuint prognum) +{ + int a; + GLint errorpos, errno; + + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, prognum); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(prog), (const GLubyte *) prog); + + assert(glIsProgramARB(prognum)); + errno = glGetError(); + printf("glGetError = %d\n", errno); + if (errno != GL_NO_ERROR) + { + glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errorpos); + printf("errorpos: %d\n", errorpos); + printf("%s\n", (char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + + for (a=-10; a<10; a++) + { + if ((errorpos+a < 0) || (errorpos+a >= strlen(prog))) continue; + printf("%c", prog[errorpos+a]); + } + printf("\n"); + exit(1); + } +} + +static void Init( void ) +{ + static const char *prog0 = + "!!ARBfp1.0\n" + "TEMP R0, RC, HC, H0, H1, H2, H3, H30 ;\n" + "MUL result.color, R0, fragment.position; \n" + "ADD result.color, H3, fragment.texcoord; \n" + "ADD_SAT result.color, H3, fragment.texcoord; \n" + "MUL result.color.xy, R0.wzyx, fragment.position; \n" + "MUL result.color, H0, fragment.position; \n" + "MUL result.color, -H0, fragment.position; \n" + "MOV RC, H1; \n" + "MOV HC, H2; \n" + "END \n" + ; + /* masked updates, defines, declarations */ + static const char *prog1 = + "!!ARBfp1.0\n" + "PARAM foo = {1., 2., 3., 4.}; \n" + "PARAM foo2 = 5.; \n" + "PARAM foo3 = {5., 6., 7., 8.}; \n" + "PARAM bar = 3.; \n" + "TEMP R0, R1, RC, EQ, NE, bar2; \n" + "ALIAS bar3 = bar; \n" + "MOV result.color.xy, R0; \n" + "MOV result.color, R0; \n" + "MOV result.color.xyzw, R0; \n" + "MOV result.color.xy, R0; \n" + "MOV RC.x, R1.x; \n" + "KIL NE; \n" + "KIL EQ.xyxy; \n" + "END \n" + ; + + /* texture instructions */ + static const char *prog2 = + "!!ARBfp1.0\n" + "TEMP R0, R1, R2, R3;\n" + "TEX R0, fragment.texcoord, texture[1], 2D; \n" + "TEX R1, fragment.texcoord[1], texture[1], CUBE; \n" + "TEX R2, fragment.texcoord[2], texture[2], 3D; \n" + "TXP R3, fragment.texcoord[3], texture[3], RECT; \n" + "MUL result.color, R0, fragment.color; \n" + "END \n" + ; + + /* test negation, absolute value */ + static const char *prog3 = + "!!ARBfp1.0\n" + "TEMP R0, R1;\n" + "MOV R0, R1; \n" + "MOV R0, -R1; \n" + "MOV result.color, R0; \n" + "END \n" + ; + + /* literal constant sources */ + static const char *prog4 = + "!!ARBfp1.0\n" + "TEMP R0, R1;\n" + "PARAM Pi = 3.14159; \n" + "MOV R0, {1., -2., +3., 4.}; \n" + "MOV R0, 5.; \n" + "MOV R0, -5.; \n" + "MOV R0, 5.; \n" + "MOV R0, Pi; \n" + "MOV result.color, R0; \n" + "END \n" + ; + + /* change the fragment color in a simple way */ + static const char *prog10 = + "!!ARBfp1.0\n" + "PARAM blue = {0., 0., 1., 0.};\n" + "PARAM color = {1., 0., 0., 1.};\n" + "TEMP R0; \n" + "MOV R0, fragment.color; \n" + "#ADD result.color, R0, fragment.color; \n" + "#ADD result.color, blue, fragment.color; \n" + "#ADD result.color, {1., 0., 0., 0.}, fragment.color; \n" + "ADD result.color, color, fragment.color; \n" + "END \n" + ; + + GLuint progs[20]; + + glGenProgramsARB(20, progs); + assert(progs[0]); + assert(progs[1]); + assert(progs[0] != progs[1]); + + + printf("program 0:\n"); + load_program(prog0, progs[0]); + printf("program 1:\n"); + load_program(prog1, progs[1]); + printf("program 2:\n"); + load_program(prog2, progs[2]); + printf("program 3:\n"); + load_program(prog3, progs[3]); + printf("program 4:\n"); + load_program(prog4, progs[4]); + printf("program 10:\n"); + load_program(prog10, progs[5]); + + + glEnable(GL_FRAGMENT_PROGRAM_ARB); + glEnable(GL_ALPHA_TEST); + glAlphaFunc(GL_ALWAYS, 0.0); +} + + +int main( int argc, char *argv[] ) +{ + glutInit( &argc, argv ); + glutInitWindowPosition( 0, 0 ); + glutInitWindowSize( 250, 250 ); + glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ); + glutCreateWindow(argv[0]); + glutReshapeFunc( Reshape ); + glutKeyboardFunc( Key ); + glutDisplayFunc( Display ); + Init(); + glutMainLoop(); + return 0; +} diff --git a/progs/tests/arbfptexture.c b/progs/tests/arbfptexture.c new file mode 100644 index 00000000000..a854908c311 --- /dev/null +++ b/progs/tests/arbfptexture.c @@ -0,0 +1,153 @@ +/* GL_ARB_fragment_program texture test */ + +#include +#include +#include +#include +#include +#define GL_GLEXT_PROTOTYPES +#include + +#include "readtex.c" + + +#define TEXTURE_FILE "../images/girl.rgb" + +static GLfloat Xrot = 0.0, Yrot = 0.0, Zrot = 0.0; + + +static void Display( void ) +{ + glClear( GL_COLOR_BUFFER_BIT ); + + glPushMatrix(); + glRotatef(Xrot, 1.0, 0.0, 0.0); + glRotatef(Yrot, 0.0, 1.0, 0.0); + glRotatef(Zrot, 0.0, 0.0, 1.0); + + glBegin(GL_POLYGON); +#define Q 2 + glColor4f(1.0, 1.0, 1.0, 1); glTexCoord4f(0, 0, 0, Q); glVertex2f(-1, -1); + glColor4f(0.2, 0.2, 1.0, 1); glTexCoord4f(1, 0, 0, Q); glVertex2f( 1, -1); + glColor4f(0.2, 1.0, 0.2, 1); glTexCoord4f(1, 1, 0, Q); glVertex2f( 1, 1); + glColor4f(1.0, 0.2, 0.2, 1); glTexCoord4f(0, 1, 0, Q); glVertex2f(-1, 1); + glEnd(); + + glPopMatrix(); + + glutSwapBuffers(); +} + + +static void Reshape( int width, int height ) +{ + glViewport( 0, 0, width, height ); + glMatrixMode( GL_PROJECTION ); + glLoadIdentity(); + glFrustum( -1.0, 1.0, -1.0, 1.0, 5.0, 25.0 ); + glMatrixMode( GL_MODELVIEW ); + glLoadIdentity(); + glTranslatef( 0.0, 0.0, -8.0 ); +} + + +static void SpecialKey( int key, int x, int y ) +{ + float 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 Key( unsigned char key, int x, int y ) +{ + (void) x; + (void) y; + switch (key) { + case 27: + exit(0); + break; + } + glutPostRedisplay(); +} + + +static void Init( void ) +{ + static const char *modulate2D = + "!!ARBfp1.0\n" + "TEMP R0;\n" + "TEX R0, fragment.texcoord[0], texture[0], 2D; \n" + "MUL result.color, R0, fragment.color; \n" + "END" + ; + GLuint modulateProg; + GLuint Texture; + + if (!glutExtensionSupported("GL_ARB_fragment_program")) { + printf("Error: GL_ARB_fragment_program not supported!\n"); + exit(1); + } + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + /* Setup the fragment program */ + glGenProgramsARB(1, &modulateProg); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(modulate2D), (const GLubyte *)modulate2D); + + printf("glGetError = 0x%x\n", (int) glGetError()); + printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + assert(glIsProgramARB(modulateProg)); + + glEnable(GL_FRAGMENT_PROGRAM_ARB); + + /* Load texture */ + glGenTextures(1, &Texture); + glBindTexture(GL_TEXTURE_2D, Texture); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + if (!LoadRGBMipmaps(TEXTURE_FILE, GL_RGB)) { + printf("Error: couldn't load texture image file %s\n", TEXTURE_FILE); + exit(1); + } + /* XXX this enable shouldn't really be needed!!! */ + glEnable(GL_TEXTURE_2D); + + glClearColor(.3, .3, .3, 0); +} + + +int main( int argc, char *argv[] ) +{ + glutInit( &argc, argv ); + glutInitWindowPosition( 0, 0 ); + glutInitWindowSize( 250, 250 ); + glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ); + glutCreateWindow(argv[0]); + glutReshapeFunc( Reshape ); + glutKeyboardFunc( Key ); + glutSpecialFunc( SpecialKey ); + glutDisplayFunc( Display ); + Init(); + glutMainLoop(); + return 0; +} diff --git a/progs/tests/arbfptrig.c b/progs/tests/arbfptrig.c new file mode 100644 index 00000000000..26b68c6b412 --- /dev/null +++ b/progs/tests/arbfptrig.c @@ -0,0 +1,156 @@ +/* GL_ARB_fragment_program texture test */ + +#include +#include +#include +#include +#include +#define GL_GLEXT_PROTOTYPES +#include + +#include "readtex.c" + + +#define TEXTURE_FILE "../images/girl.rgb" + +static GLfloat Xrot = 0.0, Yrot = 0.0, Zrot = 0.0; + +#define PI 3.141592 + +static void Display( void ) +{ + glClear( GL_COLOR_BUFFER_BIT ); + + glPushMatrix(); + glRotatef(Xrot, 1.0, 0.0, 0.0); + glRotatef(Yrot, 0.0, 1.0, 0.0); + glRotatef(Zrot, 0.0, 0.0, 1.0); + + glBegin(GL_POLYGON); + glTexCoord2f(-PI, 0); glVertex2f(-1, -1); + glTexCoord2f(PI, 0); glVertex2f( 1, -1); + glTexCoord2f(PI, 1); glVertex2f( 1, 1); + glTexCoord2f(-PI, 1); glVertex2f(-1, 1); + glEnd(); + + glPopMatrix(); + + glutSwapBuffers(); +} + + +static void Reshape( int width, int height ) +{ + glViewport( 0, 0, width, height ); + glMatrixMode( GL_PROJECTION ); + glLoadIdentity(); + glFrustum( -1.0, 1.0, -1.0, 1.0, 5.0, 25.0 ); + glMatrixMode( GL_MODELVIEW ); + glLoadIdentity(); + glTranslatef( 0.0, 0.0, -8.0 ); +} + + +static void SpecialKey( int key, int x, int y ) +{ + float 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 Key( unsigned char key, int x, int y ) +{ + (void) x; + (void) y; + switch (key) { + case 27: + exit(0); + break; + } + glutPostRedisplay(); +} + + +static void Init( void ) +{ + static const char *modulate2D = + "!!ARBfp1.0\n" + "TEMP R0;\n" + "MOV R0, {0,0,0,1};\n" + "SCS R0, fragment.texcoord[0].x; \n" + "ADD R0, R0, {1.0}.x;\n" + "MUL R0, R0, {0.5}.x;\n" + "MOV result.color, R0; \n" + "END" + ; + GLuint modulateProg; + GLuint Texture; + + if (!glutExtensionSupported("GL_ARB_fragment_program")) { + printf("Error: GL_ARB_fragment_program not supported!\n"); + exit(1); + } + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + /* Setup the fragment program */ + glGenProgramsARB(1, &modulateProg); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(modulate2D), (const GLubyte *)modulate2D); + + printf("glGetError = 0x%x\n", (int) glGetError()); + printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + assert(glIsProgramARB(modulateProg)); + + glEnable(GL_FRAGMENT_PROGRAM_ARB); + + /* Load texture */ + glGenTextures(1, &Texture); + glBindTexture(GL_TEXTURE_2D, Texture); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + if (!LoadRGBMipmaps(TEXTURE_FILE, GL_RGB)) { + printf("Error: couldn't load texture image file %s\n", TEXTURE_FILE); + exit(1); + } + /* XXX this enable shouldn't really be needed!!! */ + glEnable(GL_TEXTURE_2D); + + glClearColor(.3, .3, .3, 0); +} + + +int main( int argc, char *argv[] ) +{ + glutInit( &argc, argv ); + glutInitWindowPosition( 0, 0 ); + glutInitWindowSize( 250, 250 ); + glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ); + glutCreateWindow(argv[0]); + glutReshapeFunc( Reshape ); + glutKeyboardFunc( Key ); + glutSpecialFunc( SpecialKey ); + glutDisplayFunc( Display ); + Init(); + glutMainLoop(); + return 0; +} diff --git a/progs/tests/arbnpot.c b/progs/tests/arbnpot.c new file mode 100644 index 00000000000..8107717e271 --- /dev/null +++ b/progs/tests/arbnpot.c @@ -0,0 +1,174 @@ +/* + * Test NPOT textures with the GL_ARB_texture_non_power_of_two extension. + * Brian Paul + * 2 July 2003 + */ + +#include +#include +#include +#include +#include +#include "../util/readtex.c" + +#define IMAGE_FILE "../images/girl.rgb" + +static GLfloat Zrot = 0; + +static void Display( void ) +{ + glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); + + glPushMatrix(); + glRotatef(Zrot, 0, 0, 1); + glBegin(GL_POLYGON); + glTexCoord2f(0, 0); + glVertex2f(-1, -1); + glTexCoord2f(1, 0); + glVertex2f(1, -1); + glTexCoord2f(1, 1); + glVertex2f(1, 1); + glTexCoord2f(0, 1); + glVertex2f(-1, 1); + glEnd(); + glPopMatrix(); + + glutSwapBuffers(); +} + + +static void Reshape( int width, int height ) +{ + glViewport( 0, 0, width, height ); + glMatrixMode( GL_PROJECTION ); + glLoadIdentity(); + glFrustum( -1.0, 1.0, -1.0, 1.0, 5.0, 25.0 ); + glMatrixMode( GL_MODELVIEW ); + glLoadIdentity(); + glTranslatef( 0.0, 0.0, -7.0 ); +} + + +static void Key( unsigned char key, int x, int y ) +{ + (void) x; + (void) y; + switch (key) { + case 'z': + Zrot -= 1.0; + break; + case 'Z': + Zrot += 1.0; + break; + case 27: + exit(0); + break; + } + glutPostRedisplay(); +} + + +static void Init( void ) +{ + GLubyte *image; + int imgWidth, imgHeight, minDim, w; + GLenum imgFormat; + + if (!glutExtensionSupported("GL_ARB_texture_non_power_of_two")) { + printf("Sorry, this program requires GL_ARB_texture_non_power_of_two\n"); + exit(1); + } + +#if 1 + image = LoadRGBImage( IMAGE_FILE, &imgWidth, &imgHeight, &imgFormat ); + if (!image) { + printf("Couldn't read %s\n", IMAGE_FILE); + exit(0); + } +#else + int i, j; + imgFormat = GL_RGB; + imgWidth = 3; + imgHeight = 3; + image = malloc(imgWidth * imgHeight * 3); + for (i = 0; i < imgHeight; i++) { + for (j = 0; j < imgWidth; j++) { + int k = (i * imgWidth + j) * 3; + if ((i + j) & 1) { + image[k+0] = 255; + image[k+1] = 0; + image[k+2] = 0; + } + else { + image[k+0] = 0; + image[k+1] = 255; + image[k+2] = 0; + } + } + } +#endif + + printf("Read %d x %d\n", imgWidth, imgHeight); + + minDim = imgWidth < imgHeight ? imgWidth : imgHeight; + + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + glTexImage1D(GL_TEXTURE_1D, 0, GL_RGB, imgWidth, 0, + imgFormat, GL_UNSIGNED_BYTE, image); + assert(glGetError() == GL_NO_ERROR); + + glTexImage1D(GL_PROXY_TEXTURE_1D, 0, GL_RGB, imgWidth, 0, + imgFormat, GL_UNSIGNED_BYTE, image); + glGetTexLevelParameteriv(GL_PROXY_TEXTURE_1D, 0, GL_TEXTURE_WIDTH, &w); + assert(w == imgWidth); + + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, imgWidth, imgHeight, 0, + imgFormat, GL_UNSIGNED_BYTE, image); + assert(glGetError() == GL_NO_ERROR); + + glTexImage2D(GL_PROXY_TEXTURE_2D, 0, GL_RGB, imgWidth, imgHeight, 0, + imgFormat, GL_UNSIGNED_BYTE, image); + glGetTexLevelParameteriv(GL_PROXY_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &w); + assert(w == imgWidth); + + glTexImage3D(GL_TEXTURE_3D, 0, GL_RGB, imgWidth, imgHeight, 1, 0, + imgFormat, GL_UNSIGNED_BYTE, image); + assert(glGetError() == GL_NO_ERROR); + + glTexImage3D(GL_PROXY_TEXTURE_3D, 0, GL_RGB, imgWidth, imgHeight, 1, 0, + imgFormat, GL_UNSIGNED_BYTE, image); + glGetTexLevelParameteriv(GL_PROXY_TEXTURE_3D, 0, GL_TEXTURE_WIDTH, &w); + assert(w == imgWidth); + + glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, + minDim, minDim, 0, + imgFormat, GL_UNSIGNED_BYTE, image); + assert(glGetError() == GL_NO_ERROR); + + glTexImage2D(GL_PROXY_TEXTURE_CUBE_MAP, 0, GL_RGB, + minDim, minDim, 0, + imgFormat, GL_UNSIGNED_BYTE, image); + glGetTexLevelParameteriv(GL_PROXY_TEXTURE_CUBE_MAP, 0, GL_TEXTURE_WIDTH, &w); + assert(w == minDim); + + + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glEnable(GL_TEXTURE_2D); +} + + +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 ); + glutDisplayFunc( Display ); + Init(); + glutMainLoop(); + return 0; +} diff --git a/progs/tests/arbvptest1.c b/progs/tests/arbvptest1.c new file mode 100644 index 00000000000..0ebd3987f58 --- /dev/null +++ b/progs/tests/arbvptest1.c @@ -0,0 +1,164 @@ +/* Test glGenProgramsARB(), glIsProgramARB(), glLoadProgramARB() */ + +#include +#include +#include +#include +#include +#define GL_GLEXT_PROTOTYPES +#include + +static void Display( void ) +{ + glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); + + glPushMatrix(); + + glBegin(GL_POLYGON); + glVertexAttrib2fARB(0, -1, -1); + glVertexAttrib2fARB(0, 1, -1); + glVertexAttrib2fARB(0, 0, 1); + glEnd(); + + glPopMatrix(); + + glutSwapBuffers(); +} + + +static void Reshape( int width, int height ) +{ + glViewport( 0, 0, width, height ); + glMatrixMode( GL_PROJECTION ); + glLoadIdentity(); + glFrustum( -1.0, 1.0, -1.0, 1.0, 5.0, 25.0 ); + glMatrixMode( GL_MODELVIEW ); + glLoadIdentity(); + glTranslatef( 0.0, 0.0, -15.0 ); +} + + +static void Key( unsigned char key, int x, int y ) +{ + (void) x; + (void) y; + switch (key) { + case 27: + exit(0); + break; + } + glutPostRedisplay(); +} + +static void load_program(const char *prog, GLuint prognum) +{ + int a; + GLint errorpos, errno; + + glBindProgramARB(GL_VERTEX_PROGRAM_ARB, prognum); + glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(prog), (const GLubyte *) prog); + + assert(glIsProgramARB(prognum)); + errno = glGetError(); + printf("glGetError = %d\n", errno); + if (errno != GL_NO_ERROR) + { + glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errorpos); + printf("errorpos: %d\n", errorpos); + printf("%s\n", (char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + + for (a=-10; a<10; a++) + { + if ((errorpos+a < 0) || (errorpos+a >= strlen(prog))) continue; + printf("%c", prog[errorpos+a]); + } + printf("\n"); + exit(1); + } +} + +static void Init( void ) +{ + GLuint prognum[4]; + + static const char *prog1 = + "!!ARBvp1.0\n" + "TEMP R0;\n" + "MUL result.color.primary.xyz, R0, program.local[35]; \n" + "END\n"; + static const char *prog2 = + "!!ARBvp1.0\n" + "#\n" + "# c[0-3] = modelview projection (composite) matrix\n" + "# c[32] = normalized light direction in object-space\n" + "# c[35] = yellow diffuse material, (1.0, 1.0, 0.0, 1.0)\n" + "# c[64].x = 0.0\n" + "# c[64].z = 0.125, a scaling factor\n" + "TEMP R0, R1;\n" + "#\n" + "# outputs diffuse illumination for color and perturbed position\n" + "#\n" + "DP3 R0, program.local[32], vertex.normal; # light direction DOT normal\n" + "MUL result.color.primary.xyz, R0, program.local[35]; \n" + "MAX R0, program.local[64].x, R0; \n" + "MUL R0, R0, vertex.normal; \n" + "MUL R0, R0, program.local[64].z; \n" + "ADD R1, vertex.position, -R0; # perturb object space position\n" + "DP4 result.position.x, state.matrix.mvp.row[3], R1; \n" + "DP4 result.position.y, state.matrix.mvp.row[1], R1; \n" + "DP4 result.position.z, state.matrix.mvp.row[2], R1; \n" + "DP4 result.position.w, state.matrix.mvp.row[3], R1; \n" + "END\n"; + static const char *prog3 = + "!!ARBvp1.0\n" + "TEMP R0, R1, R2, R3;\n" + "DP4 result.position.x, state.matrix.mvp.row[0], vertex.position;\n" + "DP4 result.position.y, state.matrix.mvp.row[1], vertex.position;\n" + "DP4 result.position.z, state.matrix.mvp.row[2], vertex.position;\n" + "DP4 result.position.w, state.matrix.mvp.row[3], vertex.position;\n" + "DP3 R0.x, state.matrix.modelview.inverse.row[0], vertex.normal;\n" + "DP3 R0.y, state.matrix.modelview.inverse.row[1], vertex.normal;\n" + "DP3 R0.z, state.matrix.modelview.inverse.row[2], vertex.normal;\n" + "DP3 R1.x, program.env[32], R0; # R1.x = Lpos DOT n'\n" + "DP3 R1.y, program.env[33], R0; # R1.y = hHat DOT n'\n" + "MOV R1.w, program.local[38].x; # R1.w = specular power\n" + "LIT R2, R1; # Compute lighting values\n" + "MAD R3, program.env[35].x, R2.y, program.env[35].y; # diffuse + emissive\n" + "MAD result.color.primary.xyz, program.env[36], R2.z, R3; # + specular\n" + "END\n"; + static const char *prog4 = + "!!ARBvp1.0\n" + "TEMP R2, R3;\n" + "PARAM foo = {0., 0., 0., 1.};\n" + "PARAM blah[] = { program.local[0..8] };\n" + "ADDRESS A0;\n" + "ARL A0.x, foo.x;\n" + "DP4 R2, R3, blah[A0.x].x;\n" + "DP4 R2, R3, blah[A0.x + 5];\n" + "DP4 result.position, R3, blah[A0.x - 4];\n" + "END\n"; + + glGenProgramsARB(4, prognum); + + load_program(prog1, prognum[0]); + load_program(prog2, prognum[1]); + load_program(prog3, prognum[2]); + load_program(prog4, prognum[3]); +} + + +int main( int argc, char *argv[] ) +{ + glutInit( &argc, argv ); + glutInitWindowPosition( 0, 0 ); + glutInitWindowSize( 250, 250 ); + glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ); + glutCreateWindow(argv[0]); + glutReshapeFunc( Reshape ); + glutKeyboardFunc( Key ); + glutDisplayFunc( Display ); + Init(); + glutMainLoop(); + return 0; +} diff --git a/progs/tests/arbvptest3.c b/progs/tests/arbvptest3.c new file mode 100644 index 00000000000..6437062900e --- /dev/null +++ b/progs/tests/arbvptest3.c @@ -0,0 +1,127 @@ + +#include +#include +#include +#include +#include +#define GL_GLEXT_PROTOTYPES +#include + +static float Zrot = 0.0; + + +static void Display( void ) +{ + glClearColor(0.3, 0.3, 0.3, 1); + glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); + + glEnable(GL_VERTEX_PROGRAM_ARB); + + glLoadIdentity(); + glRotatef(Zrot, 0, 0, 1); + + glPushMatrix(); + + glVertexAttrib3fARB(3, 1, 0.5, 0.25); + glBegin(GL_TRIANGLES); +#if 1 + glVertexAttrib3fARB(3, 1.0, 0.0, 0.0); + glVertexAttrib2fARB(0, -0.5, -0.5); + glVertexAttrib3fARB(3, 0.0, 1.0, 0.0); + glVertexAttrib2fARB(0, 0.5, -0.5); + glVertexAttrib3fARB(3, 0.0, 0.0, 1.0); + glVertexAttrib2fARB(0, 0, 0.5); +#else + glVertex2f( -1, -1); + glVertex2f( 1, -1); + glVertex2f( 0, 1); +#endif + glEnd(); + + glPopMatrix(); + + glutSwapBuffers(); +} + + +static void Reshape( int width, int height ) +{ + glViewport( 0, 0, width, height ); + glMatrixMode( GL_PROJECTION ); + glLoadIdentity(); + /* glFrustum( -2.0, 2.0, -2.0, 2.0, 5.0, 25.0 );*/ + glOrtho(-2.0, 2.0, -2.0, 2.0, -2.0, 2.0 ); + glMatrixMode( GL_MODELVIEW ); + glLoadIdentity(); + /*glTranslatef( 0.0, 0.0, -15.0 );*/ +} + + +static void Key( unsigned char key, int x, int y ) +{ + (void) x; + (void) y; + switch (key) { + case 'z': + Zrot -= 5.0; + break; + case 'Z': + Zrot += 5.0; + break; + case 27: + exit(0); + break; + } + glutPostRedisplay(); +} + + +static void Init( void ) +{ + GLint errno; + GLuint prognum; + + static const char *prog1 = + "!!ARBvp1.0\n" + "MOV result.color, vertex.attrib[3];\n" + + "DP4 result.position.x, vertex.position, state.matrix.modelview.row[0];\n" + "DP4 result.position.y, vertex.position, state.matrix.modelview.row[1];\n" + "DP4 result.position.z, vertex.position, state.matrix.modelview.row[2];\n" + "DP4 result.position.w, vertex.position, state.matrix.modelview.row[3];\n" + "END\n"; + + glGenProgramsARB(1, &prognum); + + glBindProgramARB(GL_VERTEX_PROGRAM_ARB, prognum); + glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(prog1), (const GLubyte *) prog1); + + assert(glIsProgramARB(prognum)); + errno = glGetError(); + printf("glGetError = %d\n", errno); + if (errno != GL_NO_ERROR) + { + GLint errorpos; + + glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errorpos); + printf("errorpos: %d\n", errorpos); + printf("%s\n", (char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + } +} + + +int main( int argc, char *argv[] ) +{ + glutInit( &argc, argv ); + glutInitWindowPosition( 0, 0 ); + glutInitWindowSize( 250, 250 ); + glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ); + glutCreateWindow(argv[0]); + glutReshapeFunc( Reshape ); + glutKeyboardFunc( Key ); + glutDisplayFunc( Display ); + Init(); + glutMainLoop(); + return 0; +} diff --git a/progs/tests/arbvptorus.c b/progs/tests/arbvptorus.c new file mode 100644 index 00000000000..c1e2d0b76a8 --- /dev/null +++ b/progs/tests/arbvptorus.c @@ -0,0 +1,191 @@ +/* + * A lit, rotating torus via vertex program + */ + +#include +#include +#include +#include +#include +#define GL_GLEXT_PROTOTYPES +#include + +static float Xrot = 0.0, Yrot = 0.0, Zrot = 0.0; +static GLboolean Anim = GL_TRUE; + + +static void Idle( void ) +{ + Xrot += .3; + Yrot += .4; + Zrot += .2; + glutPostRedisplay(); +} + + +static void Display( void ) +{ + glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); + + glPushMatrix(); + glRotatef(Xrot, 1, 0, 0); + glRotatef(Yrot, 0, 1, 0); + glRotatef(Zrot, 0, 0, 1); + glutSolidTorus(0.75, 2.0, 10, 20); + glPopMatrix(); + + glutSwapBuffers(); +} + + +static void Reshape( int width, int height ) +{ + glViewport( 0, 0, width, height ); + glMatrixMode( GL_PROJECTION ); + glLoadIdentity(); + glFrustum( -2.0, 2.0, -2.0, 2.0, 5.0, 25.0 ); + glMatrixMode( GL_MODELVIEW ); + glLoadIdentity(); + glTranslatef( 0.0, 0.0, -12.0 ); +} + + +static void Key( unsigned char key, int x, int y ) +{ + (void) x; + (void) y; + switch (key) { + case ' ': + Xrot = Yrot = Zrot = 0; + break; + case 'a': + Anim = !Anim; + if (Anim) + glutIdleFunc(Idle); + else + glutIdleFunc(NULL); + break; + case 'z': + Zrot -= 5.0; + break; + case 'Z': + Zrot += 5.0; + 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 ) +{ + GLint errno; + GLuint prognum; + + /* borrowed from an nvidia demo: + * c[0..3] = modelview matrix + * c[4..7] = invtrans modelview matrix + * c[32] = light pos + * c[35] = diffuse color + */ + static const char prog[] = + "!!ARBvp1.0\n" + "TEMP R0, R1; \n" + "#Simple transform and diffuse lighting\n" + "# object x MVP -> clip\n" + "DP4 result.position.x, state.matrix.mvp.row[0], vertex.position ;\n" + "DP4 result.position.y, state.matrix.mvp.row[1], vertex.position ;\n" + "DP4 result.position.z, state.matrix.mvp.row[2], vertex.position ;\n" + "DP4 result.position.w, state.matrix.mvp.row[3], vertex.position ;\n" + + "# normal x MV-1T -> lighting normal\n" + "DP3 R1.x, state.matrix.modelview.invtrans.row[0], vertex.normal ;\n" + "DP3 R1.y, state.matrix.modelview.invtrans.row[1], vertex.normal;\n" + "DP3 R1.z, state.matrix.modelview.invtrans.row[2], vertex.normal;\n" + + "DP3 R0, program.local[32], R1; # L.N\n" +#if 0 + "MUL result.color.xyz, R0, program.local[35] ; # col = L.N * diffuse\n" +#else + "MUL result.color.primary.xyz, R0, program.local[35] ; # col = L.N * diffuse\n" +#endif + "MOV result.texcoord, vertex.texcoord;\n" + "END"; + + if (!glutExtensionSupported("GL_ARB_vertex_program")) { + printf("Sorry, this program requires GL_ARB_vertex_program"); + exit(1); + } + + + glGenProgramsARB(1, &prognum); + + glBindProgramARB(GL_VERTEX_PROGRAM_ARB, prognum); + glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(prog), (const GLubyte *) prog); + + assert(glIsProgramARB(prognum)); + errno = glGetError(); + printf("glGetError = %d\n", errno); + if (errno != GL_NO_ERROR) + { + GLint errorpos; + + glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errorpos); + printf("errorpos: %d\n", errorpos); + printf("%s\n", (char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + } + + /* Light position */ + glProgramLocalParameter4fARB(GL_VERTEX_PROGRAM_ARB, 32, 2, 2, 4, 1); + /* Diffuse material color */ + glProgramLocalParameter4fARB(GL_VERTEX_PROGRAM_ARB, 35, 0.25, 0, 0.25, 1); + + glEnable(GL_VERTEX_PROGRAM_ARB); + glEnable(GL_DEPTH_TEST); + glClearColor(0.3, 0.3, 0.3, 1); +} + + +int main( int argc, char *argv[] ) +{ + glutInit( &argc, argv ); + glutInitWindowPosition( 0, 0 ); + glutInitWindowSize( 250, 250 ); + glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ); + glutCreateWindow(argv[0]); + glutReshapeFunc( Reshape ); + glutKeyboardFunc( Key ); + glutSpecialFunc( SpecialKey ); + glutDisplayFunc( Display ); + if (Anim) + glutIdleFunc(Idle); + Init(); + glutMainLoop(); + return 0; +} diff --git a/progs/tests/arbvpwarpmesh.c b/progs/tests/arbvpwarpmesh.c new file mode 100644 index 00000000000..3dfe94f7596 --- /dev/null +++ b/progs/tests/arbvpwarpmesh.c @@ -0,0 +1,246 @@ +/* + * Warp a triangle mesh with a vertex program. + */ + +#include +#include +#include +#include +#include +#define GL_GLEXT_PROTOTYPES +#include + +static float Xrot = -60.0, Yrot = 0.0, Zrot = 0.0; +static GLboolean Anim = GL_TRUE; +static GLfloat Phi = 0.0; + + +static void Idle( void ) +{ + Phi += 0.01; + glutPostRedisplay(); +} + + +static void DrawMesh( int rows, int cols ) +{ + static const GLfloat colorA[3] = { 0, 1, 0 }; + static const GLfloat colorB[3] = { 0, 0, 1 }; + const float dx = 2.0 / (cols - 1); + const float dy = 2.0 / (rows - 1); + float x, y; + int i, j; + +#if 1 +#define COLOR3FV(c) glVertexAttrib3fvARB(3, c) +#define VERTEX2F(x, y) glVertexAttrib2fARB(0, x, y) +#else +#define COLOR3FV(c) glColor3fv(c) +#define VERTEX2F(x, y) glVertex2f(x, y) +#endif + + y = -1.0; + for (i = 0; i < rows - 1; i++) { + glBegin(GL_QUAD_STRIP); + x = -1.0; + for (j = 0; j < cols; j++) { + if ((i + j) & 1) + COLOR3FV(colorA); + else + COLOR3FV(colorB); + VERTEX2F(x, y); + VERTEX2F(x, y + dy); + x += dx; + } + glEnd(); + y += dy; + } +} + + +static void Display( void ) +{ + glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); + + glPushMatrix(); + glRotatef(Xrot, 1, 0, 0); + glRotatef(Yrot, 0, 1, 0); + glRotatef(Zrot, 0, 0, 1); + + /* Position the gravity source */ + { + GLfloat x, y, z, r = 0.5; + x = r * cos(Phi); + y = r * sin(Phi); + z = 1.0; + glProgramLocalParameter4fARB(GL_VERTEX_PROGRAM_ARB, 30, x, y, z, 1); + glDisable(GL_VERTEX_PROGRAM_ARB); + glBegin(GL_POINTS); + glColor3f(1,1,1); + glVertex3f(x, y, z); + glEnd(); + } + + glEnable(GL_VERTEX_PROGRAM_ARB); + DrawMesh(8, 8); + glPopMatrix(); + + glutSwapBuffers(); +} + + +static void Reshape( int width, int height ) +{ + float ar = (float) width / (float) height; + glViewport( 0, 0, width, height ); + glMatrixMode( GL_PROJECTION ); + glLoadIdentity(); + glFrustum( -1.0 * ar, 1.0 * ar, -1.0, 1.0, 5.0, 25.0 ); + glMatrixMode( GL_MODELVIEW ); + glLoadIdentity(); + glTranslatef( 0.0, 0.0, -12.0 ); + glScalef(2, 2, 2); +} + + +static void Key( unsigned char key, int x, int y ) +{ + (void) x; + (void) y; + switch (key) { + case 'a': + Anim = !Anim; + if (Anim) + glutIdleFunc(Idle); + else + glutIdleFunc(NULL); + break; + case 'p': + Phi += 0.2; + break; + case 'z': + Zrot -= 5.0; + break; + case 'Z': + Zrot += 5.0; + 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 ) +{ + GLuint prognum; + GLint errno; + + /* + * c[0..3] = modelview matrix + * c[4..7] = inverse modelview matrix + * c[30] = gravity source location + * c[31] = gravity source strength + * c[32] = light pos + * c[35] = diffuse color + */ + static const char prog[] = + "!!ARBvp1.0\n" + "TEMP R1, R2, R3; " + + "# Compute distance from vertex to gravity source\n" + "ADD R1, program.local[30], -vertex.position; # vector from vertex to gravity\n" + "DP3 R2, R1, R1; # dot product\n" + "RSQ R2, R2.x; # square root = distance\n" + "MUL R2, R2, program.local[31].xxxx; # scale by the gravity factor\n" + + "# Displace vertex by gravity factor along R1 vector\n" + "MAD R3, R1, R2, vertex.position;\n" + + "# Continue with typical modelview/projection\n" + "DP4 result.position.x, state.matrix.mvp.row[0], R3 ; # object x MVP -> clip\n" + "DP4 result.position.y, state.matrix.mvp.row[1], R3 ;\n" + "DP4 result.position.z, state.matrix.mvp.row[2], R3 ;\n" + "DP4 result.position.w, state.matrix.mvp.row[3], R3 ;\n" + + "MOV result.color, vertex.attrib[3];\n # copy input color to output color\n" + + "END"; + + if (!glutExtensionSupported("GL_ARB_vertex_program")) { + printf("Sorry, this program requires GL_ARB_vertex_program\n"); + exit(1); + } + + glGenProgramsARB(1, &prognum); + glBindProgramARB(GL_VERTEX_PROGRAM_ARB, prognum); + glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(prog), (const GLubyte *)prog); + errno = glGetError(); + printf("glGetError = %d\n", errno); + + if (errno != GL_NO_ERROR) + { + GLint errorpos; + + glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errorpos); + printf("errorpos: %d\n", errorpos); + printf("%s\n", glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + } + + /* Light position */ + glProgramLocalParameter4fARB(GL_VERTEX_PROGRAM_ARB, 32, 2, 2, 4, 1); + /* Diffuse material color */ + glProgramLocalParameter4fARB(GL_VERTEX_PROGRAM_ARB, 35, 0.25, 0, 0.25, 1); + + /* Gravity strength */ + glProgramLocalParameter4fARB(GL_VERTEX_PROGRAM_ARB, 31, .5, 0, 0, 0); + + glEnable(GL_DEPTH_TEST); + glClearColor(0.3, 0.3, 0.3, 1); + glShadeModel(GL_FLAT); + glPointSize(3); +} + + +int main( int argc, char *argv[] ) +{ + glutInit( &argc, argv ); + glutInitWindowPosition( 0, 0 ); + glutInitWindowSize( 250, 250 ); + glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ); + glutCreateWindow(argv[0]); + glutReshapeFunc( Reshape ); + glutKeyboardFunc( Key ); + glutSpecialFunc( SpecialKey ); + glutDisplayFunc( Display ); + if (Anim) + glutIdleFunc(Idle); + Init(); + glutMainLoop(); + return 0; +} diff --git a/progs/tests/auxbuffer.c b/progs/tests/auxbuffer.c new file mode 100644 index 00000000000..70f0b73910d --- /dev/null +++ b/progs/tests/auxbuffer.c @@ -0,0 +1,499 @@ +/* + * Test AUX buffer rendering + * Use GLX since GLUT doesn't support AUX buffers + */ + + +/* + * Copyright (C) 1999-2001 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 port of the infamous "gears" demo to straight GLX (i.e. no GLUT) + * Port by Brian Paul 23 March 2001 + * + * Command line options: + * -info print GL implementation information + * + */ + + +#include +#include +#include +#include +#include +#include +#include +#include + + +static int +current_time(void) +{ + return 0; +} + + + + +#ifndef M_PI +#define M_PI 3.14159265 +#endif + +static int WinWidth = 300, WinHeight = 300; +static GLfloat view_rotx = 20.0, view_roty = 30.0, view_rotz = 0.0; +static GLint gear1, gear2, gear3; +static GLfloat angle = 0.0; + + +/* + * + * Draw a gear wheel. You'll probably want to call this function when + * building a display list since we do a lot of trig here. + * + * Input: inner_radius - radius of hole at center + * outer_radius - radius at center of teeth + * width - width of gear + * teeth - number of teeth + * tooth_depth - depth of tooth + */ +static void +gear(GLfloat inner_radius, GLfloat outer_radius, GLfloat width, + GLint teeth, GLfloat tooth_depth) +{ + GLint i; + GLfloat r0, r1, r2; + GLfloat angle, da; + GLfloat u, v, len; + + r0 = inner_radius; + r1 = outer_radius - tooth_depth / 2.0; + r2 = outer_radius + tooth_depth / 2.0; + + da = 2.0 * M_PI / teeth / 4.0; + + glShadeModel(GL_FLAT); + + glNormal3f(0.0, 0.0, 1.0); + + /* draw front face */ + glBegin(GL_QUAD_STRIP); + for (i = 0; i <= teeth; i++) { + angle = i * 2.0 * M_PI / teeth; + glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5); + glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5); + if (i < teeth) { + glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5); + glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), + width * 0.5); + } + } + glEnd(); + + /* draw front sides of teeth */ + glBegin(GL_QUADS); + da = 2.0 * M_PI / teeth / 4.0; + for (i = 0; i < teeth; i++) { + angle = i * 2.0 * M_PI / teeth; + + glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5); + glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), width * 0.5); + glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), + width * 0.5); + glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), + width * 0.5); + } + glEnd(); + + glNormal3f(0.0, 0.0, -1.0); + + /* draw back face */ + glBegin(GL_QUAD_STRIP); + for (i = 0; i <= teeth; i++) { + angle = i * 2.0 * M_PI / teeth; + glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5); + glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5); + if (i < teeth) { + glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), + -width * 0.5); + glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5); + } + } + glEnd(); + + /* draw back sides of teeth */ + glBegin(GL_QUADS); + da = 2.0 * M_PI / teeth / 4.0; + for (i = 0; i < teeth; i++) { + angle = i * 2.0 * M_PI / teeth; + + glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), + -width * 0.5); + glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), + -width * 0.5); + glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), -width * 0.5); + glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5); + } + glEnd(); + + /* draw outward faces of teeth */ + glBegin(GL_QUAD_STRIP); + for (i = 0; i < teeth; i++) { + angle = i * 2.0 * M_PI / teeth; + + glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5); + glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5); + u = r2 * cos(angle + da) - r1 * cos(angle); + v = r2 * sin(angle + da) - r1 * sin(angle); + len = sqrt(u * u + v * v); + u /= len; + v /= len; + glNormal3f(v, -u, 0.0); + glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), width * 0.5); + glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), -width * 0.5); + glNormal3f(cos(angle), sin(angle), 0.0); + glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), + width * 0.5); + glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), + -width * 0.5); + u = r1 * cos(angle + 3 * da) - r2 * cos(angle + 2 * da); + v = r1 * sin(angle + 3 * da) - r2 * sin(angle + 2 * da); + glNormal3f(v, -u, 0.0); + glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), + width * 0.5); + glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), + -width * 0.5); + glNormal3f(cos(angle), sin(angle), 0.0); + } + + glVertex3f(r1 * cos(0), r1 * sin(0), width * 0.5); + glVertex3f(r1 * cos(0), r1 * sin(0), -width * 0.5); + + glEnd(); + + glShadeModel(GL_SMOOTH); + + /* draw inside radius cylinder */ + glBegin(GL_QUAD_STRIP); + for (i = 0; i <= teeth; i++) { + angle = i * 2.0 * M_PI / teeth; + glNormal3f(-cos(angle), -sin(angle), 0.0); + glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5); + glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5); + } + glEnd(); +} + + +static void +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); + + 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, 4.2, 0.0); + glRotatef(-2.0 * angle - 25.0, 0.0, 0.0, 1.0); + glCallList(gear3); + glPopMatrix(); + + glPopMatrix(); +} + + +/* new window size or exposure */ +static void +reshape(int width, int height) +{ + GLfloat h = (GLfloat) height / (GLfloat) width; + + WinWidth = width; + WinHeight = height; + glViewport(0, 0, (GLint) width, (GLint) height); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glFrustum(-1.0, 1.0, -h, h, 5.0, 60.0); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTranslatef(0.0, 0.0, -40.0); +} + + +static void +init(void) +{ + 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 }; + int i; + + glGetIntegerv(GL_AUX_BUFFERS, &i); + printf("AUX BUFFERS: %d\n", i); + + glLightfv(GL_LIGHT0, GL_POSITION, pos); + glEnable(GL_CULL_FACE); + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + glEnable(GL_DEPTH_TEST); + + /* make the gears */ + gear1 = glGenLists(1); + glNewList(gear1, GL_COMPILE); + glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, red); + gear(1.0, 4.0, 1.0, 20, 0.7); + glEndList(); + + gear2 = glGenLists(1); + glNewList(gear2, GL_COMPILE); + glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, green); + gear(0.5, 2.0, 2.0, 10, 0.7); + glEndList(); + + gear3 = glGenLists(1); + glNewList(gear3, GL_COMPILE); + glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, blue); + gear(1.3, 2.0, 0.5, 10, 0.7); + glEndList(); + + glEnable(GL_NORMALIZE); +} + + +/* + * Create an RGB, double-buffered window. + * Return the window and context handles. + */ +static void +make_window( Display *dpy, const char *name, + int x, int y, int width, int height, + Window *winRet, GLXContext *ctxRet) +{ + int attrib[] = { GLX_RGBA, + GLX_RED_SIZE, 1, + GLX_GREEN_SIZE, 1, + GLX_BLUE_SIZE, 1, + GLX_DOUBLEBUFFER, + GLX_DEPTH_SIZE, 1, + GLX_AUX_BUFFERS, 1, + None }; + int scrnum; + XSetWindowAttributes attr; + unsigned long mask; + Window root; + Window win; + GLXContext ctx; + XVisualInfo *visinfo; + + scrnum = DefaultScreen( dpy ); + root = RootWindow( dpy, scrnum ); + + visinfo = glXChooseVisual( dpy, scrnum, attrib ); + if (!visinfo) { + printf("Error: couldn't get an RGB, Double-buffered visual\n"); + exit(1); + } + + /* 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 ); + + /* set hints and properties */ + { + XSizeHints sizehints; + sizehints.x = x; + sizehints.y = y; + 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) { + printf("Error: glXCreateContext failed\n"); + exit(1); + } + + XFree(visinfo); + + *winRet = win; + *ctxRet = ctx; +} + + +static void +event_loop(Display *dpy, Window win) +{ + while (1) { + while (XPending(dpy) > 0) { + XEvent event; + XNextEvent(dpy, &event); + switch (event.type) { + case Expose: + /* we'll redraw below */ + break; + case ConfigureNotify: + reshape(event.xconfigure.width, event.xconfigure.height); + break; + case KeyPress: + { + char buffer[10]; + int r, code; + code = XLookupKeysym(&event.xkey, 0); + if (code == XK_Left) { + view_roty += 5.0; + } + else if (code == XK_Right) { + view_roty -= 5.0; + } + else if (code == XK_Up) { + view_rotx += 5.0; + } + else if (code == XK_Down) { + view_rotx -= 5.0; + } + else { + r = XLookupString(&event.xkey, buffer, sizeof(buffer), + NULL, NULL); + if (buffer[0] == 27) { + /* escape */ + return; + } + } + } + } + } + + /* next frame */ + angle += 2.0; + + /* draw to aux buffer */ + glDrawBuffer(GL_AUX0); + + draw(); + + /* Copy aux buffer image to back color buffer */ + glReadBuffer(GL_AUX0); + glDrawBuffer(GL_BACK); + glWindowPos2iARB(0, 0); + glDisable(GL_DEPTH_TEST); + glCopyPixels(0, 0, WinWidth, WinHeight, GL_COLOR); + glEnable(GL_DEPTH_TEST); + + glXSwapBuffers(dpy, win); + + /* calc framerate */ + { + static int t0 = -1; + static int frames = 0; + int t = current_time(); + + if (t0 < 0) + t0 = t; + + frames++; + + if (t - t0 >= 5.0) { + GLfloat seconds = t - t0; + GLfloat fps = frames / seconds; + printf("%d frames in %3.1f seconds = %6.3f FPS\n", frames, seconds, + fps); + t0 = t; + frames = 0; + } + } + } +} + + +int +main(int argc, char *argv[]) +{ + Display *dpy; + Window win; + GLXContext ctx; + char *dpyName = ":0"; + GLboolean printInfo = GL_FALSE; + int i; + + for (i = 1; i < argc; i++) { + if (strcmp(argv[i], "-display") == 0) { + dpyName = argv[i+1]; + i++; + } + else if (strcmp(argv[i], "-info") == 0) { + printInfo = GL_TRUE; + } + } + + dpy = XOpenDisplay(dpyName); + if (!dpy) { + printf("Error: couldn't open display %s\n", dpyName); + return -1; + } + + make_window(dpy, "glxgears", 0, 0, WinWidth, WinHeight, &win, &ctx); + XMapWindow(dpy, win); + glXMakeCurrent(dpy, win, ctx); + + if (printInfo) { + 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)); + } + + init(); + + event_loop(dpy, win); + + glXDestroyContext(dpy, ctx); + XDestroyWindow(dpy, win); + XCloseDisplay(dpy); + + return 0; +} diff --git a/progs/tests/blendminmax.c b/progs/tests/blendminmax.c new file mode 100644 index 00000000000..2aab1a39d29 --- /dev/null +++ b/progs/tests/blendminmax.c @@ -0,0 +1,209 @@ +/* + * (C) Copyright IBM Corporation 2004 + * 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 + * on the rights to use, copy, modify, merge, publish, distribute, sub + * license, 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 (including the next + * paragraph) 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 NON-INFRINGEMENT. IN NO EVENT SHALL + * VA LINUX SYSTEM, IBM AND/OR THEIR SUPPLIERS 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. + */ + +/** + * \file blendminmax.c + * + * Simple test of GL_EXT_blend_minmax functionality. Four squares are drawn + * with different blending modes, but all should be rendered with the same + * final color. + * + * \author Ian Romanick + */ + +#include +#include +#include + +static int Width = 400; +static int Height = 200; +static const GLfloat Near = 5.0, Far = 25.0; + + +static void Display( void ) +{ + glClearColor(0.2, 0.2, 0.8, 0); + glClear( GL_COLOR_BUFFER_BIT ); + + glPushMatrix(); + + /* This is the "reference" square. + */ + + glTranslatef(-4.5, 0, 0); + glBlendEquation( GL_FUNC_ADD ); + glBlendFunc( GL_ONE, GL_ZERO ); + glBegin(GL_QUADS); + glColor3f( 0.5, 0.5, 0.5 ); + glVertex2f(-1, -1); + glVertex2f( 1, -1); + glVertex2f( 1, 1); + glVertex2f(-1, 1); + glEnd(); + + + /* GL_MIN and GL_MAX are supposed to ignore the blend function setting. + * To test that, we set the blend function to GL_ZERO for both color and + * alpha each time GL_MIN or GL_MAX is used. + * + * Apple ships an extension called GL_ATI_blend_weighted_minmax (supported + * on Mac OS X 10.2 and later). I believe the difference with that + * extension is that it uses the blend function. However, I have no idea + * what the enums are for it. The extension is listed at Apple's developer + * site, but there is no documentation. + * + * http://developer.apple.com/opengl/extensions.html + */ + + glTranslatef(3.0, 0, 0); + glBlendEquation( GL_FUNC_ADD ); + glBlendFunc( GL_ONE, GL_ZERO ); + glBegin(GL_QUADS); + glColor3f( 0.5, 0.5, 0.5 ); + glVertex2f(-1, -1); + glVertex2f( 1, -1); + glVertex2f( 1, 1); + glVertex2f(-1, 1); + glEnd(); + + glBlendEquation( GL_MAX ); + glBlendFunc( GL_ZERO, GL_ZERO ); + glBegin(GL_QUADS); + glColor3f( 0.2, 0.2, 0.2 ); + glVertex2f(-1, -1); + glVertex2f( 1, -1); + glVertex2f( 1, 1); + glVertex2f(-1, 1); + glEnd(); + + + glTranslatef(3.0, 0, 0); + glBlendEquation( GL_FUNC_ADD ); + glBlendFunc( GL_ONE, GL_ZERO ); + glBegin(GL_QUADS); + glColor3f( 0.5, 0.5, 0.5 ); + glVertex2f(-1, -1); + glVertex2f( 1, -1); + glVertex2f( 1, 1); + glVertex2f(-1, 1); + glEnd(); + + glBlendEquation( GL_MIN ); + glBlendFunc( GL_ZERO, GL_ZERO ); + glBegin(GL_QUADS); + glColor3f( 0.8, 0.8, 0.8 ); + glVertex2f(-1, -1); + glVertex2f( 1, -1); + glVertex2f( 1, 1); + glVertex2f(-1, 1); + glEnd(); + + + glTranslatef(3.0, 0, 0); + glBlendEquation( GL_FUNC_ADD ); + glBlendFunc( GL_ONE, GL_ZERO ); + glBegin(GL_QUADS); + glColor3f( 0.8, 0.8, 0.8 ); + glVertex2f(-1, -1); + glVertex2f( 1, -1); + glVertex2f( 1, 1); + glVertex2f(-1, 1); + glEnd(); + + glBlendEquation( GL_MIN ); + glBlendFunc( GL_ZERO, GL_ZERO ); + glBegin(GL_QUADS); + glColor3f( 0.5, 0.5, 0.5 ); + glVertex2f(-1, -1); + glVertex2f( 1, -1); + glVertex2f( 1, 1); + glVertex2f(-1, 1); + glEnd(); + + glPopMatrix(); + + glutSwapBuffers(); +} + + +static void Reshape( int width, int height ) +{ + GLfloat ar = (float) width / (float) height; + Width = width; + Height = height; + glViewport( 0, 0, width, height ); + glMatrixMode( GL_PROJECTION ); + glLoadIdentity(); + glFrustum( -ar, ar, -1.0, 1.0, Near, Far ); + glMatrixMode( GL_MODELVIEW ); + glLoadIdentity(); + glTranslatef( 0.0, 0.0, -15.0 ); +} + + +static void Key( unsigned char key, int x, int y ) +{ + (void) x; + (void) y; + switch (key) { + case 27: + exit(0); + break; + } + glutPostRedisplay(); +} + + +static void Init( void ) +{ + const char * const ver_string = (const char * const) + glGetString( GL_VERSION ); + + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + printf("GL_VERSION = %s\n", ver_string); + + if ( !glutExtensionSupported("GL_ARB_imaging") && !glutExtensionSupported("GL_EXT_blend_minmax")) { + printf("Sorry, this program requires either GL_ARB_imaging or GL_EXT_blend_minmax.\n"); + exit(1); + } + + printf("\nAll 4 squares should be the same color.\n"); + glEnable( GL_BLEND ); +} + + +int main( int argc, char *argv[] ) +{ + glutInit( &argc, argv ); + glutInitWindowPosition( 0, 0 ); + glutInitWindowSize( Width, Height ); + glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE ); + glutCreateWindow( "GL_EXT_blend_minmax test" ); + glutReshapeFunc( Reshape ); + glutKeyboardFunc( Key ); + glutDisplayFunc( Display ); + Init(); + glutMainLoop(); + return 0; +} diff --git a/progs/tests/blendsquare.c b/progs/tests/blendsquare.c new file mode 100644 index 00000000000..1694866a557 --- /dev/null +++ b/progs/tests/blendsquare.c @@ -0,0 +1,178 @@ +/* + * (C) Copyright IBM Corporation 2004 + * 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 + * on the rights to use, copy, modify, merge, publish, distribute, sub + * license, 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 (including the next + * paragraph) 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 NON-INFRINGEMENT. IN NO EVENT SHALL + * VA LINUX SYSTEM, IBM AND/OR THEIR SUPPLIERS 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. + */ + +/** + * \file blendsquare.c + * + * Simple test of GL_NV_blend_square functionality. Four squares are drawn + * with different blending modes, but all should be rendered with the same + * final color. + * + * \author Ian Romanick + */ + +#include +#include +#include + +static int Width = 400; +static int Height = 200; +static const GLfloat Near = 5.0, Far = 25.0; + + +static void Display( void ) +{ + glClearColor(0.2, 0.2, 0.8, 0); + glClear( GL_COLOR_BUFFER_BIT ); + + glPushMatrix(); + + glTranslatef(-4.5, 0, 0); + glBlendFunc( GL_ONE, GL_ZERO ); + glBegin(GL_QUADS); + glColor3f( 0.5 * 0.5, 0.5 * 0.5, 0.5 * 0.5 ); + glVertex2f(-1, -1); + glVertex2f( 1, -1); + glVertex2f( 1, 1); + glVertex2f(-1, 1); + glEnd(); + + + glTranslatef(3.0, 0, 0); + glBlendFunc( GL_ONE, GL_ZERO ); + glBegin(GL_QUADS); + glColor3f( 0.5, 0.5, 0.5 ); + glVertex2f(-1, -1); + glVertex2f( 1, -1); + glVertex2f( 1, 1); + glVertex2f(-1, 1); + glEnd(); + + glBlendFunc( GL_DST_COLOR, GL_ZERO ); + glBegin(GL_QUADS); + glVertex2f(-1, -1); + glVertex2f( 1, -1); + glVertex2f( 1, 1); + glVertex2f(-1, 1); + glEnd(); + + + glTranslatef(3.0, 0, 0); + glBlendFunc( GL_SRC_COLOR, GL_ZERO ); + glBegin(GL_QUADS); + glVertex2f(-1, -1); + glVertex2f( 1, -1); + glVertex2f( 1, 1); + glVertex2f(-1, 1); + glEnd(); + + + glTranslatef(3.0, 0, 0); + glBlendFunc( GL_ONE, GL_ZERO ); + glBegin(GL_QUADS); + glVertex2f(-1, -1); + glVertex2f( 1, -1); + glVertex2f( 1, 1); + glVertex2f(-1, 1); + glEnd(); + + glBlendFunc( GL_ZERO, GL_DST_COLOR ); + glBegin(GL_QUADS); + glVertex2f(-1, -1); + glVertex2f( 1, -1); + glVertex2f( 1, 1); + glVertex2f(-1, 1); + glEnd(); + + glPopMatrix(); + + glutSwapBuffers(); +} + + +static void Reshape( int width, int height ) +{ + GLfloat ar = (float) width / (float) height; + Width = width; + Height = height; + glViewport( 0, 0, width, height ); + glMatrixMode( GL_PROJECTION ); + glLoadIdentity(); + glFrustum( -ar, ar, -1.0, 1.0, Near, Far ); + glMatrixMode( GL_MODELVIEW ); + glLoadIdentity(); + glTranslatef( 0.0, 0.0, -15.0 ); +} + + +static void Key( unsigned char key, int x, int y ) +{ + (void) x; + (void) y; + switch (key) { + case 27: + exit(0); + break; + } + glutPostRedisplay(); +} + + +static void Init( void ) +{ + const char * const ver_string = (const char * const) + glGetString( GL_VERSION ); + const double version = strtod( ver_string, NULL ); + + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + printf("GL_VERSION = %s\n", ver_string); + + if ( (version < 1.4) && !glutExtensionSupported("GL_NV_blend_square")) { + printf("Sorry, this program requires either OpenGL 1.4 or GL_NV_blend_square\n"); + exit(1); + } + + printf("\nAll 4 squares should be the same color. The two on the left are drawn\n" + "without NV_blend_square functionality, and the two on the right are drawn\n" + "with NV_blend_square functionality. If the two on the left are dark, but\n" + "the two on the right are not, then NV_blend_square is broken.\n"); + glEnable( GL_BLEND ); + glBlendEquation( GL_FUNC_ADD ); +} + + +int main( int argc, char *argv[] ) +{ + glutInit( &argc, argv ); + glutInitWindowPosition( 0, 0 ); + glutInitWindowSize( Width, Height ); + glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE ); + glutCreateWindow( "GL_NV_blend_square test" ); + glutReshapeFunc( Reshape ); + glutKeyboardFunc( Key ); + glutDisplayFunc( Display ); + Init(); + glutMainLoop(); + return 0; +} diff --git a/progs/tests/bufferobj.c b/progs/tests/bufferobj.c new file mode 100644 index 00000000000..c765d2516ba --- /dev/null +++ b/progs/tests/bufferobj.c @@ -0,0 +1,359 @@ +/* + * Test GL_ARB_vertex_buffer_object + * + * Brian Paul + * 16 Sep 2003 + */ + + +#define GL_GLEXT_PROTOTYPES +#include +#include +#include +#include +#include + +#define NUM_OBJECTS 10 + +struct object +{ + GLuint BufferID; + GLuint ElementsBufferID; + GLuint NumVerts; + GLuint VertexOffset; + GLuint ColorOffset; + GLuint NumElements; +}; + +static struct object Objects[NUM_OBJECTS]; +static GLuint NumObjects; + +static GLfloat Xrot = 0, Yrot = 0, Zrot = 0; +static GLboolean Anim = GL_TRUE; + + +static void CheckError(int line) +{ + GLenum err = glGetError(); + if (err) { + printf("GL Error 0x%x at line %d\n", (int) err, line); + } +} + + +static void DrawObject( const struct object *obj ) +{ + glBindBufferARB(GL_ARRAY_BUFFER_ARB, obj->BufferID); + glVertexPointer(3, GL_FLOAT, 0, (void *) obj->VertexOffset); + glEnable(GL_VERTEX_ARRAY); + + /* test push/pop attrib */ + /* XXX this leads to a segfault with NVIDIA's 53.36 driver */ +#if 0 + if (1) + { + glPushClientAttrib(GL_CLIENT_VERTEX_ARRAY_BIT); + /*glVertexPointer(3, GL_FLOAT, 0, (void *) (obj->VertexOffset + 10000));*/ + glBindBufferARB(GL_ARRAY_BUFFER_ARB, 999999); + glPopClientAttrib(); + } +#endif + glColorPointer(3, GL_FLOAT, 0, (void *) obj->ColorOffset); + glEnable(GL_COLOR_ARRAY); + + if (obj->NumElements > 0) { + /* indexed arrays */ + glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, obj->ElementsBufferID); + glDrawElements(GL_LINE_LOOP, obj->NumElements, GL_UNSIGNED_INT, NULL); + } + else { + /* non-indexed arrays */ + glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0); + glDrawArrays(GL_LINE_LOOP, 0, obj->NumVerts); + } +} + + +static void Idle( void ) +{ + Zrot = 0.05 * glutGet(GLUT_ELAPSED_TIME); + glutPostRedisplay(); +} + + +static void Display( void ) +{ + int i; + + glClear( GL_COLOR_BUFFER_BIT ); + + for (i = 0; i < NumObjects; i++) { + float x = 5.0 * ((float) i / (NumObjects-1) - 0.5); + glPushMatrix(); + glTranslatef(x, 0, 0); + glRotatef(Xrot, 1, 0, 0); + glRotatef(Yrot, 0, 1, 0); + glRotatef(Zrot, 0, 0, 1); + + DrawObject(Objects + i); + + glPopMatrix(); + } + + CheckError(__LINE__); + glutSwapBuffers(); +} + + +static void Reshape( int width, int height ) +{ + float ar = (float) width / (float) height; + glViewport( 0, 0, width, height ); + glMatrixMode( GL_PROJECTION ); + glLoadIdentity(); + glFrustum( -ar, ar, -1.0, 1.0, 5.0, 25.0 ); + glMatrixMode( GL_MODELVIEW ); + glLoadIdentity(); + glTranslatef( 0.0, 0.0, -15.0 ); +} + + +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 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 MakeObject1(struct object *obj) +{ + GLfloat *v, *c; + void *p; + int i; + GLubyte buffer[500]; + + for (i = 0; i < 500; i++) + buffer[i] = i & 0xff; + + obj->BufferID = 0; + glGenBuffersARB(1, &obj->BufferID); + assert(obj->BufferID != 0); + glBindBufferARB(GL_ARRAY_BUFFER_ARB, obj->BufferID); + glBufferDataARB(GL_ARRAY_BUFFER_ARB, 500, buffer, GL_STATIC_DRAW_ARB); + + for (i = 0; i < 500; i++) + buffer[i] = 0; + + glGetBufferSubDataARB(GL_ARRAY_BUFFER_ARB, 0, 500, buffer); + + for (i = 0; i < 500; i++) + assert(buffer[i] == (i & 0xff)); + + glGetBufferParameterivARB(GL_ARRAY_BUFFER_ARB, GL_BUFFER_MAPPED_ARB, &i); + assert(!i); + + glGetBufferParameterivARB(GL_ARRAY_BUFFER_ARB, GL_BUFFER_USAGE_ARB, &i); + + v = (GLfloat *) glMapBufferARB(GL_ARRAY_BUFFER_ARB, GL_WRITE_ONLY_ARB); + + /* do some sanity tests */ + glGetBufferPointervARB(GL_ARRAY_BUFFER_ARB, GL_BUFFER_MAP_POINTER_ARB, &p); + assert(p == v); + + glGetBufferParameterivARB(GL_ARRAY_BUFFER_ARB, GL_BUFFER_SIZE_ARB, &i); + assert(i == 500); + + glGetBufferParameterivARB(GL_ARRAY_BUFFER_ARB, GL_BUFFER_USAGE_ARB, &i); + assert(i == GL_STATIC_DRAW_ARB); + + glGetBufferParameterivARB(GL_ARRAY_BUFFER_ARB, GL_BUFFER_ACCESS_ARB, &i); + assert(i == GL_WRITE_ONLY_ARB); + + glGetBufferParameterivARB(GL_ARRAY_BUFFER_ARB, GL_BUFFER_MAPPED_ARB, &i); + assert(i); + + /* Make rectangle */ + v[0] = -1; v[1] = -1; v[2] = 0; + v[3] = 1; v[4] = -1; v[5] = 0; + v[6] = 1; v[7] = 1; v[8] = 0; + v[9] = -1; v[10] = 1; v[11] = 0; + c = v + 12; + c[0] = 1; c[1] = 0; c[2] = 0; + c[3] = 1; c[4] = 0; c[5] = 0; + c[6] = 1; c[7] = 0; c[8] = 1; + c[9] = 1; c[10] = 0; c[11] = 1; + obj->NumVerts = 4; + obj->VertexOffset = 0; + obj->ColorOffset = 3 * sizeof(GLfloat) * obj->NumVerts; + obj->NumElements = 0; + + glUnmapBufferARB(GL_ARRAY_BUFFER_ARB); + + glGetBufferPointervARB(GL_ARRAY_BUFFER_ARB, GL_BUFFER_MAP_POINTER_ARB, &p); + assert(!p); + + glGetBufferParameterivARB(GL_ARRAY_BUFFER_ARB, GL_BUFFER_MAPPED_ARB, &i); + assert(!i); +} + + +static void MakeObject2(struct object *obj) +{ + GLfloat *v, *c; + + glGenBuffersARB(1, &obj->BufferID); + glBindBufferARB(GL_ARRAY_BUFFER_ARB, obj->BufferID); + glBufferDataARB(GL_ARRAY_BUFFER_ARB, 1000, NULL, GL_STATIC_DRAW_ARB); + v = (GLfloat *) glMapBufferARB(GL_ARRAY_BUFFER_ARB, GL_WRITE_ONLY_ARB); + + /* Make triangle */ + v[0] = -1; v[1] = -1; v[2] = 0; + v[3] = 1; v[4] = -1; v[5] = 0; + v[6] = 0; v[7] = 1; v[8] = 0; + c = v + 9; + c[0] = 0; c[1] = 1; c[2] = 0; + c[3] = 0; c[4] = 1; c[5] = 0; + c[6] = 1; c[7] = 1; c[8] = 0; + obj->NumVerts = 3; + obj->VertexOffset = 0; + obj->ColorOffset = 3 * sizeof(GLfloat) * obj->NumVerts; + obj->NumElements = 0; + + glUnmapBufferARB(GL_ARRAY_BUFFER_ARB); +} + + +static void MakeObject3(struct object *obj) +{ + GLfloat vertexData[1000]; + GLfloat *v, *c; + GLuint *i; + int bytes; + + /* Make rectangle */ + v = vertexData; + v[0] = -1; v[1] = -0.5; v[2] = 0; + v[3] = 1; v[4] = -0.5; v[5] = 0; + v[6] = 1; v[7] = 0.5; v[8] = 0; + v[9] = -1; v[10] = 0.5; v[11] = 0; + c = vertexData + 12; + c[0] = 0; c[1] = 0; c[2] = 1; + c[3] = 0; c[4] = 0; c[5] = 1; + c[6] = 0; c[7] = 1; c[8] = 1; + c[9] = 0; c[10] = 1; c[11] = 1; + obj->NumVerts = 4; + obj->VertexOffset = 0; + obj->ColorOffset = 3 * sizeof(GLfloat) * obj->NumVerts; + + bytes = obj->NumVerts * (3 + 3) * sizeof(GLfloat); + + /* Don't use glMap/UnmapBuffer for this object */ + glGenBuffersARB(1, &obj->BufferID); + glBindBufferARB(GL_ARRAY_BUFFER_ARB, obj->BufferID); + glBufferDataARB(GL_ARRAY_BUFFER_ARB, bytes, vertexData, GL_STATIC_DRAW_ARB); + + /* Setup a buffer of indices to test the ELEMENTS path */ + glGenBuffersARB(1, &obj->ElementsBufferID); + glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, obj->ElementsBufferID); + glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 100, NULL, GL_STATIC_DRAW_ARB); + i = (GLuint *) glMapBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, GL_READ_WRITE_ARB); + i[0] = 0; + i[1] = 1; + i[2] = 2; + i[3] = 3; + glUnmapBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB); + obj->NumElements = 4; +} + + + +static void Init( void ) +{ + if (!glutExtensionSupported("GL_ARB_vertex_buffer_object")) { + printf("GL_ARB_vertex_buffer_object not found!\n"); + exit(0); + } + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + /* Test buffer object deletion */ + if (1) { + static GLubyte data[1000]; + GLuint id = 999; + glBindBufferARB(GL_ARRAY_BUFFER_ARB, id); + glBufferDataARB(GL_ARRAY_BUFFER_ARB, 1000, data, GL_STATIC_DRAW_ARB); + glVertexPointer(3, GL_FLOAT, 0, (void *) 0); + glDeleteBuffersARB(1, &id); + assert(!glIsBufferARB(id)); + glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); + glVertexPointer(3, GL_FLOAT, 0, (void *) 0); + assert(!glIsBufferARB(id)); + } + + MakeObject1(Objects + 0); + MakeObject2(Objects + 1); + MakeObject3(Objects + 2); + NumObjects = 3; +} + + +int main( int argc, char *argv[] ) +{ + glutInit( &argc, argv ); + glutInitWindowPosition( 0, 0 ); + glutInitWindowSize( 600, 300 ); + glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE ); + glutCreateWindow(argv[0]); + glutReshapeFunc( Reshape ); + glutKeyboardFunc( Key ); + glutSpecialFunc( SpecialKey ); + glutDisplayFunc( Display ); + if (Anim) + glutIdleFunc(Idle); + Init(); + glutMainLoop(); + return 0; +} diff --git a/progs/tests/bug_3050.c b/progs/tests/bug_3050.c new file mode 100644 index 00000000000..4ea7b80f231 --- /dev/null +++ b/progs/tests/bug_3050.c @@ -0,0 +1,162 @@ +/* + * (C) Copyright IBM Corporation 2006 + * 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 + * on the rights to use, copy, modify, merge, publish, distribute, sub + * license, 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 (including the next + * paragraph) 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 NON-INFRINGEMENT. IN NO EVENT SHALL + * VA LINUX SYSTEM, IBM AND/OR THEIR SUPPLIERS 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. + */ + +/** + * \file bug_3050.c + * + * Simple regression test for bug #3050. Create a texture and make a few + * calls to \c glGetTexLevelParameteriv. If the bug still exists, trying + * to get \c GL_TEXTURE_WITDH will cause a protocol error. + * + * This test \b only applies to indirect-rendering. This may mean that the + * test needs to be run with the environment variable \c LIBGL_ALWAYS_INDIRECT + * set to a non-zero value. + * + * \author Ian Romanick + */ + +#include +#include +#include +#include + +static int Width = 400; +static int Height = 200; +static const GLfloat Near = 5.0, Far = 25.0; + + +static void Display( void ) +{ +} + + +static void Reshape( int width, int 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 Init( void ) +{ + unsigned i; + static const GLenum pnames[] = { + GL_TEXTURE_RED_SIZE, + GL_TEXTURE_GREEN_SIZE, + GL_TEXTURE_BLUE_SIZE, + GL_TEXTURE_ALPHA_SIZE, + GL_TEXTURE_LUMINANCE_SIZE, + GL_TEXTURE_INTENSITY_SIZE, + GL_TEXTURE_BORDER, + GL_TEXTURE_INTERNAL_FORMAT, + GL_TEXTURE_WIDTH, + GL_TEXTURE_HEIGHT, + GL_TEXTURE_DEPTH, + ~0 + }; + + + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + printf("GL_VERSION = %s\n", (char *) glGetString(GL_VERSION)); + + printf("\nThis program should log some data about a texture and exit.\n"); + printf("This is a regression test for bug #3050. If the bug still\n"); + printf("exists, a GLX protocol error will be generated.\n"); + printf("https://bugs.freedesktop.org/show_bug.cgi?id=3050\n\n"); + + + if ( ! glutExtensionSupported( "GL_NV_texture_rectangle" ) + && ! glutExtensionSupported( "GL_EXT_texture_rectangle" ) + && ! glutExtensionSupported( "GL_ARB_texture_rectangle" ) ) { + printf( "This test requires one of GL_ARB_texture_rectangle, GL_EXT_texture_rectangle,\n" + "or GL_NV_texture_rectangle be supported\n." ); + exit( 1 ); + } + + + glBindTexture( GL_TEXTURE_RECTANGLE_NV, 1 ); + glTexImage2D( GL_PROXY_TEXTURE_RECTANGLE_NV, 0, GL_RGBA, 8, 8, 0, + GL_RGBA, GL_UNSIGNED_BYTE, NULL ); + + for ( i = 0 ; pnames[i] != ~0 ; i++ ) { + GLint param_i; + GLfloat param_f; + GLenum err; + + glGetTexLevelParameteriv( GL_PROXY_TEXTURE_RECTANGLE_NV, 0, pnames[i], & param_i ); + err = glGetError(); + + if ( err ) { + printf("glGetTexLevelParameteriv(GL_PROXY_TEXTURE_RECTANGLE_NV, 0, 0x%04x, & param) generated a GL\n" + "error of 0x%04x!", + pnames[i], err ); + exit( 1 ); + } + else { + printf("glGetTexLevelParameteriv(GL_PROXY_TEXTURE_RECTANGLE_NV, 0, 0x%04x, & param) = 0x%04x\n", + pnames[i], param_i ); + } + + + glGetTexLevelParameterfv( GL_PROXY_TEXTURE_RECTANGLE_NV, 0, pnames[i], & param_f ); + err = glGetError(); + + if ( err ) { + printf("glGetTexLevelParameterfv(GL_PROXY_TEXTURE_RECTANGLE_NV, 0, 0x%04x, & param) generated a GL\n" + "error of 0x%04x!\n", + pnames[i], err ); + exit( 1 ); + } + else { + printf("glGetTexLevelParameterfv(GL_PROXY_TEXTURE_RECTANGLE_NV, 0, 0x%04x, & param) = %.1f (0x%04x)\n", + pnames[i], param_f, (GLint) param_f ); + } + } +} + + +int main( int argc, char *argv[] ) +{ + glutInit( &argc, argv ); + glutInitWindowPosition( 0, 0 ); + glutInitWindowSize( Width, Height ); + glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE ); + glutCreateWindow( "Bug #3050 Test" ); + glutReshapeFunc( Reshape ); + glutKeyboardFunc( Key ); + glutDisplayFunc( Display ); + Init(); + return 0; +} diff --git a/progs/tests/bug_3101.c b/progs/tests/bug_3101.c new file mode 100644 index 00000000000..761dcbb9513 --- /dev/null +++ b/progs/tests/bug_3101.c @@ -0,0 +1,128 @@ +/* + * (C) Copyright IBM Corporation 2005 + * 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 + * on the rights to use, copy, modify, merge, publish, distribute, sub + * license, 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 (including the next + * paragraph) 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 NON-INFRINGEMENT. IN NO EVENT SHALL + * VA LINUX SYSTEM, IBM AND/OR THEIR SUPPLIERS 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. + */ + +/** + * \file bug_3101.c + * + * Simple regression test for bug #3101. Attempt to draw a single square. + * After emiting the first vertex, call \c glEdgeFlag to change the vertex + * format. If the bug still exists, this will cause a segfault. + * + * \author Ian Romanick + */ + +#include +#include +#include + +static int Width = 400; +static int Height = 200; +static const GLfloat Near = 5.0, Far = 25.0; + + +static void Display( void ) +{ + glClearColor(0.2, 0.2, 0.8, 0); + glClear( GL_COLOR_BUFFER_BIT ); + + glPushMatrix(); + + /* This is the "reference" square. + */ + + glTranslatef(-4.5, 0, 0); + glBlendEquation( GL_FUNC_ADD ); + glBlendFunc( GL_ONE, GL_ZERO ); + glBegin(GL_QUADS); + glColor3f( 0.5, 0.5, 0.5 ); + glVertex2f(-1, -1); + glVertex2f( 1, -1); + glEdgeFlag(GL_TRUE); + glVertex2f( 1, 1); + glVertex2f(-1, 1); + glEnd(); + + glPopMatrix(); + + glutSwapBuffers(); +} + + +static void Reshape( int width, int height ) +{ + GLfloat ar = (float) width / (float) height; + Width = width; + Height = height; + glViewport( 0, 0, width, height ); + glMatrixMode( GL_PROJECTION ); + glLoadIdentity(); + glFrustum( -ar, ar, -1.0, 1.0, Near, Far ); + glMatrixMode( GL_MODELVIEW ); + glLoadIdentity(); + glTranslatef( 0.0, 0.0, -15.0 ); +} + + +static void Key( unsigned char key, int x, int y ) +{ + (void) x; + (void) y; + switch (key) { + case 27: + exit(0); + break; + } + glutPostRedisplay(); +} + + +static void Init( void ) +{ + const char * const ver_string = (const char * const) + glGetString( GL_VERSION ); + + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + printf("GL_VERSION = %s\n", ver_string); + + printf("\nThis program should draw a single square, but not crash.\n"); + printf("This is a regression test for bug #3101.\n"); + printf("https://bugs.freedesktop.org/show_bug.cgi?id=3101\n"); + glEnable( GL_BLEND ); +} + + +int main( int argc, char *argv[] ) +{ + glutInit( &argc, argv ); + glutInitWindowPosition( 0, 0 ); + glutInitWindowSize( Width, Height ); + glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE ); + glutCreateWindow( "Bug #3101 Test" ); + glutReshapeFunc( Reshape ); + glutKeyboardFunc( Key ); + glutDisplayFunc( Display ); + Init(); + glutMainLoop(); + return 0; +} diff --git a/progs/tests/bug_3195.c b/progs/tests/bug_3195.c new file mode 100644 index 00000000000..4aceae04abe --- /dev/null +++ b/progs/tests/bug_3195.c @@ -0,0 +1,275 @@ +/* + * 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. + */ + +/** + * \file bug_3195.c + * + * Simple regression test for bug #3195. A bug in the i180 driver caused + * a segfault (inside the driver) when the LOD bias is adjusted and no texture + * is enabled. This test, which is based on progs/demos/lodbias.c, sets up + * all the texturing, disables all textures, adjusts the LOD bias, then + * re-enables \c GL_TEXTURE_2D. + * + * \author Brian Paul + * \author Ian Romanick + */ + +#include +#include +#include +#include +#include +#include + +#include "readtex.h" + +#define TEXTURE_FILE "../images/girl.rgb" + +static GLfloat Xrot = 0, Yrot = -30, Zrot = 0; +static GLint Bias = 0, BiasStepSign = +1; /* ints avoid fp precision problem */ +static GLint BiasMin = -400, BiasMax = 400; + + + +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) { + exit(0); + } + 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); + + glTexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, 0.01 * Bias); + glEnable(GL_TEXTURE_2D); + + 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 ) +{ + (void) x; + (void) y; + switch (key) { + 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 ) +{ + GLfloat maxBias; + const char * const ver_string = (const char * const) + glGetString( GL_VERSION ); + + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + printf("GL_VERSION = %s\n", ver_string); + + printf("\nThis program should function nearly identically to Mesa's lodbias demo.\n" + "It should cycle through the complet LOD bias range once and exit. If bug\n" + "#3195 still exists, the demo should crash almost immediatly.\n"); + printf("This is a regression test for bug #3195.\n"); + printf("https://bugs.freedesktop.org/show_bug.cgi?id=3195\n"); + + if (!glutExtensionSupported("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 (glutExtensionSupported("GL_SGIS_generate_mipmap")) { + /* test auto mipmap generation */ + GLint width, height, i; + GLenum format; + GLubyte *image = LoadRGBImage(TEXTURE_FILE, &width, &height, &format); + if (!image) { + printf("Error: could not load texture image %s\n", TEXTURE_FILE); + exit(1); + } + /* resize to 256 x 256 */ + if (width != 256 || height != 256) { + GLubyte *newImage = malloc(256 * 256 * 4); + gluScaleImage(format, width, height, GL_UNSIGNED_BYTE, image, + 256, 256, GL_UNSIGNED_BYTE, newImage); + free(image); + image = newImage; + } + printf("Using GL_SGIS_generate_mipmap\n"); + glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS, GL_TRUE); + glTexImage2D(GL_TEXTURE_2D, 0, format, 256, 256, 0, + format, GL_UNSIGNED_BYTE, image); + free(image); + + /* make sure mipmap was really generated correctly */ + width = height = 256; + for (i = 0; i < 9; i++) { + GLint w, h; + glGetTexLevelParameteriv(GL_TEXTURE_2D, i, GL_TEXTURE_WIDTH, &w); + glGetTexLevelParameteriv(GL_TEXTURE_2D, i, GL_TEXTURE_HEIGHT, &h); + printf("Level %d size: %d x %d\n", i, w, h); + assert(w == width); + assert(h == height); + width /= 2; + height /= 2; + } + + } + else 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); + + glGetFloatv(GL_MAX_TEXTURE_LOD_BIAS_EXT, &maxBias); + printf("LOD bias range: [%g, %g]\n", -maxBias, maxBias); + BiasMin = -100 * maxBias; + BiasMax = 100 * maxBias; + + /* Since we have (about) 8 mipmap levels, no need to bias beyond + * the range [-1, +8]. + */ + if (BiasMin < -100) + BiasMin = -100; + if (BiasMax > 800) + BiasMax = 800; +} + + +int main( int argc, char *argv[] ) +{ + glutInit( &argc, argv ); + glutInitWindowPosition( 0, 0 ); + glutInitWindowSize( 350, 350 ); + glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE ); + glutCreateWindow( "Bug #3195 Test" ); + glutReshapeFunc( Reshape ); + glutKeyboardFunc( Key ); + glutSpecialFunc( SpecialKey ); + glutDisplayFunc( Display ); + glutIdleFunc(Idle); + Init(); + glutMainLoop(); + return 0; +} diff --git a/progs/tests/copypixrate.c b/progs/tests/copypixrate.c new file mode 100644 index 00000000000..e9a42a1c8c9 --- /dev/null +++ b/progs/tests/copypixrate.c @@ -0,0 +1,259 @@ +/* + * Measure glCopyPixels speed + * + * Brian Paul + * 26 Jan 2006 + */ + +#define GL_GLEXT_PROTOTYPES +#include +#include +#include +#include +#include + +static GLint WinWidth = 1000, WinHeight = 800; +static GLint ImgWidth, ImgHeight; + +static GLenum Buffer = GL_FRONT; +static GLenum AlphaTest = GL_FALSE; +static GLboolean UseBlit = GL_FALSE; + +static PFNGLBLITFRAMEBUFFEREXTPROC glBlitFramebufferEXT_func = NULL; + + +/** + * draw teapot in lower-left corner of window + */ +static void +DrawTestImage(void) +{ + GLfloat ar; + + ImgWidth = WinWidth / 3; + ImgHeight = WinHeight / 3; + + glViewport(0, 0, ImgWidth, ImgHeight); + glScissor(0, 0, ImgWidth, ImgHeight); + glEnable(GL_SCISSOR_TEST); + + glClearColor(0.5, 0.5, 0.5, 0.0); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + ar = (float) WinWidth / WinHeight; + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glFrustum(-ar, ar, -1.0, 1.0, 5.0, 25.0); + glMatrixMode(GL_MODELVIEW); + + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + glEnable(GL_DEPTH_TEST); + glFrontFace(GL_CW); + glPushMatrix(); + glRotatef(45, 1, 0, 0); + glutSolidTeapot(2.0); + glPopMatrix(); + glFrontFace(GL_CCW); + glDisable(GL_DEPTH_TEST); + glDisable(GL_LIGHTING); + + glDisable(GL_SCISSOR_TEST); + + glViewport(0, 0, WinWidth, WinHeight); + glFinish(); +} + + +static int +Rand(int max) +{ + return ((int) random()) % max; +} + + +/** + * Measure glCopyPixels rate + */ +static void +RunTest(void) +{ + double t1, t0 = glutGet(GLUT_ELAPSED_TIME) / 1000.0; + int iters = 0; + float copyRate, mbRate; + int r, g, b, a, bpp; + + if (AlphaTest) { + glEnable(GL_ALPHA_TEST); + glAlphaFunc(GL_GREATER, 0.0); + } + + glGetIntegerv(GL_RED_BITS, &r); + glGetIntegerv(GL_GREEN_BITS, &g); + glGetIntegerv(GL_BLUE_BITS, &b); + glGetIntegerv(GL_ALPHA_BITS, &a); + bpp = (r + g + b + a) / 8; + + do { + int x, y; + x = Rand(WinWidth); + y = Rand(WinHeight); + + if (x > ImgWidth || y > ImgHeight) { +#ifdef GL_EXT_framebuffer_blit + if (UseBlit) + { + glBlitFramebufferEXT_func(0, 0, ImgWidth, ImgHeight, + x, y, x + ImgWidth, y + ImgHeight, + GL_COLOR_BUFFER_BIT, GL_LINEAR); + } + else +#endif + { + glWindowPos2iARB(x, y); + glCopyPixels(0, 0, ImgWidth, ImgHeight, GL_COLOR); + } + glFinish(); /* XXX OK? */ + + iters++; + + t1 = glutGet(GLUT_ELAPSED_TIME) / 1000.0; + } + } while (t1 - t0 < 5.0); + + glDisable(GL_ALPHA_TEST); + + copyRate = iters / (t1 - t0); + mbRate = ImgWidth * ImgHeight * bpp * copyRate / (1024 * 1024); + + printf("Image size: %d x %d, %d Bpp\n", ImgWidth, ImgHeight, bpp); + printf("%d copies in %.2f = %.2f copies/sec, %.2f MB/s\n", + iters, t1-t0, copyRate, mbRate); +} + + +static void +Draw(void) +{ + glClearColor(0.0, 0.0, 0.0, 0.0); + glClearColor(0.2, 0.2, 0.8, 0); + glReadBuffer(Buffer); + glDrawBuffer(Buffer); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + DrawTestImage(); + + RunTest(); + + if (Buffer == GL_FRONT) + glFinish(); + else + glutSwapBuffers(); + + printf("exiting\n"); + exit(0); +} + + +static void +Reshape(int width, int height) +{ + glViewport(0, 0, width, height); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glFrustum(-1.0, 1.0, -1.0, 1.0, 5.0, 25.0); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTranslatef(0.0, 0.0, -15.0); +} + + +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) +{ + (void) x; + (void) y; + switch (key) { + case GLUT_KEY_UP: + break; + case GLUT_KEY_DOWN: + break; + case GLUT_KEY_LEFT: + break; + case GLUT_KEY_RIGHT: + break; + } + glutPostRedisplay(); +} + + +static void +ParseArgs(int argc, char *argv[]) +{ + int i; + for (i = 1; i < argc; i++) { + if (strcmp(argv[i], "-back") == 0) + Buffer = GL_BACK; + else if (strcmp(argv[i], "-alpha") == 0) + AlphaTest = GL_TRUE; + else if (strcmp(argv[i], "-blit") == 0) + UseBlit = GL_TRUE; + } +} + + +static void +Init(void) +{ + if (glutExtensionSupported("GL_EXT_framebuffer_blit")) { + glBlitFramebufferEXT_func = (PFNGLBLITFRAMEBUFFEREXTPROC) + glutGetProcAddress("glBlitFramebufferEXT"); + } + else if (UseBlit) { + printf("Warning: GL_EXT_framebuffer_blit not supported.\n"); + UseBlit = GL_FALSE; + } +} + + +int +main(int argc, char *argv[]) +{ + GLint mode = GLUT_RGB | GLUT_ALPHA | GLUT_DOUBLE | GLUT_DEPTH; + glutInit(&argc, argv); + + ParseArgs(argc, argv); + if (AlphaTest) + mode |= GLUT_ALPHA; + + glutInitWindowPosition(0, 0); + glutInitWindowSize(WinWidth, WinHeight); + glutInitDisplayMode(mode); + glutCreateWindow(argv[0]); + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutSpecialFunc(SpecialKey); + glutDisplayFunc(Draw); + + printf("GL_RENDERER: %s\n", (char *) glGetString(GL_RENDERER)); + printf("Draw Buffer: %s\n", (Buffer == GL_BACK) ? "Back" : "Front"); + Init(); + + glutMainLoop(); + return 0; +} diff --git a/progs/tests/crossbar.c b/progs/tests/crossbar.c new file mode 100644 index 00000000000..12aabb1c9ad --- /dev/null +++ b/progs/tests/crossbar.c @@ -0,0 +1,235 @@ +/* + * (C) Copyright IBM Corporation 2005 + * 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 + * on the rights to use, copy, modify, merge, publish, distribute, sub + * license, 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 (including the next + * paragraph) 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 NON-INFRINGEMENT. IN NO EVENT SHALL + * VA LINUX SYSTEM, IBM AND/OR THEIR SUPPLIERS 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. + */ + +/** + * \file crossbar.c + * + * Simple test of GL_ARB_texture_env_crossbar functionality. Several squares + * are drawn with different texture combine modes, but all should be rendered + * with the same final color. + * + * \author Ian Romanick + */ + +#include +#include +#include +#include + +static const GLint tests[][8] = { + { 1, GL_REPLACE, GL_PRIMARY_COLOR, GL_PRIMARY_COLOR, + 2, GL_REPLACE, GL_TEXTURE, GL_PRIMARY_COLOR }, + { 3, GL_REPLACE, GL_PRIMARY_COLOR, GL_PRIMARY_COLOR, + 2, GL_SUBTRACT, GL_TEXTURE0, GL_TEXTURE1 }, + { 2, GL_REPLACE, GL_PRIMARY_COLOR, GL_PRIMARY_COLOR, + 2, GL_REPLACE, GL_TEXTURE0, GL_TEXTURE0 }, + { 2, GL_REPLACE, GL_PRIMARY_COLOR, GL_PRIMARY_COLOR, + 1, GL_SUBTRACT, GL_TEXTURE0, GL_TEXTURE1 }, + { 3, GL_ADD, GL_TEXTURE1, GL_TEXTURE1, + 2, GL_MODULATE, GL_TEXTURE1, GL_PREVIOUS }, + { 3, GL_ADD, GL_TEXTURE1, GL_TEXTURE1, + 4, GL_MODULATE, GL_TEXTURE0, GL_PREVIOUS }, +}; + +#define NUM_TESTS (sizeof(tests) / sizeof(tests[0])) + +static int Width = 100 * (NUM_TESTS + 1); +static int Height = 200; +static const GLfloat Near = 5.0, Far = 25.0; + + +static void Display( void ) +{ + unsigned i; + + + glClearColor(0.2, 0.2, 0.8, 0); + glClear( GL_COLOR_BUFFER_BIT ); + + glPushMatrix(); + + /* This is the "reference" square. + */ + + glActiveTexture( GL_TEXTURE0 ); + glDisable( GL_TEXTURE_2D ); + glActiveTexture( GL_TEXTURE1 ); + glDisable( GL_TEXTURE_2D ); + + glTranslatef(-(NUM_TESTS * 1.5), 0, 0); + glBegin(GL_QUADS); + glColor3f( 0.5, 0.5, 0.5 ); + glVertex2f(-1, -1); + glVertex2f( 1, -1); + glVertex2f( 1, 1); + glVertex2f(-1, 1); + glEnd(); + + for ( i = 0 ; i < NUM_TESTS ; i++ ) { + glActiveTexture( GL_TEXTURE0 ); + glEnable( GL_TEXTURE_2D ); + glBindTexture( GL_TEXTURE_2D, tests[i][0] ); + glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE ); + glTexEnvi( GL_TEXTURE_ENV, GL_COMBINE_RGB, tests[i][1] ); + glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE0_RGB, tests[i][2] ); + glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE1_RGB, tests[i][3] ); + + glActiveTexture( GL_TEXTURE1 ); + glEnable( GL_TEXTURE_2D ); + glBindTexture( GL_TEXTURE_2D, tests[i][4] ); + glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE ); + glTexEnvi( GL_TEXTURE_ENV, GL_COMBINE_RGB, tests[i][5] ); + glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE0_RGB, tests[i][6] ); + glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE1_RGB, tests[i][7] ); + + glCallList(1); + } + + glPopMatrix(); + + glutSwapBuffers(); +} + + +static void Reshape( int width, int height ) +{ + GLfloat ar = (float) width / (float) height; + Width = width; + Height = height; + glViewport( 0, 0, width, height ); + glMatrixMode( GL_PROJECTION ); + glLoadIdentity(); + glFrustum( -ar, ar, -1.0, 1.0, Near, Far ); + glMatrixMode( GL_MODELVIEW ); + glLoadIdentity(); + glTranslatef( 0.0, 0.0, -15.0 ); +} + + +static void Key( unsigned char key, int x, int y ) +{ + (void) x; + (void) y; + switch (key) { + case 27: + exit(0); + break; + } + glutPostRedisplay(); +} + + +static void Init( void ) +{ + const char * const ver_string = (const char * const) + glGetString( GL_VERSION ); + float ver = strtof( ver_string, NULL ); + GLint tex_units; + GLint temp[ 256 ]; + + + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + printf("GL_VERSION = %s\n", ver_string); + + if ( (!glutExtensionSupported("GL_ARB_multitexture") + && (ver < 1.3)) + || (!glutExtensionSupported("GL_ARB_texture_env_combine") + && !glutExtensionSupported("GL_EXT_texture_env_combine") + && (ver < 1.3)) + || (!glutExtensionSupported("GL_ARB_texture_env_crossbar") + && !glutExtensionSupported("GL_NV_texture_env_combine4") + && (ver < 1.4)) ) { + printf("\nSorry, this program requires GL_ARB_multitexture and either\n" + "GL_ARB_texture_env_combine or GL_EXT_texture_env_combine (or OpenGL 1.3).\n" + "Either GL_ARB_texture_env_crossbar or GL_NV_texture_env_combine4 (or\n" + "OpenGL 1.4) are also required.\n"); + exit(1); + } + + glGetIntegerv( GL_MAX_TEXTURE_UNITS, & tex_units ); + if ( tex_units < 2 ) { + printf("\nSorry, this program requires at least 2 texture units.\n"); + exit(1); + } + + printf("\nAll %u squares should be the same color.\n", NUM_TESTS + 1); + + (void) memset( temp, 0x00, sizeof( temp ) ); + glBindTexture( GL_TEXTURE_2D, 1 ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST ); + glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, 8, 8, 0, + GL_RGBA, GL_UNSIGNED_BYTE, temp ); + + (void) memset( temp, 0x7f, sizeof( temp ) ); + glBindTexture( GL_TEXTURE_2D, 2 ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST ); + glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, 8, 8, 0, + GL_RGBA, GL_UNSIGNED_BYTE, temp ); + + (void) memset( temp, 0xff, sizeof( temp ) ); + glBindTexture( GL_TEXTURE_2D, 3 ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST ); + glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, 8, 8, 0, + GL_RGBA, GL_UNSIGNED_BYTE, temp ); + + (void) memset( temp, 0x3f, sizeof( temp ) ); + glBindTexture( GL_TEXTURE_2D, 4 ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST ); + glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, 8, 8, 0, + GL_RGBA, GL_UNSIGNED_BYTE, temp ); + + + glNewList( 1, GL_COMPILE ); + glTranslatef(3.0, 0, 0); + glBegin(GL_QUADS); + glColor3f( 0.9, 0.0, 0.0 ); + glMultiTexCoord2f( GL_TEXTURE0, 0.5, 0.5 ); + glMultiTexCoord2f( GL_TEXTURE1, 0.5, 0.5 ); + glVertex2f(-1, -1); + glVertex2f( 1, -1); + glVertex2f( 1, 1); + glVertex2f(-1, 1); + glEnd(); + glEndList(); +} + + +int main( int argc, char *argv[] ) +{ + glutInit( &argc, argv ); + glutInitWindowPosition( 0, 0 ); + glutInitWindowSize( Width, Height ); + glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE ); + glutCreateWindow( "GL_ARB_texture_env_crossbar test" ); + glutReshapeFunc( Reshape ); + glutKeyboardFunc( Key ); + glutDisplayFunc( Display ); + Init(); + glutMainLoop(); + return 0; +} diff --git a/progs/tests/cva.c b/progs/tests/cva.c new file mode 100644 index 00000000000..8514be6226e --- /dev/null +++ b/progs/tests/cva.c @@ -0,0 +1,164 @@ +/* $Id: cva.c,v 1.7 2003-12-08 09:03:35 joukj Exp $ */ + +/* + * Trivial CVA test, good for testing driver fastpaths (especially + * indexed vertex buffers if they are supported). + * + * Gareth Hughes + * November 2000 + */ + +#include +#include +#include +#ifdef __VMS +# include /* for ptrdiff_t, referenced by GL.h when GL_GLEXT_LEGACY defined */ +#else +# include /* for ptrdiff_t, referenced by GL.h when GL_GLEXT_LEGACY defined */ +#endif +#ifdef _WIN32 +#include +#endif +#define GL_GLEXT_LEGACY +#include + + +GLfloat verts[][4] = { + { -0.5, -0.5, -2.0, 0.0 }, + { 0.5, -0.5, -2.0, 0.0 }, + { -0.5, 0.5, -2.0, 0.0 }, + { 0.5, 0.5, -2.0, 0.0 }, +}; + +GLubyte color[][4] = { + { 0xff, 0x00, 0x00, 0x00 }, + { 0x00, 0xff, 0x00, 0x00 }, + { 0x00, 0x00, 0xff, 0x00 }, + { 0xff, 0xff, 0xff, 0x00 }, +}; + +GLuint indices[] = { 0, 1, 2, 3 }; + +GLboolean compiled = GL_TRUE; +GLboolean doubleBuffer = GL_TRUE; + + +void init( void ) +{ + glClearColor( 0.0, 0.0, 0.0, 0.0 ); + glShadeModel( GL_SMOOTH ); + + glFrontFace( GL_CCW ); + glCullFace( GL_BACK ); + glEnable( GL_CULL_FACE ); + + glEnable( GL_DEPTH_TEST ); + + glEnableClientState( GL_VERTEX_ARRAY ); + glEnableClientState( GL_COLOR_ARRAY ); + + glMatrixMode( GL_PROJECTION ); + glLoadIdentity(); + glFrustum( -1.0, 1.0, -1.0, 1.0, 2.0, 10.0 ); + glMatrixMode( GL_MODELVIEW ); + glLoadIdentity(); + + glVertexPointer( 3, GL_FLOAT, sizeof(verts[0]), verts ); + glColorPointer( 4, GL_UNSIGNED_BYTE, 0, color ); + +#ifdef GL_EXT_compiled_vertex_array + if ( compiled ) { + glLockArraysEXT( 0, 4 ); + } +#endif +} + +void display( void ) +{ + glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); + + glDrawElements( GL_TRIANGLES, 3, GL_UNSIGNED_INT, indices ); + + glFlush(); + if ( doubleBuffer ) { + glutSwapBuffers(); + } +} + +void keyboard( unsigned char key, int x, int y ) +{ + switch ( key ) { + case 27: + exit( 0 ); + break; + } + + glutPostRedisplay(); +} + +GLboolean args( int argc, char **argv ) +{ + GLint i; + + doubleBuffer = GL_TRUE; + + for ( i = 1 ; i < argc ; i++ ) { + if ( strcmp( argv[i], "-sb" ) == 0 ) { + doubleBuffer = GL_FALSE; + } else if ( strcmp( argv[i], "-db" ) == 0 ) { + doubleBuffer = GL_TRUE; + } else { + fprintf( stderr, "%s (Bad option).\n", argv[i] ); + return GL_FALSE; + } + } + return GL_TRUE; +} + +int main( int argc, char **argv ) +{ + GLenum type; + char *string; + + glutInit( &argc, argv ); + + if ( args( argc, argv ) == GL_FALSE ) { + exit( 1 ); + } + + type = GLUT_RGB | GLUT_DEPTH; + type |= ( doubleBuffer ) ? GLUT_DOUBLE : GLUT_SINGLE; + + glutInitDisplayMode( type ); + glutInitWindowSize( 250, 250 ); + glutInitWindowPosition( 100, 100 ); + glutCreateWindow( "CVA Test" ); + + /* Make sure the server supports GL 1.2 vertex arrays. + */ + string = (char *) glGetString( GL_VERSION ); + + if ( !strstr(string, "1.2") && + !strstr(string, "1.3") && + !strstr(string, "1.4")) { + fprintf( stderr, "This program requires OpenGL 1.2 vertex arrays.\n" ); + exit( -1 ); + } + + /* See if the server supports compiled vertex arrays. + */ + string = (char *) glGetString( GL_EXTENSIONS ); + + if ( !strstr( string, "GL_EXT_compiled_vertex_array" ) ) { + fprintf( stderr, "Compiled vertex arrays not supported by this renderer.\n" ); + compiled = GL_FALSE; + } + + init(); + + glutDisplayFunc( display ); + glutKeyboardFunc( keyboard ); + glutMainLoop(); + + return 0; +} diff --git a/progs/tests/debugger.c b/progs/tests/debugger.c new file mode 100644 index 00000000000..4c6955bcfc6 --- /dev/null +++ b/progs/tests/debugger.c @@ -0,0 +1,733 @@ +/* + * Test the GL_MESA_program_debug extension + */ + + +#include +#include +#include +#include +#include +#include +#define GL_GLEXT_PROTOTYPES +#include + + +/* + * Print the string with line numbers + */ +static void list_program(const GLubyte *string, GLsizei len) +{ + const char *c = (const char *) string; + int i, line = 1, printNumber = 1; + + for (i = 0; i < len; i++) { + if (printNumber) { + printf("%3d ", line); + printNumber = 0; + } + if (*c == '\n') { + line++; + printNumber = 1; + } + putchar(*c); + c++; + } + putchar('\n'); +} + + +/* + * Return the line number and column number that corresponds to the + * given program position. Also return a null-terminated copy of that + * line of the program string. + */ +static const GLubyte * +find_line_column(const GLubyte *string, const GLubyte *pos, + GLint *line, GLint *col) +{ + const GLubyte *lineStart = string; + const GLubyte *p = string; + GLubyte *s; + int len; + + *line = 1; + + while (p != pos) { + if (*p == (GLubyte) '\n') { + (*line)++; + lineStart = p + 1; + } + p++; + } + + *col = (pos - lineStart) + 1; + + /* return copy of this line */ + while (*p != 0 && *p != '\n') + p++; + len = p - lineStart; + s = (GLubyte *) malloc(len + 1); + memcpy(s, lineStart, len); + s[len] = 0; + + return s; +} + + +#define ARB_VERTEX_PROGRAM 1 +#define ARB_FRAGMENT_PROGRAM 2 +#define NV_VERTEX_PROGRAM 3 +#define NV_FRAGMENT_PROGRAM 4 + + +struct breakpoint { + enum {PIXEL, LINE} type; + int x, y; + int line; + GLboolean enabled; +}; + +#define MAX_BREAKPOINTS 100 +static struct breakpoint Breakpoints[MAX_BREAKPOINTS]; +static int NumBreakpoints = 0; + + + +/* + * Interactive debugger + */ +static void Debugger2(GLenum target, GLvoid *data) +{ + static GLuint skipCount = 0; + const GLubyte *ln; + GLint pos, line, column; + GLint id; + int progType; + GLint len; + GLubyte *program; + GLboolean stop; + int i; + + /* Sigh, GL_VERTEX_PROGRAM_ARB == GL_VERTEX_PROGRAM_NV so it's a bit + * hard to distinguish between them. + */ + if (target == GL_FRAGMENT_PROGRAM_ARB) + progType = ARB_FRAGMENT_PROGRAM; + else if (target == GL_FRAGMENT_PROGRAM_NV) + progType = NV_FRAGMENT_PROGRAM; + else + progType = NV_VERTEX_PROGRAM; + + /* Until we hit zero, continue rendering */ + if (skipCount > 0) { + skipCount--; + return; + } + + /* Get id of the program and current position */ + switch (progType) { + case ARB_FRAGMENT_PROGRAM: + glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_BINDING_ARB, &id); + glGetIntegerv(GL_FRAGMENT_PROGRAM_POSITION_MESA, &pos); + break; + case NV_FRAGMENT_PROGRAM: + glGetIntegerv(GL_FRAGMENT_PROGRAM_BINDING_NV, &id); + glGetIntegerv(GL_FRAGMENT_PROGRAM_POSITION_MESA, &pos); + break; + case ARB_VERTEX_PROGRAM: + glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_BINDING_ARB, &id); + glGetIntegerv(GL_VERTEX_PROGRAM_POSITION_MESA, &pos); + break; + case NV_VERTEX_PROGRAM: + glGetIntegerv(GL_VERTEX_PROGRAM_BINDING_NV, &id); + glGetIntegerv(GL_VERTEX_PROGRAM_POSITION_MESA, &pos); + break; + default: + abort(); + } + + /* get program string */ + if (progType == ARB_VERTEX_PROGRAM || + progType == ARB_FRAGMENT_PROGRAM) + glGetProgramivARB(target, GL_PROGRAM_LENGTH_ARB, &len); + else + glGetProgramivNV(id, GL_PROGRAM_LENGTH_NV, &len); + program = malloc(len + 1); + if (progType == ARB_VERTEX_PROGRAM || + progType == ARB_FRAGMENT_PROGRAM) + glGetProgramStringARB(target, GL_PROGRAM_STRING_ARB, program); + else + glGetProgramStringNV(id, GL_PROGRAM_STRING_NV, program); + + + /* Get current line number, column, line string */ + ln = find_line_column(program, program + pos, &line, &column); + + /* test breakpoints */ + if (NumBreakpoints > 0) + stop = GL_FALSE; + else + stop = GL_TRUE; + for (i = 0; i < NumBreakpoints; i++) { + if (Breakpoints[i].enabled) { + switch (Breakpoints[i].type) { + case PIXEL: + if (progType == ARB_FRAGMENT_PROGRAM) { + + } + else if (progType == NV_FRAGMENT_PROGRAM) { + GLfloat pos[4]; + int px, py; + glGetProgramRegisterfvMESA(GL_FRAGMENT_PROGRAM_NV, + 6, (GLubyte *) "f[WPOS]", pos); + px = (int) pos[0]; + py = (int) pos[1]; + printf("%d, %d\n", px, py); + if (px == Breakpoints[i].x && + py == Breakpoints[i].y) { + printf("Break at pixel (%d, %d)\n", px, py); + stop = GL_TRUE; + } + } + break; + case LINE: + if (line == Breakpoints[i].line) { + /* hit a breakpoint! */ + printf("Break at line %d\n", line); + stop = GL_TRUE; + } + break; + } + } + } + if (!stop) { + free(program); + return; + } + + printf("%d: %s\n", line, ln); + + /* get commands from stdin */ + while (1) { + char command[1000], *cmd; + + /* print prompt and get command */ + printf("(%s %d) ", (target == GL_VERTEX_PROGRAM_ARB ? "vert" : "frag"), + line); + fgets(command, 999, stdin); + + /* skip leading whitespace */ + for (cmd = command; cmd[0] == ' '; cmd++) + ; + + if (!cmd[0]) + /* nothing (repeat the previous cmd?) */ + continue; + + switch (cmd[0]) { + case 's': + /* skip N instructions */ + i = atoi(cmd + 2); + skipCount = i; + printf("Skipping %d instructions\n", i); + return; + case 'n': + /* next */ + return; + case 'c': + return; + case 'd': + /* dump machine state */ + if (progType == NV_FRAGMENT_PROGRAM) { + static const char *inRegs[] = { + "f[WPOS]", "f[COL0]", "f[COL1]", "f[FOGC]", + "f[TEX0]", "f[TEX1]", "f[TEX2]", "f[TEX3]", + NULL + }; + static const char *outRegs[] = { + "o[COLR]", "o[COLH]", "o[DEPR]", NULL + }; + GLfloat v[4]; + int i; + printf("Fragment input attributes:\n"); + for (i = 0; inRegs[i]; i++) { + glGetProgramRegisterfvMESA(GL_FRAGMENT_PROGRAM_NV, + strlen(inRegs[i]), + (const GLubyte *) inRegs[i], v); + printf(" %s: %g, %g, %g, %g\n", inRegs[i], + v[0], v[1], v[2], v[3]); + } + printf("Fragment output attributes:\n"); + for (i = 0; outRegs[i]; i++) { + glGetProgramRegisterfvMESA(GL_FRAGMENT_PROGRAM_NV, + strlen(outRegs[i]), + (const GLubyte *) outRegs[i], v); + printf(" %s: %g, %g, %g, %g\n", outRegs[i], + v[0], v[1], v[2], v[3]); + } + printf("Temporaries:\n"); + for (i = 0; i < 4; i++) { + char temp[100]; + GLfloat v[4]; + sprintf(temp, "R%d", i); + glGetProgramRegisterfvMESA(GL_FRAGMENT_PROGRAM_NV, + strlen(temp), + (const GLubyte *) temp, v); + printf(" %s: %g, %g, %g, %g\n", temp, v[0],v[1],v[2],v[3]); + } + } + else if (progType == NV_VERTEX_PROGRAM) { + GLfloat v[4]; + int i; + static const char *inRegs[] = { + "v[OPOS]", "v[WGHT]", "v[NRML]", "v[COL0]", + "v[COL1]", "v[FOGC]", "v[6]", "v[7]", + "v[TEX0]", "v[TEX1]", "v[TEX2]", "v[TEX3]", + "v[TEX4]", "v[TEX5]", "v[TEX6]", "v[TEX7]", + NULL + }; + static const char *outRegs[] = { + "o[HPOS]", "o[COL0]", "o[COL1]", "o[BFC0]", + "o[BFC1]", "o[FOGC]", "o[PSIZ]", + "o[TEX0]", "o[TEX1]", "o[TEX2]", "o[TEX3]", + "o[TEX4]", "o[TEX5]", "o[TEX6]", "o[TEX7]", + NULL + }; + printf("Vertex input attributes:\n"); + for (i = 0; inRegs[i]; i++) { + glGetProgramRegisterfvMESA(GL_VERTEX_PROGRAM_NV, + strlen(inRegs[i]), + (const GLubyte *) inRegs[i], v); + printf(" %s: %g, %g, %g, %g\n", inRegs[i], + v[0], v[1], v[2], v[3]); + } + printf("Vertex output attributes:\n"); + for (i = 0; outRegs[i]; i++) { + glGetProgramRegisterfvMESA(GL_VERTEX_PROGRAM_NV, + strlen(outRegs[i]), + (const GLubyte *) outRegs[i], v); + printf(" %s: %g, %g, %g, %g\n", outRegs[i], + v[0], v[1], v[2], v[3]); + } + printf("Temporaries:\n"); + for (i = 0; i < 4; i++) { + char temp[100]; + GLfloat v[4]; + sprintf(temp, "R%d", i); + glGetProgramRegisterfvMESA(GL_VERTEX_PROGRAM_NV, + strlen(temp), + (const GLubyte *) temp, v); + printf(" %s: %g, %g, %g, %g\n", temp, v[0],v[1],v[2],v[3]); + } + } + break; + case 'l': + /* list */ + list_program(program, len); + break; + case 'p': + /* print */ + { + GLfloat v[4]; + char *c; + cmd++; + while (*cmd == ' ') + cmd++; + c = cmd; + while (*c) { + if (*c == '\n' || *c == '\r') + *c = 0; + else + c++; + } + glGetProgramRegisterfvMESA(target, strlen(cmd), + (const GLubyte *) cmd, v); + if (glGetError() == GL_NO_ERROR) + printf("%s = %g, %g, %g, %g\n", cmd, v[0], v[1], v[2], v[3]); + else + printf("Invalid expression\n"); + } + break; + case 'b': + if (cmd[1] == ' ' && isdigit(cmd[2])) { + char *comma = strchr(cmd, ','); + if (comma) { + /* break at pixel */ + int x = atoi(cmd + 2); + int y = atoi(comma + 1); + if (NumBreakpoints < MAX_BREAKPOINTS) { + Breakpoints[NumBreakpoints].type = PIXEL; + Breakpoints[NumBreakpoints].x = x; + Breakpoints[NumBreakpoints].y = y; + Breakpoints[NumBreakpoints].enabled = GL_TRUE; + NumBreakpoints++; + printf("Breakpoint %d: break at pixel (%d, %d)\n", + NumBreakpoints, x, y); + } + } + else { + /* break at line */ + int l = atoi(cmd + 2); + if (l && NumBreakpoints < MAX_BREAKPOINTS) { + Breakpoints[NumBreakpoints].type = LINE; + Breakpoints[NumBreakpoints].line = l; + Breakpoints[NumBreakpoints].enabled = GL_TRUE; + NumBreakpoints++; + printf("Breakpoint %d: break at line %d\n", + NumBreakpoints, l); + } + } + } + else { + /* list breakpoints */ + printf("Breakpoints:\n"); + for (i = 0; i < NumBreakpoints; i++) { + switch (Breakpoints[i].type) { + case LINE: + printf(" %d: break at line %d\n", + i + 1, Breakpoints[i].line); + break; + case PIXEL: + printf(" %d: break at pixel (%d, %d)\n", + i + 1, Breakpoints[i].x, Breakpoints[i].y); + break; + } + } + } + break; + case 'h': + /* help */ + printf("Debugger commands:\n"); + printf(" b list breakpoints\n"); + printf(" b N break at line N\n"); + printf(" b x,y break at pixel x,y\n"); + printf(" c continue execution\n"); + printf(" d display register values\n"); + printf(" h help\n"); + printf(" l list program\n"); + printf(" n next instruction\n"); + printf(" p V print value V\n"); + printf(" s N skip N instructions\n"); + break; + default: + printf("Unknown command: %c\n", cmd[0]); + } + } +} + + +/* + * Print current line, some registers, and continue. + */ +static void Debugger(GLenum target, GLvoid *data) +{ + GLint pos; + const GLubyte *ln; + GLint line, column; + GLfloat v[4]; + + assert(target == GL_FRAGMENT_PROGRAM_NV); + + glGetIntegerv(GL_FRAGMENT_PROGRAM_POSITION_MESA, &pos); + + ln = find_line_column((const GLubyte *) data, (const GLubyte *) data + pos, + &line, &column); + printf("%d:%d: %s\n", line, column, (char *) ln); + + glGetProgramRegisterfvMESA(GL_FRAGMENT_PROGRAM_NV, + 2, (const GLubyte *) "R0", v); + printf(" R0 = %g, %g, %g, %g\n", v[0], v[1], v[2], v[3]); + glGetProgramRegisterfvMESA(GL_FRAGMENT_PROGRAM_NV, + 7, (const GLubyte *) "f[WPOS]", v); + printf(" o[WPOS] = %g, %g, %g, %g\n", v[0], v[1], v[2], v[3]); + glGetProgramRegisterfvMESA(GL_FRAGMENT_PROGRAM_NV, + 7, (const GLubyte *) "o[COLR]", v); + printf(" o[COLR] = %g, %g, %g, %g\n", v[0], v[1], v[2], v[3]); + + free((void *) ln); +} + + + + +/**********************************************************************/ + +static GLfloat Diffuse[4] = { 0.5, 0.5, 1.0, 1.0 }; +static GLfloat Specular[4] = { 0.8, 0.8, 0.8, 1.0 }; +static GLfloat LightPos[4] = { 0.0, 10.0, 20.0, 1.0 }; +static GLfloat Delta = 1.0; + +static GLuint FragProg; +static GLuint VertProg; +static GLboolean Anim = GL_TRUE; +static GLboolean Wire = GL_FALSE; +static GLboolean PixelLight = GL_TRUE; + +static GLfloat Xrot = 0, Yrot = 0; + + +#define NAMED_PARAMETER4FV(prog, name, v) \ + glProgramNamedParameter4fvNV(prog, strlen(name), (const GLubyte *) name, v) + + +static void Display( void ) +{ + glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); + + if (PixelLight) { + NAMED_PARAMETER4FV(FragProg, "LightPos", LightPos); + glEnable(GL_FRAGMENT_PROGRAM_NV); + glEnable(GL_VERTEX_PROGRAM_NV); + glDisable(GL_LIGHTING); + } + else { + glLightfv(GL_LIGHT0, GL_POSITION, LightPos); + glDisable(GL_FRAGMENT_PROGRAM_NV); + glDisable(GL_VERTEX_PROGRAM_NV); + glEnable(GL_LIGHTING); + } + + glPushMatrix(); + glRotatef(Xrot, 1, 0, 0); + glRotatef(Yrot, 0, 1, 0); + +#if 1 + glutSolidSphere(2.0, 10, 5); +#else + { + GLUquadricObj *q = gluNewQuadric(); + gluQuadricNormals(q, GL_SMOOTH); + gluQuadricTexture(q, GL_TRUE); + glRotatef(90, 1, 0, 0); + glTranslatef(0, 0, -1); + gluCylinder(q, 1.0, 1.0, 2.0, 24, 1); + gluDeleteQuadric(q); + } +#endif + + glPopMatrix(); + + glutSwapBuffers(); +} + + +static void Idle(void) +{ + LightPos[0] += Delta; + if (LightPos[0] > 25.0) + Delta = -1.0; + else if (LightPos[0] <- 25.0) + Delta = 1.0; + glutPostRedisplay(); +} + + +static void Reshape( int width, int height ) +{ + glViewport( 0, 0, width, height ); + glMatrixMode( GL_PROJECTION ); + glLoadIdentity(); + glFrustum( -1.0, 1.0, -1.0, 1.0, 5.0, 25.0 ); + /*glOrtho( -2.0, 2.0, -2.0, 2.0, 5.0, 25.0 );*/ + glMatrixMode( GL_MODELVIEW ); + glLoadIdentity(); + glTranslatef( 0.0, 0.0, -15.0 ); +} + + +static void Key( unsigned char key, int x, int y ) +{ + (void) x; + (void) y; + switch (key) { + case ' ': + Anim = !Anim; + if (Anim) + glutIdleFunc(Idle); + else + glutIdleFunc(NULL); + break; + case 'x': + LightPos[0] -= 1.0; + break; + case 'X': + LightPos[0] += 1.0; + break; + case 'w': + Wire = !Wire; + if (Wire) + glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); + else + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); + break; + case 'p': + PixelLight = !PixelLight; + if (PixelLight) { + printf("Per-pixel lighting\n"); + } + else { + printf("Conventional lighting\n"); + } + 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( int argc, char *argv[] ) +{ + static const char *fragProgramText = + "!!FP1.0\n" + "DECLARE Diffuse; \n" + "DECLARE Specular; \n" + "DECLARE LightPos; \n" + + "# Compute normalized LightPos, put it in R0\n" + "DP3 R0.x, LightPos, LightPos;\n" + "RSQ R0.y, R0.x;\n" + "MUL R0, LightPos, R0.y;\n" + + "# Compute normalized normal, put it in R1\n" + "DP3 R1, f[TEX0], f[TEX0]; \n" + "RSQ R1.y, R1.x;\n" + "MUL R1, f[TEX0], R1.y;\n" + + "# Compute dot product of light direction and normal vector\n" + "DP3 R2, R0, R1;\n" + + "MUL R3, Diffuse, R2; # diffuse attenuation\n" + + "POW R4, R2.x, {20.0}.x; # specular exponent\n" + + "MUL R5, Specular, R4; # specular attenuation\n" + + "ADD o[COLR], R3, R5; # add diffuse and specular colors\n" + "END \n" + ; + + static const char *vertProgramText = + "!!VP1.0\n" + "# typical modelview/projection transform\n" + "DP4 o[HPOS].x, c[0], v[OPOS] ;\n" + "DP4 o[HPOS].y, c[1], v[OPOS] ;\n" + "DP4 o[HPOS].z, c[2], v[OPOS] ;\n" + "DP4 o[HPOS].w, c[3], v[OPOS] ;\n" + "# transform normal by inv transpose of modelview, put in tex0\n" + "DP4 o[TEX0].x, c[4], v[NRML] ;\n" + "DP4 o[TEX0].y, c[5], v[NRML] ;\n" + "DP4 o[TEX0].z, c[6], v[NRML] ;\n" + "DP4 o[TEX0].w, c[7], v[NRML] ;\n" + "END\n"; + ; + + if (!glutExtensionSupported("GL_NV_vertex_program")) { + printf("Sorry, this demo requires GL_NV_vertex_program\n"); + exit(1); + } + if (!glutExtensionSupported("GL_NV_fragment_program")) { + printf("Sorry, this demo requires GL_NV_fragment_program\n"); + exit(1); + } + + glGenProgramsNV(1, &FragProg); + assert(FragProg > 0); + glGenProgramsNV(1, &VertProg); + assert(VertProg > 0); + + /* + * Fragment program + */ + glLoadProgramNV(GL_FRAGMENT_PROGRAM_NV, FragProg, + strlen(fragProgramText), + (const GLubyte *) fragProgramText); + assert(glIsProgramNV(FragProg)); + glBindProgramNV(GL_FRAGMENT_PROGRAM_NV, FragProg); + + NAMED_PARAMETER4FV(FragProg, "Diffuse", Diffuse); + NAMED_PARAMETER4FV(FragProg, "Specular", Specular); + + /* + * Vertex program + */ + glLoadProgramNV(GL_VERTEX_PROGRAM_NV, VertProg, + strlen(vertProgramText), + (const GLubyte *) vertProgramText); + assert(glIsProgramNV(VertProg)); + glBindProgramNV(GL_VERTEX_PROGRAM_NV, VertProg); + glTrackMatrixNV(GL_VERTEX_PROGRAM_NV, 0, GL_MODELVIEW_PROJECTION_NV, GL_IDENTITY_NV); + glTrackMatrixNV(GL_VERTEX_PROGRAM_NV, 4, GL_MODELVIEW, GL_INVERSE_TRANSPOSE_NV); + + /* + * Misc init + */ + glClearColor(0.3, 0.3, 0.3, 0.0); + glEnable(GL_DEPTH_TEST); + glEnable(GL_LIGHT0); + glEnable(GL_LIGHTING); + glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, Diffuse); + glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, Specular); + glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 20.0); + + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + printf("Press p to toggle between per-pixel and per-vertex lighting\n"); + +#ifdef GL_MESA_program_debug + if (argc > 1 && strcmp(argv[1], "fragment") == 0) { + printf(">> Debugging fragment program\n"); + glProgramCallbackMESA(GL_FRAGMENT_PROGRAM_ARB, Debugger2, + (GLvoid *) fragProgramText); + glEnable(GL_FRAGMENT_PROGRAM_CALLBACK_MESA); + } + else { + printf(">> Debugging vertex program\n"); + glProgramCallbackMESA(GL_VERTEX_PROGRAM_ARB, Debugger2, + (GLvoid *) fragProgramText); + glEnable(GL_VERTEX_PROGRAM_CALLBACK_MESA); + } +#endif +} + + +int main( int argc, char *argv[] ) +{ + glutInit( &argc, argv ); + glutInitWindowPosition( 0, 0 ); + glutInitWindowSize( 200, 200 ); + glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ); + glutCreateWindow(argv[0]); + glutReshapeFunc( Reshape ); + glutKeyboardFunc( Key ); + glutSpecialFunc( SpecialKey ); + glutDisplayFunc( Display ); + if (Anim) + glutIdleFunc(Idle); + Init(argc, argv); + glutMainLoop(); + return 0; +} diff --git a/progs/tests/descrip.mms b/progs/tests/descrip.mms new file mode 100644 index 00000000000..b6ba3e1aebb --- /dev/null +++ b/progs/tests/descrip.mms @@ -0,0 +1,84 @@ +# Makefile for GLUT-based demo programs for VMS +# contributed by Jouk Jansen joukj@hrem.stm.tudelft.nl + + +.first + define gl [--.include.gl] + +.include [--]mms-config. + +##### MACROS ##### + +INCDIR = ([--.include],[-.util]) +CFLAGS = /include=$(INCDIR)/prefix=all/name=(as_is,short)/float=ieee/ieee=denorm + +.ifdef SHARE +GL_LIBS = $(XLIBS) +.else +GL_LIBS = [--.lib]libGLUT/l,libMesaGLU/l,libMesaGL/l,$(XLIBS) +.endif + +LIB_DEP = [--.lib]$(GL_LIB) [--.lib]$(GLU_LIB) [--.lib]$(GLUT_LIB) + +PROGS = cva.exe,\ + dinoshade.exe,\ + fogcoord.exe,\ + manytex.exe,\ + multipal.exe,\ + projtex.exe,\ + seccolor.exe,\ + sharedtex.exe,\ + texline.exe,\ + texwrap.exe,\ + vptest1.exe,\ + vptest2.exe,\ + vptest3.exe,\ + vptorus.exe,\ + vpwarpmesh.exe + +##### RULES ##### +.obj.exe : + cxxlink $(MMS$TARGET_NAME),$(GL_LIBS) + +##### TARGETS ##### +default : + $(MMS)$(MMSQUALIFIERS) $(PROGS) + +clean : + delete *.obj;* + +realclean : + delete $(PROGS) + delete *.obj;* + +cva.exe : cva.obj $(LIB_DEP) +dinoshade.exe : dinoshade.obj $(LIB_DEP) +fogcoord.exe : fogcoord.obj $(LIB_DEP) +manytex.exe : manytex.obj $(LIB_DEP) +multipal.exe : multipal.obj $(LIB_DEP) +projtex.exe : projtex.obj $(LIB_DEP) +seccolor.exe : seccolor.obj $(LIB_DEP) +sharedtex.exe : sharedtex.obj $(LIB_DEP) +texline.exe : texline.obj $(LIB_DEP) +texwrap.exe : texwrap.obj $(LIB_DEP) +vptest1.exe : vptest1.obj $(LIB_DEP) +vptest2.exe : vptest2.obj $(LIB_DEP) +vptest3.exe : vptest3.obj $(LIB_DEP) +vptorus.exe : vptorus.obj $(LIB_DEP) +vpwarpmesh.exe : vpwarpmesh.obj $(LIB_DEP) + +cva.obj : cva.c +dinoshade.obj : dinoshade.c +fogcoord.obj : fogcoord.c +manytex.obj : manytex.c +multipal.obj : multipal.c +projtex.obj : projtex.c +seccolor.obj : seccolor.c +sharedtex.obj : sharedtex.c +texline.obj : texline.c +texwrap.obj : texwrap.c +vptest1.obj : vptest1.c +vptest2.obj : vptest2.c +vptest3.obj : vptest3.c +vptorus.obj : vptorus.c +vpwarpmesh.obj : vpwarpmesh.c diff --git a/progs/tests/dinoshade.c b/progs/tests/dinoshade.c new file mode 100644 index 00000000000..ed7b879bc71 --- /dev/null +++ b/progs/tests/dinoshade.c @@ -0,0 +1,914 @@ + +/* Copyright (c) Mark J. Kilgard, 1994, 1997. */ + +/* This program is freely distributable without licensing fees + and is provided without guarantee or warrantee expressed or + implied. This program is -not- in the public domain. */ + +/* Example for PC game developers to show how to *combine* texturing, + reflections, and projected shadows all in real-time with OpenGL. + Robust reflections use stenciling. Robust projected shadows + use both stenciling and polygon offset. PC game programmers + should realize that neither stenciling nor polygon offset are + supported by Direct3D, so these real-time rendering algorithms + are only really viable with OpenGL. + + The program has modes for disabling the stenciling and polygon + offset uses. It is worth running this example with these features + toggled off so you can see the sort of artifacts that result. + + Notice that the floor texturing, reflections, and shadowing + all co-exist properly. */ + +/* When you run this program: Left mouse button controls the + view. Middle mouse button controls light position (left & + right rotates light around dino; up & down moves light + position up and down). Right mouse button pops up menu. */ + +/* Check out the comments in the "redraw" routine to see how the + reflection blending and surface stenciling is done. You can + also see in "redraw" how the projected shadows are rendered, + including the use of stenciling and polygon offset. */ + +/* This program is derived from glutdino.c */ + +/* Compile: cc -o dinoshade dinoshade.c -lglut -lGLU -lGL -lXmu -lXext -lX11 -lm */ + +#include +#include +#include +#include /* for cos(), sin(), and sqrt() */ +#ifdef __VMS +# include /* for ptrdiff_t, referenced by GL.h when GL_GLEXT_LEGACY defined */ +#else +# include /* for ptrdiff_t, referenced by GL.h when GL_GLEXT_LEGACY defined */ +#endif +#ifdef _WIN32 +#include +#endif +#define GL_GLEXT_LEGACY +#include /* OpenGL Utility Toolkit header */ + +/* Some files do not define M_PI... */ +#ifndef M_PI +#define M_PI 3.14159265358979323846 +#endif + +/* Variable controlling various rendering modes. */ +static int stencilReflection = 1, stencilShadow = 1, offsetShadow = 1; +static int renderShadow = 1, renderDinosaur = 1, renderReflection = 1; +static int linearFiltering = 0, useMipmaps = 0, useTexture = 1; +static int reportSpeed = 0; +static int animation = 1; +static GLboolean lightSwitch = GL_TRUE; +static int directionalLight = 1; +static int forceExtension = 0; + +/* Time varying or user-controled variables. */ +static float jump = 0.0; +static float lightAngle = 0.0, lightHeight = 20; +GLfloat angle = -150; /* in degrees */ +GLfloat angle2 = 30; /* in degrees */ + +int moving, startx, starty; +int lightMoving = 0, lightStartX, lightStartY; + +enum { + MISSING, EXTENSION, ONE_DOT_ONE +}; +int polygonOffsetVersion; + +static GLdouble bodyWidth = 3.0; +/* *INDENT-OFF* */ +static GLfloat body[][2] = { {0, 3}, {1, 1}, {5, 1}, {8, 4}, {10, 4}, {11, 5}, + {11, 11.5}, {13, 12}, {13, 13}, {10, 13.5}, {13, 14}, {13, 15}, {11, 16}, + {8, 16}, {7, 15}, {7, 13}, {8, 12}, {7, 11}, {6, 6}, {4, 3}, {3, 2}, + {1, 2} }; +static GLfloat arm[][2] = { {8, 10}, {9, 9}, {10, 9}, {13, 8}, {14, 9}, {16, 9}, + {15, 9.5}, {16, 10}, {15, 10}, {15.5, 11}, {14.5, 10}, {14, 11}, {14, 10}, + {13, 9}, {11, 11}, {9, 11} }; +static GLfloat leg[][2] = { {8, 6}, {8, 4}, {9, 3}, {9, 2}, {8, 1}, {8, 0.5}, {9, 0}, + {12, 0}, {10, 1}, {10, 2}, {12, 4}, {11, 6}, {10, 7}, {9, 7} }; +static GLfloat eye[][2] = { {8.75, 15}, {9, 14.7}, {9.6, 14.7}, {10.1, 15}, + {9.6, 15.25}, {9, 15.25} }; +static GLfloat lightPosition[4]; +static GLfloat lightColor[] = {0.8, 1.0, 0.8, 1.0}; /* green-tinted */ +static GLfloat skinColor[] = {0.1, 1.0, 0.1, 1.0}, eyeColor[] = {1.0, 0.2, 0.2, 1.0}; +/* *INDENT-ON* */ + +/* Nice floor texture tiling pattern. */ +static char *circles[] = { + "....xxxx........", + "..xxxxxxxx......", + ".xxxxxxxxxx.....", + ".xxx....xxx.....", + "xxx......xxx....", + "xxx......xxx....", + "xxx......xxx....", + "xxx......xxx....", + ".xxx....xxx.....", + ".xxxxxxxxxx.....", + "..xxxxxxxx......", + "....xxxx........", + "................", + "................", + "................", + "................", +}; + +static void +makeFloorTexture(void) +{ + GLubyte floorTexture[16][16][3]; + GLubyte *loc; + int s, t; + + /* Setup RGB image for the texture. */ + loc = (GLubyte*) floorTexture; + for (t = 0; t < 16; t++) { + for (s = 0; s < 16; s++) { + if (circles[t][s] == 'x') { + /* Nice green. */ + loc[0] = 0x1f; + loc[1] = 0x8f; + loc[2] = 0x1f; + } else { + /* Light gray. */ + loc[0] = 0xaa; + loc[1] = 0xaa; + loc[2] = 0xaa; + } + loc += 3; + } + } + + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + + if (useMipmaps) { + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, + GL_LINEAR_MIPMAP_LINEAR); + gluBuild2DMipmaps(GL_TEXTURE_2D, 3, 16, 16, + GL_RGB, GL_UNSIGNED_BYTE, floorTexture); + } else { + if (linearFiltering) { + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + } else { + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + } + glTexImage2D(GL_TEXTURE_2D, 0, 3, 16, 16, 0, + GL_RGB, GL_UNSIGNED_BYTE, floorTexture); + } +} + +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]); +} + +void +extrudeSolidFromPolygon(GLfloat data[][2], unsigned int dataSize, + GLdouble thickness, GLuint side, GLuint edge, GLuint whole) +{ + static GLUtriangulatorObj *tobj = NULL; + GLdouble vertex[3], dx, dy, len; + int i; + int count = (int) (dataSize / (2 * sizeof(GLfloat))); + + if (tobj == NULL) { + tobj = gluNewTess(); /* create and initialize a GLU + polygon tesselation object */ + gluTessCallback(tobj, GLU_BEGIN, glBegin); + gluTessCallback(tobj, GLU_VERTEX, glVertex2fv); /* semi-tricky */ + gluTessCallback(tobj, GLU_END, glEnd); + } + glNewList(side, GL_COMPILE); + glShadeModel(GL_SMOOTH); /* smooth minimizes seeing + tessellation */ + gluBeginPolygon(tobj); + for (i = 0; i < count; i++) { + vertex[0] = data[i][0]; + vertex[1] = data[i][1]; + vertex[2] = 0; + gluTessVertex(tobj, vertex, data[i]); + } + gluEndPolygon(tobj); + glEndList(); + glNewList(edge, GL_COMPILE); + glShadeModel(GL_FLAT); /* flat shade keeps angular hands + from being "smoothed" */ + glBegin(GL_QUAD_STRIP); + for (i = 0; i <= count; i++) { +#if 1 /* weird, but seems to be legal */ + /* mod function handles closing the edge */ + glVertex3f(data[i % count][0], data[i % count][1], 0.0); + glVertex3f(data[i % count][0], data[i % count][1], thickness); + /* Calculate a unit normal by dividing by Euclidean + distance. We * could be lazy and use + glEnable(GL_NORMALIZE) so we could pass in * arbitrary + normals for a very slight performance hit. */ + dx = data[(i + 1) % count][1] - data[i % count][1]; + dy = data[i % count][0] - data[(i + 1) % count][0]; + len = sqrt(dx * dx + dy * dy); + glNormal3f(dx / len, dy / len, 0.0); +#else /* the nice way of doing it */ + /* Calculate a unit normal by dividing by Euclidean + distance. We * could be lazy and use + glEnable(GL_NORMALIZE) so we could pass in * arbitrary + normals for a very slight performance hit. */ + dx = data[i % count][1] - data[(i - 1 + count) % count][1]; + dy = data[(i - 1 + count) % count][0] - data[i % count][0]; + len = sqrt(dx * dx + dy * dy); + glNormal3f(dx / len, dy / len, 0.0); + /* mod function handles closing the edge */ + glVertex3f(data[i % count][0], data[i % count][1], 0.0); + glVertex3f(data[i % count][0], data[i % count][1], thickness); +#endif + } + glEnd(); + glEndList(); + glNewList(whole, GL_COMPILE); + glFrontFace(GL_CW); + glCallList(edge); + glNormal3f(0.0, 0.0, -1.0); /* constant normal for side */ + glCallList(side); + glPushMatrix(); + glTranslatef(0.0, 0.0, thickness); + glFrontFace(GL_CCW); + glNormal3f(0.0, 0.0, 1.0); /* opposite normal for other side */ + glCallList(side); + glPopMatrix(); + glEndList(); +} + +/* Enumerants for refering to display lists. */ +typedef enum { + RESERVED, BODY_SIDE, BODY_EDGE, BODY_WHOLE, ARM_SIDE, ARM_EDGE, ARM_WHOLE, + LEG_SIDE, LEG_EDGE, LEG_WHOLE, EYE_SIDE, EYE_EDGE, EYE_WHOLE +} displayLists; + +static void +makeDinosaur(void) +{ + extrudeSolidFromPolygon(body, sizeof(body), bodyWidth, + BODY_SIDE, BODY_EDGE, BODY_WHOLE); + extrudeSolidFromPolygon(arm, sizeof(arm), bodyWidth / 4, + ARM_SIDE, ARM_EDGE, ARM_WHOLE); + extrudeSolidFromPolygon(leg, sizeof(leg), bodyWidth / 2, + LEG_SIDE, LEG_EDGE, LEG_WHOLE); + extrudeSolidFromPolygon(eye, sizeof(eye), bodyWidth + 0.2, + EYE_SIDE, EYE_EDGE, EYE_WHOLE); +} + +static void +drawDinosaur(void) + +{ + glPushMatrix(); + /* Translate the dinosaur to be at (0,8,0). */ + glTranslatef(-8, 0, -bodyWidth / 2); + glTranslatef(0.0, jump, 0.0); + glMaterialfv(GL_FRONT, GL_DIFFUSE, skinColor); + glCallList(BODY_WHOLE); + glTranslatef(0.0, 0.0, bodyWidth); + glCallList(ARM_WHOLE); + glCallList(LEG_WHOLE); + glTranslatef(0.0, 0.0, -bodyWidth - bodyWidth / 4); + glCallList(ARM_WHOLE); + glTranslatef(0.0, 0.0, -bodyWidth / 4); + glCallList(LEG_WHOLE); + glTranslatef(0.0, 0.0, bodyWidth / 2 - 0.1); + glMaterialfv(GL_FRONT, GL_DIFFUSE, eyeColor); + glCallList(EYE_WHOLE); + glPopMatrix(); +} + +static GLfloat floorVertices[4][3] = { + { -20.0, 0.0, 20.0 }, + { 20.0, 0.0, 20.0 }, + { 20.0, 0.0, -20.0 }, + { -20.0, 0.0, -20.0 }, +}; + +/* Draw a floor (possibly textured). */ +static void +drawFloor(void) +{ + glDisable(GL_LIGHTING); + + if (useTexture) { + glEnable(GL_TEXTURE_2D); + } + + glBegin(GL_QUADS); + glTexCoord2f(0.0, 0.0); + glVertex3fv(floorVertices[0]); + glTexCoord2f(0.0, 16.0); + glVertex3fv(floorVertices[1]); + glTexCoord2f(16.0, 16.0); + glVertex3fv(floorVertices[2]); + glTexCoord2f(16.0, 0.0); + glVertex3fv(floorVertices[3]); + glEnd(); + + if (useTexture) { + glDisable(GL_TEXTURE_2D); + } + + glEnable(GL_LIGHTING); +} + +static GLfloat floorPlane[4]; +static GLfloat floorShadow[4][4]; + +static void +redraw(void) +{ + int start, end; + + if (reportSpeed) { + start = glutGet(GLUT_ELAPSED_TIME); + } + + /* Clear; default stencil clears to zero. */ + if ((stencilReflection && renderReflection) || (stencilShadow && renderShadow)) { + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); + } else { + /* Avoid clearing stencil when not using it. */ + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + } + + /* Reposition the light source. */ + lightPosition[0] = 12*cos(lightAngle); + lightPosition[1] = lightHeight; + lightPosition[2] = 12*sin(lightAngle); + if (directionalLight) { + lightPosition[3] = 0.0; + } else { + lightPosition[3] = 1.0; + } + + shadowMatrix(floorShadow, floorPlane, lightPosition); + + glPushMatrix(); + /* Perform scene rotations based on user mouse input. */ + glRotatef(angle2, 1.0, 0.0, 0.0); + glRotatef(angle, 0.0, 1.0, 0.0); + + /* Tell GL new light source position. */ + glLightfv(GL_LIGHT0, GL_POSITION, lightPosition); + + if (renderReflection) { + if (stencilReflection) { + /* We can eliminate the visual "artifact" of seeing the "flipped" + dinosaur underneath the floor by using stencil. The idea is + draw the floor without color or depth update but so that + a stencil value of one is where the floor will be. Later when + rendering the dinosaur reflection, we will only update pixels + with a stencil value of 1 to make sure the reflection only + lives on the floor, not below the floor. */ + + /* Don't update color or depth. */ + glDisable(GL_DEPTH_TEST); + glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); + + /* Draw 1 into the stencil buffer. */ + glEnable(GL_STENCIL_TEST); + glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE); + glStencilFunc(GL_ALWAYS, 1, 0xffffffff); + + /* Now render floor; floor pixels just get their stencil set to 1. */ + drawFloor(); + + /* Re-enable update of color and depth. */ + glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); + glEnable(GL_DEPTH_TEST); + + /* Now, only render where stencil is set to 1. */ + glStencilFunc(GL_EQUAL, 1, 0xffffffff); /* draw if ==1 */ + glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); + } + + glPushMatrix(); + + /* The critical reflection step: Reflect dinosaur through the floor + (the Y=0 plane) to make a relection. */ + glScalef(1.0, -1.0, 1.0); + + /* Reflect the light position. */ + glLightfv(GL_LIGHT0, GL_POSITION, lightPosition); + + /* To avoid our normals getting reversed and hence botched lighting + on the reflection, turn on normalize. */ + glEnable(GL_NORMALIZE); + glCullFace(GL_FRONT); + + /* Draw the reflected dinosaur. */ + drawDinosaur(); + + /* Disable noramlize again and re-enable back face culling. */ + glDisable(GL_NORMALIZE); + glCullFace(GL_BACK); + + glPopMatrix(); + + /* Switch back to the unreflected light position. */ + glLightfv(GL_LIGHT0, GL_POSITION, lightPosition); + + if (stencilReflection) { + glDisable(GL_STENCIL_TEST); + } + } + + /* Back face culling will get used to only draw either the top or the + bottom floor. This let's us get a floor with two distinct + appearances. The top floor surface is reflective and kind of red. + The bottom floor surface is not reflective and blue. */ + + /* Draw "bottom" of floor in blue. */ + glFrontFace(GL_CW); /* Switch face orientation. */ + glColor4f(0.1, 0.1, 0.7, 1.0); + drawFloor(); + glFrontFace(GL_CCW); + + if (renderShadow) { + if (stencilShadow) { + /* Draw the floor with stencil value 3. This helps us only + draw the shadow once per floor pixel (and only on the + floor pixels). */ + glEnable(GL_STENCIL_TEST); + glStencilFunc(GL_ALWAYS, 3, 0xffffffff); + glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE); + } + } + + /* Draw "top" of floor. Use blending to blend in reflection. */ + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glColor4f(0.7, 0.0, 0.0, 0.3); + glColor4f(1.0, 1.0, 1.0, 0.3); + drawFloor(); + glDisable(GL_BLEND); + + if (renderDinosaur) { + /* Draw "actual" dinosaur, not its reflection. */ + drawDinosaur(); + } + + if (renderShadow) { + + /* Render the projected shadow. */ + + if (stencilShadow) { + + /* Now, only render where stencil is set above 2 (ie, 3 where + the top floor is). Update stencil with 2 where the shadow + gets drawn so we don't redraw (and accidently reblend) the + shadow). */ + glStencilFunc(GL_LESS, 2, 0xffffffff); /* draw if ==1 */ + glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE); + } + + /* To eliminate depth buffer artifacts, we use polygon offset + to raise the depth of the projected shadow slightly so + that it does not depth buffer alias with the floor. */ + if (offsetShadow) { + switch (polygonOffsetVersion) { + case EXTENSION: +#ifdef GL_EXT_polygon_offset + glEnable(GL_POLYGON_OFFSET_EXT); + break; +#endif +#ifdef GL_VERSION_1_1 + case ONE_DOT_ONE: + glEnable(GL_POLYGON_OFFSET_FILL); + break; +#endif + case MISSING: + /* Oh well. */ + break; + } + } + + /* Render 50% black shadow color on top of whatever the + floor appareance is. */ + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glDisable(GL_LIGHTING); /* Force the 50% black. */ + glColor4f(0.0, 0.0, 0.0, 0.5); + + glPushMatrix(); + /* Project the shadow. */ + glMultMatrixf((GLfloat *) floorShadow); + drawDinosaur(); + glPopMatrix(); + + glDisable(GL_BLEND); + glEnable(GL_LIGHTING); + + if (offsetShadow) { + switch (polygonOffsetVersion) { +#ifdef GL_EXT_polygon_offset + case EXTENSION: + glDisable(GL_POLYGON_OFFSET_EXT); + break; +#endif +#ifdef GL_VERSION_1_1 + case ONE_DOT_ONE: + glDisable(GL_POLYGON_OFFSET_FILL); + break; +#endif + case MISSING: + /* Oh well. */ + break; + } + } + if (stencilShadow) { + glDisable(GL_STENCIL_TEST); + } + } + + glPushMatrix(); + glDisable(GL_LIGHTING); + glColor3f(1.0, 1.0, 0.0); + if (directionalLight) { + /* Draw an arrowhead. */ + glDisable(GL_CULL_FACE); + glTranslatef(lightPosition[0], lightPosition[1], lightPosition[2]); + glRotatef(lightAngle * -180.0 / M_PI, 0, 1, 0); + glRotatef(atan(lightHeight/12) * 180.0 / M_PI, 0, 0, 1); + glBegin(GL_TRIANGLE_FAN); + glVertex3f(0, 0, 0); + glVertex3f(2, 1, 1); + glVertex3f(2, -1, 1); + glVertex3f(2, -1, -1); + glVertex3f(2, 1, -1); + glVertex3f(2, 1, 1); + glEnd(); + /* Draw a white line from light direction. */ + glColor3f(1.0, 1.0, 1.0); + glBegin(GL_LINES); + glVertex3f(0, 0, 0); + glVertex3f(5, 0, 0); + glEnd(); + glEnable(GL_CULL_FACE); + } else { + /* Draw a yellow ball at the light source. */ + glTranslatef(lightPosition[0], lightPosition[1], lightPosition[2]); + glutSolidSphere(1.0, 5, 5); + } + glEnable(GL_LIGHTING); + glPopMatrix(); + + glPopMatrix(); + + if (reportSpeed) { + glFinish(); + end = glutGet(GLUT_ELAPSED_TIME); + printf("Speed %.3g frames/sec (%d ms)\n", 1000.0/(end-start), end-start); + } + + glutSwapBuffers(); +} + +/* ARGSUSED2 */ +static void +mouse(int button, int state, int x, int y) +{ + if (button == GLUT_LEFT_BUTTON) { + if (state == GLUT_DOWN) { + moving = 1; + startx = x; + starty = y; + } + if (state == GLUT_UP) { + moving = 0; + } + } + if (button == GLUT_MIDDLE_BUTTON) { + if (state == GLUT_DOWN) { + lightMoving = 1; + lightStartX = x; + lightStartY = y; + } + if (state == GLUT_UP) { + lightMoving = 0; + } + } +} + +/* ARGSUSED1 */ +static void +motion(int x, int y) +{ + if (moving) { + angle = angle + (x - startx); + angle2 = angle2 + (y - starty); + startx = x; + starty = y; + glutPostRedisplay(); + } + if (lightMoving) { + lightAngle += (x - lightStartX)/40.0; + lightHeight += (lightStartY - y)/20.0; + lightStartX = x; + lightStartY = y; + glutPostRedisplay(); + } +} + +/* Advance time varying state when idle callback registered. */ +static void +idle(void) +{ + static float time = 0.0; + + time = glutGet(GLUT_ELAPSED_TIME) / 500.0; + + jump = 4.0 * fabs(sin(time)*0.5); + if (!lightMoving) { + lightAngle += 0.03; + } + glutPostRedisplay(); +} + +enum { + M_NONE, M_MOTION, M_LIGHT, M_TEXTURE, M_SHADOWS, M_REFLECTION, M_DINOSAUR, + M_STENCIL_REFLECTION, M_STENCIL_SHADOW, M_OFFSET_SHADOW, + M_POSITIONAL, M_DIRECTIONAL, M_PERFORMANCE +}; + +static void +controlLights(int value) +{ + switch (value) { + case M_NONE: + return; + case M_MOTION: + animation = 1 - animation; + if (animation) { + glutIdleFunc(idle); + } else { + glutIdleFunc(NULL); + } + break; + case M_LIGHT: + lightSwitch = !lightSwitch; + if (lightSwitch) { + glEnable(GL_LIGHT0); + } else { + glDisable(GL_LIGHT0); + } + break; + case M_TEXTURE: + useTexture = !useTexture; + break; + case M_SHADOWS: + renderShadow = 1 - renderShadow; + break; + case M_REFLECTION: + renderReflection = 1 - renderReflection; + break; + case M_DINOSAUR: + renderDinosaur = 1 - renderDinosaur; + break; + case M_STENCIL_REFLECTION: + stencilReflection = 1 - stencilReflection; + break; + case M_STENCIL_SHADOW: + stencilShadow = 1 - stencilShadow; + break; + case M_OFFSET_SHADOW: + offsetShadow = 1 - offsetShadow; + break; + case M_POSITIONAL: + directionalLight = 0; + break; + case M_DIRECTIONAL: + directionalLight = 1; + break; + case M_PERFORMANCE: + reportSpeed = 1 - reportSpeed; + break; + } + glutPostRedisplay(); +} + +/* When not visible, stop animating. Restart when visible again. */ +static void +visible(int vis) +{ + if (vis == GLUT_VISIBLE) { + if (animation) + glutIdleFunc(idle); + } else { + if (!animation) + glutIdleFunc(NULL); + } +} + +/* Press any key to redraw; good when motion stopped and + performance reporting on. */ +/* ARGSUSED */ +static void +key(unsigned char c, int x, int y) +{ + if (c == 27) { + exit(0); /* IRIS GLism, Escape quits. */ + } + glutPostRedisplay(); +} + +/* Press any key to redraw; good when motion stopped and + performance reporting on. */ +/* ARGSUSED */ +static void +special(int k, int x, int y) +{ + glutPostRedisplay(); +} + +static int +supportsOneDotOne(void) +{ + const char *version; + int major, minor; + + version = (char *) glGetString(GL_VERSION); + if (sscanf(version, "%d.%d", &major, &minor) == 2) + return major >= 1 && minor >= 1; + return 0; /* OpenGL version string malformed! */ +} + +int +main(int argc, char **argv) +{ + int i; + + glutInit(&argc, argv); + + for (i=1; i=2 rgb double depth"); +#endif + + glutCreateWindow("Shadowy Leapin' Lizards"); + + if (glutGet(GLUT_WINDOW_STENCIL_SIZE) <= 1) { + printf("dinoshade: Sorry, I need at least 2 bits of stencil.\n"); + exit(1); + } + + /* Register GLUT callbacks. */ + glutDisplayFunc(redraw); + glutMouseFunc(mouse); + glutMotionFunc(motion); + glutVisibilityFunc(visible); + glutKeyboardFunc(key); + glutSpecialFunc(special); + + glutCreateMenu(controlLights); + + glutAddMenuEntry("Toggle motion", M_MOTION); + glutAddMenuEntry("-----------------------", M_NONE); + glutAddMenuEntry("Toggle light", M_LIGHT); + glutAddMenuEntry("Toggle texture", M_TEXTURE); + glutAddMenuEntry("Toggle shadows", M_SHADOWS); + glutAddMenuEntry("Toggle reflection", M_REFLECTION); + glutAddMenuEntry("Toggle dinosaur", M_DINOSAUR); + glutAddMenuEntry("-----------------------", M_NONE); + glutAddMenuEntry("Toggle reflection stenciling", M_STENCIL_REFLECTION); + glutAddMenuEntry("Toggle shadow stenciling", M_STENCIL_SHADOW); + glutAddMenuEntry("Toggle shadow offset", M_OFFSET_SHADOW); + glutAddMenuEntry("----------------------", M_NONE); + glutAddMenuEntry("Positional light", M_POSITIONAL); + glutAddMenuEntry("Directional light", M_DIRECTIONAL); + glutAddMenuEntry("-----------------------", M_NONE); + glutAddMenuEntry("Toggle performance", M_PERFORMANCE); + glutAttachMenu(GLUT_RIGHT_BUTTON); + makeDinosaur(); + +#ifdef GL_VERSION_1_1 + if (supportsOneDotOne() && !forceExtension) { + polygonOffsetVersion = ONE_DOT_ONE; + glPolygonOffset(-2.0, -9.0); + } else +#endif + { +#ifdef GL_EXT_polygon_offset + /* check for the polygon offset extension */ + if (glutExtensionSupported("GL_EXT_polygon_offset")) { + polygonOffsetVersion = EXTENSION; + glPolygonOffsetEXT(-2.0, -0.002); + } else +#endif + { + polygonOffsetVersion = MISSING; + printf("\ndinoshine: Missing polygon offset.\n"); + printf(" Expect shadow depth aliasing artifacts.\n\n"); + } + } + + glEnable(GL_CULL_FACE); + glEnable(GL_DEPTH_TEST); + glEnable(GL_TEXTURE_2D); + glLineWidth(3.0); + + glMatrixMode(GL_PROJECTION); + gluPerspective( /* field of view in degree */ 40.0, + /* aspect ratio */ 1.0, + /* Z near */ 20.0, /* Z far */ 100.0); + glMatrixMode(GL_MODELVIEW); + gluLookAt(0.0, 8.0, 60.0, /* eye is at (0,8,60) */ + 0.0, 8.0, 0.0, /* center is at (0,8,0) */ + 0.0, 1.0, 0.); /* up is in postivie Y direction */ + + glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 1); + glLightfv(GL_LIGHT0, GL_DIFFUSE, lightColor); + glLightf(GL_LIGHT0, GL_CONSTANT_ATTENUATION, 0.1); + glLightf(GL_LIGHT0, GL_LINEAR_ATTENUATION, 0.05); + glEnable(GL_LIGHT0); + glEnable(GL_LIGHTING); + + makeFloorTexture(); + + /* Setup floor plane for projected shadow calculations. */ + findPlane(floorPlane, floorVertices[1], floorVertices[2], floorVertices[3]); + + glutMainLoop(); + return 0; /* ANSI C requires main to return int. */ +} diff --git a/progs/tests/ext422square.c b/progs/tests/ext422square.c new file mode 100644 index 00000000000..6533514d697 --- /dev/null +++ b/progs/tests/ext422square.c @@ -0,0 +1,258 @@ +/* + * Exercise the EXT_422_pixels extension, a less convenient + * alternative to MESA_ycbcr_texture. Requires ARB_fragment_program + * to perform the final YUV->RGB conversion. + * + * Brian Paul 13 September 2002 + * Keith Whitwell 30 November 2004 + */ + + +#include +#include +#include +#include +#define GL_GLEXT_PROTOTYPES +#include +#include + +#include "../util/readtex.c" /* I know, this is a hack. */ + +#define TEXTURE_FILE "../images/tile.rgb" + +static GLfloat Xrot = 0, Yrot = 0, Zrot = 0; +static GLint ImgWidth, ImgHeight; +static GLushort *ImageYUV = NULL; +static const GLuint yuvObj = 100; +static const GLuint rgbObj = 101; + +static void Init( int argc, char *argv[] ); + +static void DrawObject(void) +{ + glBegin(GL_QUADS); + + glTexCoord2f(0, 0); + glVertex2f(-1.0, -1.0); + + glTexCoord2f(1, 0); + glVertex2f(1.0, -1.0); + + glTexCoord2f(1, 1); + glVertex2f(1.0, 1.0); + + glTexCoord2f(0, 1); + glVertex2f(-1.0, 1.0); + + glEnd(); +} + +static void Display( void ) +{ + static int firsttime = 1; + + if (firsttime) { + firsttime = 0; + Init( 0, 0 ); /* don't ask */ + } + + glClear( GL_COLOR_BUFFER_BIT ); + glBindTexture(GL_TEXTURE_2D, yuvObj); + + glPushMatrix(); + glEnable(GL_FRAGMENT_PROGRAM_ARB); + glTranslatef( -1.1, 0.0, -15.0 ); + glRotatef(Xrot, 1.0, 0.0, 0.0); + glRotatef(Yrot, 0.0, 1.0, 0.0); + glRotatef(Zrot, 0.0, 0.0, 1.0); + glBindTexture(GL_TEXTURE_2D, yuvObj); + DrawObject(); + glPopMatrix(); + + glPushMatrix(); + glDisable(GL_FRAGMENT_PROGRAM_ARB); + glTranslatef( 1.1, 0.0, -15.0 ); + glRotatef(Xrot, 1.0, 0.0, 0.0); + glRotatef(Yrot, 0.0, 1.0, 0.0); + glRotatef(Zrot, 0.0, 0.0, 1.0); + glBindTexture(GL_TEXTURE_2D, rgbObj); + DrawObject(); + glPopMatrix(); + + glutSwapBuffers(); +} + + +static void Reshape( int width, int height ) +{ + glViewport( 0, 0, width, height ); + glMatrixMode( GL_PROJECTION ); + glLoadIdentity(); + glFrustum( -1.1, 1.1, -1.1, 1.1, 10.0, 100.0 ); + glMatrixMode( GL_MODELVIEW ); + glLoadIdentity(); + glTranslatef( 0.0, 0.0, -15.0 ); +} + + +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 ) +{ + float 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(); +} + + + + +/* #define LINEAR_FILTER */ + +static void Init( int argc, char *argv[] ) +{ + const char *file; + const GLfloat yuvtorgb[16] = { + 1.164, 1.164, 1.164, 0, + 0, -.391, 2.018, 0, + 1.596, -.813, 0.0, 0, + (-.0625*1.164 + -.5*1.596), (-.0625*1.164 + -.5*-.813 + -.5*-.391), (-.0625*1.164 + -.5*2.018), 1 + }; + + if (!glutExtensionSupported("GL_ARB_fragment_program")) { + printf("Error: GL_ARB_fragment_program not supported!\n"); + exit(1); + } + + if (!glutExtensionSupported("GL_EXT_422_pixels")) { + printf("Error: GL_EXT_422_pixels not supported!\n"); + exit(1); + } + + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + + file = TEXTURE_FILE; + + /* Load the texture as YCbCr. + */ + glBindTexture(GL_TEXTURE_2D, yuvObj); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + + ImageYUV = LoadYUVImage(file, &ImgWidth, &ImgHeight ); + if (!ImageYUV) { + printf("Couldn't read %s\n", TEXTURE_FILE); + exit(0); + } + + glTexImage2D(GL_TEXTURE_2D, 0, + GL_RGB, + ImgWidth, ImgHeight, 0, + GL_422_EXT, + GL_UNSIGNED_BYTE, ImageYUV); + + glEnable(GL_TEXTURE_2D); + + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + + { + static const char *modulateYUV = + "!!ARBfp1.0\n" + "TEMP R0;\n" + "TEX R0, fragment.texcoord[0], texture[0], 2D; \n" + + "ADD R0, R0, {-0.0625, -0.5, -0.5, 0.0}; \n" + "DP3 result.color.x, R0, {1.164, 1.596, 0.0}; \n" + "DP3 result.color.y, R0, {1.164, -0.813, -0.391}; \n" + "DP3 result.color.z, R0, {1.164, 0.0, 2.018}; \n" + "MOV result.color.w, R0.w; \n" + + "END" + ; + + GLuint modulateProg; + + + /* Setup the fragment program */ + glGenProgramsARB(1, &modulateProg); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(modulateYUV), (const GLubyte *)modulateYUV); + + printf("glGetError = 0x%x\n", (int) glGetError()); + printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + assert(glIsProgramARB(modulateProg)); + + } + + /* Now the same, but use a color matrix to do the conversion at + * upload time: + */ + glBindTexture(GL_TEXTURE_2D, rgbObj); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + + glMatrixMode( GL_COLOR_MATRIX ); + glLoadMatrixf( yuvtorgb ); + + glTexImage2D(GL_TEXTURE_2D, 0, + GL_RGB, + ImgWidth, ImgHeight, 0, + GL_422_EXT, + GL_UNSIGNED_BYTE, ImageYUV); + + glLoadIdentity(); + glMatrixMode( GL_MODELVIEW ); + + glEnable(GL_TEXTURE_2D); + + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + + + glShadeModel(GL_FLAT); + glClearColor(0.3, 0.3, 0.4, 1.0); +} + + +int main( int argc, char *argv[] ) +{ + glutInit( &argc, argv ); + glutInitWindowSize( 300, 300 ); + glutInitWindowPosition( 0, 0 ); + glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE ); + glutCreateWindow(argv[0] ); + glutReshapeFunc( Reshape ); + glutKeyboardFunc( Key ); + glutSpecialFunc( SpecialKey ); + glutDisplayFunc( Display ); + glutMainLoop(); + return 0; +} diff --git a/progs/tests/fbotest1.c b/progs/tests/fbotest1.c new file mode 100644 index 00000000000..ed72ab16dd8 --- /dev/null +++ b/progs/tests/fbotest1.c @@ -0,0 +1,204 @@ +/* + * Test GL_EXT_framebuffer_object + * + * Brian Paul + * 7 Feb 2005 + */ + + +#define GL_GLEXT_PROTOTYPES +#include +#include +#include +#include +#include + +static int Width = 400, Height = 400; +static GLuint MyFB, MyRB; + + +static void +CheckError(int line) +{ + GLenum err = glGetError(); + if (err) { + printf("GL Error 0x%x at line %d\n", (int) err, line); + } +} + + +static void +Display( void ) +{ + GLubyte *buffer = malloc(Width * Height * 4); + GLenum status; + + /* draw to user framebuffer */ + glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, MyFB); + glDrawBuffer(GL_COLOR_ATTACHMENT1_EXT); + glReadBuffer(GL_COLOR_ATTACHMENT1_EXT); + + status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT); + if (status != GL_FRAMEBUFFER_COMPLETE_EXT) { + printf("Framebuffer incomplete!!!\n"); + } + + glClearColor(0.5, 0.5, 1.0, 0.0); + glClear( GL_COLOR_BUFFER_BIT ); + + glBegin(GL_POLYGON); + glColor3f(1, 0, 0); + glVertex2f(-1, -1); + glColor3f(0, 1, 0); + glVertex2f(1, -1); + glColor3f(0, 0, 1); + glVertex2f(0, 1); + glEnd(); + + /* read from user framebuffer */ + glReadPixels(0, 0, Width, Height, GL_RGBA, GL_UNSIGNED_BYTE, buffer); + + /* draw to window */ + glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); + glWindowPos2iARB(0, 0); + glDrawPixels(Width, Height, GL_RGBA, GL_UNSIGNED_BYTE, buffer); + + free(buffer); + glutSwapBuffers(); + CheckError(__LINE__); +} + + +static void +Reshape( int width, int height ) +{ +#if 0 + float ar = (float) width / (float) height; +#endif + glViewport( 0, 0, width, height ); + glMatrixMode( GL_PROJECTION ); + glLoadIdentity(); +#if 0 + glFrustum( -ar, ar, -1.0, 1.0, 5.0, 25.0 ); +#else + glOrtho(-1.0, 1.0, -1.0, 1.0, 5.0, 25.0 ); +#endif + glMatrixMode( GL_MODELVIEW ); + glLoadIdentity(); + glTranslatef( 0.0, 0.0, -15.0 ); + Width = width; + Height = height; + glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGB, Width, Height); +} + + +static void +CleanUp(void) +{ + glDeleteFramebuffersEXT(1, &MyFB); + glDeleteRenderbuffersEXT(1, &MyRB); + assert(!glIsFramebufferEXT(MyFB)); + assert(!glIsRenderbufferEXT(MyRB)); + exit(0); +} + + +static void +Key( unsigned char key, int x, int y ) +{ + (void) x; + (void) y; + switch (key) { + case 27: + CleanUp(); + break; + } + glutPostRedisplay(); +} + + +static void +Init( void ) +{ + GLint i; + + if (!glutExtensionSupported("GL_EXT_framebuffer_object")) { + printf("GL_EXT_framebuffer_object not found!\n"); + /*exit(0);*/ + } + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + glGenFramebuffersEXT(1, &MyFB); + assert(MyFB); + assert(!glIsFramebufferEXT(MyFB)); + glDeleteFramebuffersEXT(1, &MyFB); + assert(!glIsFramebufferEXT(MyFB)); + /* Note, continue to use MyFB below */ + + glGenRenderbuffersEXT(1, &MyRB); + assert(MyRB); + assert(!glIsRenderbufferEXT(MyRB)); + glDeleteRenderbuffersEXT(1, &MyRB); + assert(!glIsRenderbufferEXT(MyRB)); + MyRB = 42; /* an arbitrary ID */ + + glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, MyFB); + assert(glIsFramebufferEXT(MyFB)); + glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, MyRB); + assert(glIsRenderbufferEXT(MyRB)); + + glGetIntegerv(GL_RENDERBUFFER_BINDING_EXT, &i); + assert(i == MyRB); + + glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, &i); + assert(i == MyFB); + + CheckError(__LINE__); + glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT1_EXT, + GL_RENDERBUFFER_EXT, MyRB); + + glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGB, Width, Height); + + CheckError(__LINE__); + + { + GLint r, g, b, a; + glGetRenderbufferParameterivEXT(GL_RENDERBUFFER_EXT, + GL_RENDERBUFFER_RED_SIZE_EXT, &r); + glGetRenderbufferParameterivEXT(GL_RENDERBUFFER_EXT, + GL_RENDERBUFFER_GREEN_SIZE_EXT, &g); + glGetRenderbufferParameterivEXT(GL_RENDERBUFFER_EXT, + GL_RENDERBUFFER_BLUE_SIZE_EXT, &b); + glGetRenderbufferParameterivEXT(GL_RENDERBUFFER_EXT, + GL_RENDERBUFFER_ALPHA_SIZE_EXT, &a); + CheckError(__LINE__); + printf("renderbuffer RGBA sizes = %d %d %d %d\n", r, g, b, a); + + glGetIntegerv(GL_RED_BITS, &r); + glGetIntegerv(GL_GREEN_BITS, &g); + glGetIntegerv(GL_BLUE_BITS, &b); + glGetIntegerv(GL_ALPHA_BITS, &a); + printf("Visual RGBA sizes = %d %d %d %d\n", r, g, b, a); + } + + /* restore to default */ + glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); + CheckError(__LINE__); +} + + +int +main( int argc, char *argv[] ) +{ + glutInit( &argc, argv ); + glutInitWindowPosition( 0, 0 ); + glutInitWindowSize(Width, Height); + glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE ); + glutCreateWindow(argv[0]); + glutReshapeFunc( Reshape ); + glutKeyboardFunc( Key ); + glutDisplayFunc( Display ); + Init(); + glutMainLoop(); + return 0; +} diff --git a/progs/tests/fbotest2.c b/progs/tests/fbotest2.c new file mode 100644 index 00000000000..c3117b0f767 --- /dev/null +++ b/progs/tests/fbotest2.c @@ -0,0 +1,199 @@ +/* + * Test GL_EXT_framebuffer_object + * + * Brian Paul + * 19 Mar 2006 + */ + + +#define GL_GLEXT_PROTOTYPES +#include +#include +#include +#include +#include + +static int Width = 400, Height = 400; +static GLuint MyFB, ColorRb, DepthRb; +static GLboolean Animate = GL_TRUE; +static GLfloat Rotation = 0.0; + + +static void +CheckError(int line) +{ + GLenum err = glGetError(); + if (err) { + printf("fbotest2: GL Error 0x%x at line %d\n", (int) err, line); + } +} + + +static void +Display( void ) +{ + GLubyte *buffer = malloc(Width * Height * 4); + GLenum status; + + CheckError(__LINE__); + + /* draw to user framebuffer */ + glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, MyFB); + glDrawBuffer(GL_COLOR_ATTACHMENT1_EXT); + glReadBuffer(GL_COLOR_ATTACHMENT1_EXT); + + status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT); + if (status != GL_FRAMEBUFFER_COMPLETE_EXT) { + printf("fbotest2: Error: Framebuffer is incomplete!!!\n"); + } + + CheckError(__LINE__); + + glClearColor(0.5, 0.5, 1.0, 0.0); + glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); + + glEnable(GL_DEPTH_TEST); + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + + glPushMatrix(); + glRotatef(30.0, 1, 0, 0); + glRotatef(Rotation, 0, 1, 0); + glutSolidTeapot(2.0); + glPopMatrix(); + + /* read from user framebuffer */ + glReadPixels(0, 0, Width, Height, GL_RGBA, GL_UNSIGNED_BYTE, buffer); + + /* draw to window */ + glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); + glWindowPos2iARB(0, 0); + glDrawPixels(Width, Height, GL_RGBA, GL_UNSIGNED_BYTE, buffer); + + free(buffer); + glutSwapBuffers(); + CheckError(__LINE__); +} + + +static void +Reshape( int width, int height ) +{ + float ar = (float) width / (float) height; + + glViewport( 0, 0, width, height ); + glMatrixMode( GL_PROJECTION ); + glLoadIdentity(); + glFrustum( -ar, ar, -1.0, 1.0, 5.0, 25.0 ); + + glMatrixMode( GL_MODELVIEW ); + glLoadIdentity(); + glTranslatef( 0.0, 0.0, -15.0 ); + + glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, ColorRb); + glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGB, width, height); + glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, DepthRb); + glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT, + width, height); + + Width = width; + Height = height; +} + + +static void +CleanUp(void) +{ + glDeleteFramebuffersEXT(1, &MyFB); + glDeleteRenderbuffersEXT(1, &ColorRb); + glDeleteRenderbuffersEXT(1, &DepthRb); + assert(!glIsFramebufferEXT(MyFB)); + assert(!glIsRenderbufferEXT(ColorRb)); + assert(!glIsRenderbufferEXT(DepthRb)); + exit(0); +} + + +static void +Idle(void) +{ + Rotation = glutGet(GLUT_ELAPSED_TIME) * 0.1; + glutPostRedisplay(); +} + + +static void +Key( unsigned char key, int x, int y ) +{ + (void) x; + (void) y; + switch (key) { + case 'a': + Animate = !Animate; + if (Animate) + glutIdleFunc(Idle); + else + glutIdleFunc(NULL); + break; + case 27: + CleanUp(); + break; + } + glutPostRedisplay(); +} + + +static void +Init( void ) +{ + if (!glutExtensionSupported("GL_EXT_framebuffer_object")) { + printf("fbotest2: GL_EXT_framebuffer_object not found!\n"); + exit(0); + } + printf("fbotest2: GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + glGenFramebuffersEXT(1, &MyFB); + glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, MyFB); + assert(glIsFramebufferEXT(MyFB)); + + /* set color buffer */ + glGenRenderbuffersEXT(1, &ColorRb); + glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, ColorRb); + assert(glIsRenderbufferEXT(ColorRb)); + glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT1_EXT, + GL_RENDERBUFFER_EXT, ColorRb); + glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGB, Width, Height); + + /* setup depth buffer */ + glGenRenderbuffersEXT(1, &DepthRb); + glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, DepthRb); + assert(glIsRenderbufferEXT(DepthRb)); + glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, + GL_RENDERBUFFER_EXT, DepthRb); + glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT, Width, Height); + + CheckError(__LINE__); + + /* restore to default */ + glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); + CheckError(__LINE__); +} + + +int +main( int argc, char *argv[] ) +{ + glutInit( &argc, argv ); + glutInitWindowPosition( 0, 0 ); + glutInitWindowSize(Width, Height); + glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE ); + glutCreateWindow(argv[0]); + glutReshapeFunc( Reshape ); + glutKeyboardFunc( Key ); + glutDisplayFunc( Display ); + if (Animate) + glutIdleFunc(Idle); + Init(); + glutMainLoop(); + return 0; +} diff --git a/progs/tests/fbotexture.c b/progs/tests/fbotexture.c new file mode 100644 index 00000000000..13a29db3f35 --- /dev/null +++ b/progs/tests/fbotexture.c @@ -0,0 +1,404 @@ +/* + * Test GL_EXT_framebuffer_object render-to-texture + * + * Draw a teapot into a texture image with stenciling. + * Then draw a textured quad using that texture. + * + * Brian Paul + * 18 Apr 2005 + */ + + +#define GL_GLEXT_PROTOTYPES +#include +#include +#include +#include +#include +#include + +/* For debug */ +#define DEPTH 1 +#define STENCIL 1 +#define DRAW 1 + + +static int Width = 400, Height = 400; + +static GLenum TexTarget = GL_TEXTURE_2D; /*GL_TEXTURE_RECTANGLE_ARB;*/ +static int TexWidth = 512, TexHeight = 512; +/*static int TexWidth = 600, TexHeight = 600;*/ + +static GLuint MyFB; +static GLuint TexObj; +static GLuint DepthRB, StencilRB; +static GLboolean Anim = GL_FALSE; +static GLfloat Rot = 0.0; +static GLboolean UsePackedDepthStencil = GL_FALSE; +static GLuint TextureLevel = 1; /* which texture level to render to */ +static GLenum TexIntFormat = GL_RGB; /* either GL_RGB or GL_RGBA */ + + +static void +CheckError(int line) +{ + GLenum err = glGetError(); + if (err) { + printf("GL Error 0x%x at line %d\n", (int) err, line); + } +} + + +static void +Idle(void) +{ + Rot = glutGet(GLUT_ELAPSED_TIME) * 0.1; + glutPostRedisplay(); +} + + +static void +RenderTexture(void) +{ + GLenum status; + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-1.0, 1.0, -1.0, 1.0, 5.0, 25.0); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTranslatef(0.0, 0.0, -15.0); + + /* draw to texture image */ + glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, MyFB); + + status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT); + if (status != GL_FRAMEBUFFER_COMPLETE_EXT) { + printf("Framebuffer incomplete!!!\n"); + } + + glViewport(0, 0, TexWidth, TexHeight); + + glClearColor(0.5, 0.5, 1.0, 0.0); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); + CheckError(__LINE__); + +#if DEPTH + glEnable(GL_DEPTH_TEST); +#endif + +#if STENCIL + glEnable(GL_STENCIL_TEST); + glStencilFunc(GL_NEVER, 1, ~0); + glStencilOp(GL_REPLACE, GL_KEEP, GL_REPLACE); +#endif + + CheckError(__LINE__); + +#if DEPTH || STENCIL + /* draw diamond-shaped stencil pattern */ + glColor3f(0, 1, 0); + glBegin(GL_POLYGON); + glVertex2f(-0.2, 0.0); + glVertex2f( 0.0, -0.2); + glVertex2f( 0.2, 0.0); + glVertex2f( 0.0, 0.2); + glEnd(); +#endif + + /* draw teapot where stencil != 1 */ +#if STENCIL + glStencilFunc(GL_NOTEQUAL, 1, ~0); + glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); +#endif + + CheckError(__LINE__); + +#if 0 + glBegin(GL_POLYGON); + glColor3f(1, 0, 0); + glVertex2f(-1, -1); + glColor3f(0, 1, 0); + glVertex2f(1, -1); + glColor3f(0, 0, 1); + glVertex2f(0, 1); + glEnd(); +#else + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + glPushMatrix(); + glRotatef(0.5 * Rot, 1.0, 0.0, 0.0); + glutSolidTeapot(0.5); + glPopMatrix(); + glDisable(GL_LIGHTING); + /* + PrintStencilHistogram(TexWidth, TexHeight); + */ +#endif + + glDisable(GL_DEPTH_TEST); + glDisable(GL_STENCIL_TEST); + +#if DRAW + /* Bind normal framebuffer */ + glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); +#endif + + CheckError(__LINE__); +} + + + +static void +Display(void) +{ + float ar = (float) Width / (float) Height; + + RenderTexture(); + + /* draw textured quad in the window */ +#if DRAW + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glFrustum(-ar, ar, -1.0, 1.0, 5.0, 25.0); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTranslatef(0.0, 0.0, -7.0); + + glViewport(0, 0, Width, Height); + + glClearColor(0.25, 0.25, 0.25, 0); + glClear(GL_COLOR_BUFFER_BIT); + + glPushMatrix(); + glRotatef(Rot, 0, 1, 0); + glEnable(TexTarget); + glBindTexture(TexTarget, TexObj); + glBegin(GL_POLYGON); + glColor3f(0.25, 0.25, 0.25); + if (TexTarget == GL_TEXTURE_2D) { + glTexCoord2f(0, 0); + glVertex2f(-1, -1); + glTexCoord2f(1, 0); + glVertex2f(1, -1); + glColor3f(1.0, 1.0, 1.0); + glTexCoord2f(1, 1); + glVertex2f(1, 1); + glTexCoord2f(0, 1); + glVertex2f(-1, 1); + } + else { + assert(TexTarget == GL_TEXTURE_RECTANGLE_ARB); + glTexCoord2f(0, 0); + glVertex2f(-1, -1); + glTexCoord2f(TexWidth, 0); + glVertex2f(1, -1); + glColor3f(1.0, 1.0, 1.0); + glTexCoord2f(TexWidth, TexHeight); + glVertex2f(1, 1); + glTexCoord2f(0, TexHeight); + glVertex2f(-1, 1); + } + glEnd(); + glPopMatrix(); + glDisable(TexTarget); +#endif + + glutSwapBuffers(); + CheckError(__LINE__); +} + + +static void +Reshape(int width, int height) +{ + glViewport(0, 0, width, height); + Width = width; + Height = height; +} + + +static void +CleanUp(void) +{ +#if DEPTH + glDeleteRenderbuffersEXT(1, &DepthRB); +#endif +#if STENCIL + if (!UsePackedDepthStencil) + glDeleteRenderbuffersEXT(1, &StencilRB); +#endif + glDeleteFramebuffersEXT(1, &MyFB); + + glDeleteTextures(1, &TexObj); + + exit(0); +} + + +static void +Key(unsigned char key, int x, int y) +{ + (void) x; + (void) y; + switch (key) { + case 'a': + Anim = !Anim; + if (Anim) + glutIdleFunc(Idle); + else + glutIdleFunc(NULL); + break; + case 's': + Rot += 2.0; + break; + case 27: + CleanUp(); + break; + } + glutPostRedisplay(); +} + + +static void +Init(int argc, char *argv[]) +{ + static const GLfloat mat[4] = { 1.0, 0.5, 0.5, 1.0 }; + GLint i; + + if (!glutExtensionSupported("GL_EXT_framebuffer_object")) { + printf("GL_EXT_framebuffer_object not found!\n"); + exit(0); + } + + if (argc > 1 && strcmp(argv[1], "-ds") == 0) { + if (!glutExtensionSupported("GL_EXT_packed_depth_stencil")) { + printf("GL_EXT_packed_depth_stencil not found!\n"); + exit(0); + } + UsePackedDepthStencil = GL_TRUE; + printf("Using GL_EXT_packed_depth_stencil\n"); + } + + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + /* gen framebuffer id, delete it, do some assertions, just for testing */ + glGenFramebuffersEXT(1, &MyFB); + assert(MyFB); + assert(!glIsFramebufferEXT(MyFB)); + glDeleteFramebuffersEXT(1, &MyFB); + assert(!glIsFramebufferEXT(MyFB)); + /* Note, continue to use MyFB below */ + + glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, MyFB); + assert(glIsFramebufferEXT(MyFB)); + glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, &i); + assert(i == MyFB); + + /* Make texture object/image */ + glGenTextures(1, &TexObj); + glBindTexture(TexTarget, TexObj); + /* make two image levels */ + glTexImage2D(TexTarget, 0, TexIntFormat, TexWidth, TexHeight, 0, + GL_RGBA, GL_UNSIGNED_BYTE, NULL); + glTexImage2D(TexTarget, 1, TexIntFormat, TexWidth/2, TexHeight/2, 0, + GL_RGBA, GL_UNSIGNED_BYTE, NULL); + TexWidth = TexWidth >> TextureLevel; + TexHeight = TexHeight >> TextureLevel; + + glTexParameteri(TexTarget, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(TexTarget, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + glTexParameteri(TexTarget, GL_TEXTURE_BASE_LEVEL, TextureLevel); + glTexParameteri(TexTarget, GL_TEXTURE_MAX_LEVEL, TextureLevel); + + CheckError(__LINE__); + + /* Render color to texture */ + glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, + TexTarget, TexObj, TextureLevel); + + +#if DEPTH + /* make depth renderbuffer */ + glGenRenderbuffersEXT(1, &DepthRB); + assert(DepthRB); + assert(!glIsRenderbufferEXT(DepthRB)); + glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, DepthRB); + assert(glIsRenderbufferEXT(DepthRB)); + if (UsePackedDepthStencil) + glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_STENCIL_EXT, + TexWidth, TexHeight); + else + glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT, + TexWidth, TexHeight); + CheckError(__LINE__); + glGetRenderbufferParameterivEXT(GL_RENDERBUFFER_EXT, + GL_RENDERBUFFER_DEPTH_SIZE_EXT, &i); + CheckError(__LINE__); + printf("Depth renderbuffer size = %d bits\n", i); + assert(i > 0); + + /* attach DepthRB to MyFB */ + glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, + GL_RENDERBUFFER_EXT, DepthRB); +#endif + + CheckError(__LINE__); + +#if STENCIL + if (UsePackedDepthStencil) { + /* DepthRb is a combined depth/stencil renderbuffer */ + glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, + GL_STENCIL_ATTACHMENT_EXT, + GL_RENDERBUFFER_EXT, DepthRB); + } + else { + /* make stencil renderbuffer */ + glGenRenderbuffersEXT(1, &StencilRB); + assert(StencilRB); + assert(!glIsRenderbufferEXT(StencilRB)); + glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, StencilRB); + assert(glIsRenderbufferEXT(StencilRB)); + glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_STENCIL_INDEX, + TexWidth, TexHeight); + /* attach StencilRB to MyFB */ + glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, + GL_STENCIL_ATTACHMENT_EXT, + GL_RENDERBUFFER_EXT, StencilRB); + } + glGetRenderbufferParameterivEXT(GL_RENDERBUFFER_EXT, + GL_RENDERBUFFER_STENCIL_SIZE_EXT, &i); + CheckError(__LINE__); + printf("Stencil renderbuffer size = %d bits\n", i); + assert(i > 0); +#endif + + CheckError(__LINE__); + + /* bind regular framebuffer */ + glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); + + + /* lighting */ + glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat); +} + + +int +main(int argc, char *argv[]) +{ + glutInit(&argc, argv); + glutInitWindowPosition(0, 0); + glutInitWindowSize(Width, Height); + glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE); + glutCreateWindow(argv[0]); + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Display); + if (Anim) + glutIdleFunc(Idle); + Init(argc, argv); + glutMainLoop(); + return 0; +} diff --git a/progs/tests/floattex.c b/progs/tests/floattex.c new file mode 100644 index 00000000000..2345a49b270 --- /dev/null +++ b/progs/tests/floattex.c @@ -0,0 +1,169 @@ +/* + * Test floating point textures. + * No actual rendering, yet. + */ + + +#include +#include +#include +#include +#include + + +/* XXX - temporary */ +#ifndef GL_ARB_texture_float +#define GL_ARB_texture_float 1 +#define GL_TEXTURE_RED_TYPE_ARB 0x9000 +#define GL_TEXTURE_GREEN_TYPE_ARB 0x9001 +#define GL_TEXTURE_BLUE_TYPE_ARB 0x9002 +#define GL_TEXTURE_ALPHA_TYPE_ARB 0x9003 +#define GL_TEXTURE_LUMINANCE_TYPE_ARB 0x9004 +#define GL_TEXTURE_INTENSITY_TYPE_ARB 0x9005 +#define GL_TEXTURE_DEPTH_TYPE_ARB 0x9006 +#define GL_UNSIGNED_NORMALIZED_ARB 0x9007 +#define GL_RGBA32F_ARB 0x8814 +#define GL_RGB32F_ARB 0x8815 +#define GL_ALPHA32F_ARB 0x8816 +#define GL_INTENSITY32F_ARB 0x8817 +#define GL_LUMINANCE32F_ARB 0x8818 +#define GL_LUMINANCE_ALPHA32F_ARB 0x8819 +#define GL_RGBA16F_ARB 0x881A +#define GL_RGB16F_ARB 0x881B +#define GL_ALPHA16F_ARB 0x881C +#define GL_INTENSITY16F_ARB 0x881D +#define GL_LUMINANCE16F_ARB 0x881E +#define GL_LUMINANCE_ALPHA16F_ARB 0x881F +#endif + + +static GLboolean +CheckError( int line ) +{ + GLenum error = glGetError(); + if (error) { + char *err = (char *) gluErrorString( error ); + fprintf( stderr, "GL Error: %s at line %d\n", err, line ); + return GL_TRUE; + } + return GL_FALSE; +} + + +static void +Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + glPushMatrix(); + + glutSolidCube(2.0); + + glPopMatrix(); + + glutSwapBuffers(); +} + + +static void +Reshape(int width, int height) +{ + glViewport(0, 0, width, height); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glFrustum(-1.0, 1.0, -1.0, 1.0, 5.0, 25.0); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTranslatef(0.0, 0.0, -15.0); +} + + +static void +Key(unsigned char key, int x, int y) +{ + (void) x; + (void) y; + switch (key) { + case 27: + exit(0); + break; + } + glutPostRedisplay(); +} + + + +static void +Init(void) +{ + GLfloat tex[16][16][4]; + GLfloat tex2[16][16][4]; + GLint i, j, t; + + if (!glutExtensionSupported("GL_MESAX_texture_float")) { + printf("Sorry, this test requires GL_MESAX_texture_float\n"); + exit(1); + } + + for (i = 0; i < 16; i++) { + for (j = 0; j < 16; j++) { + GLfloat s = i / 15.0; + tex[i][j][0] = s; + tex[i][j][1] = 2.0 * s; + tex[i][j][2] = -3.0 * s; + tex[i][j][3] = 4.0 * s; + } + } + + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F_ARB, 16, 16, 0, GL_RGBA, + GL_FLOAT, tex); + CheckError(__LINE__); + + glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_RED_TYPE_ARB, &t); + assert(t == GL_FLOAT); + glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_GREEN_TYPE_ARB, &t); + assert(t == GL_FLOAT); + glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_BLUE_TYPE_ARB, &t); + assert(t == GL_FLOAT); + glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_ALPHA_TYPE_ARB, &t); + assert(t == GL_FLOAT); + + CheckError(__LINE__); + + /* read back the texture and make sure values are correct */ + glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_FLOAT, tex2); + CheckError(__LINE__); + for (i = 0; i < 16; i++) { + for (j = 0; j < 16; j++) { + if (tex[i][j][0] != tex2[i][j][0] || + tex[i][j][1] != tex2[i][j][1] || + tex[i][j][2] != tex2[i][j][2] || + tex[i][j][3] != tex2[i][j][3]) { + printf("tex[%d][%d] %g %g %g %g != tex2[%d][%d] %g %g %g %g\n", + i, j, + tex[i][j][0], tex[i][j][1], tex[i][j][2], tex[i][j][3], + i, j, + tex2[i][j][0], tex2[i][j][1], tex2[i][j][2], tex2[i][j][3]); + } + } + } + + +} + + +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); + glutDisplayFunc(Draw); + Init(); + glutMainLoop(); + return 0; +} diff --git a/progs/tests/fog.c b/progs/tests/fog.c new file mode 100644 index 00000000000..ecd9f533f99 --- /dev/null +++ b/progs/tests/fog.c @@ -0,0 +1,199 @@ +/* + * Copyright 2005 Eric Anholt + * 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 (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Authors: + * Eric Anholt + * Brian Paul (fogcoord.c used as a skeleton) + */ + +/* + * Test to exercise fog modes and for comparison with GL_EXT_fog_coord. + */ + +#define GL_GLEXT_PROTOTYPES +#include +#include +#include +#include + +static int Width = 600; +static int Height = 600; +static GLfloat Near = 0.0, Far = 1.0; +GLboolean has_fogcoord; + +static void drawString( const char *string ) +{ + glRasterPos2f(0, .5); + while ( *string ) { + glutBitmapCharacter( GLUT_BITMAP_TIMES_ROMAN_10, *string ); + string++; + } +} + +static void Display( void ) +{ + GLint i, depthi; + GLfloat fogcolor[4] = {1, 1, 1, 1}; + + glEnable(GL_FOG); + glFogfv(GL_FOG_COLOR, fogcolor); + + glClearColor(0.2, 0.2, 0.8, 0); + glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); + + glPushMatrix(); + for (i = 0; i < 6; i++) { + if (i >= 3 && !has_fogcoord) + break; + + glPushMatrix(); + for (depthi = 0; depthi < 5; depthi++) { + GLfloat depth = Near + (Far - Near) * depthi / 4; + + switch (i % 3) { + case 0: + glFogi(GL_FOG_MODE, GL_LINEAR); + glFogf(GL_FOG_START, Near); + glFogf(GL_FOG_END, Far); + break; + case 1: + glFogi(GL_FOG_MODE, GL_EXP); + glFogf(GL_FOG_DENSITY, 2); + break; + case 2: + glFogi(GL_FOG_MODE, GL_EXP2); + glFogf(GL_FOG_DENSITY, 2); + break; + } + + glColor4f(0, 0, 0, 0); + if (i < 3) { + if (has_fogcoord) + glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT); + + glBegin(GL_POLYGON); + glVertex3f(0, 0, depth); + glVertex3f(1, 0, depth); + glVertex3f(1, 1, depth); + glVertex3f(0, 1, depth); + glEnd(); + } else { + glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FOG_COORDINATE_EXT); + glFogCoordfEXT(depth); + + glBegin(GL_POLYGON); + glVertex3f(0, 0, (Near + Far) / 2); + glVertex3f(1, 0, (Near + Far) / 2); + glVertex3f(1, 1, (Near + Far) / 2); + glVertex3f(0, 1, (Near + Far) / 2); + glEnd(); + } + glTranslatef(1.5, 0, 0); + } + + glTranslatef(.1, 0, 0); + switch (i) { + case 0: + drawString("GL_LINEAR"); + break; + case 1: + drawString("GL_EXP"); + break; + case 2: + drawString("GL_EXP2"); + break; + case 3: + drawString("GL_FOGCOORD GL_LINEAR"); + break; + case 4: + drawString("GL_FOGCOORD GL_EXP"); + break; + case 5: + drawString("GL_FOGCOORD GL_EXP2"); + break; + } + + glPopMatrix(); + glTranslatef(0, 1.5, 0); + } + glPopMatrix(); + + glutSwapBuffers(); +} + + +static void Reshape( int width, int height ) +{ + Width = width; + Height = height; + glViewport( 0, 0, width, height ); + + glMatrixMode( GL_PROJECTION ); + glLoadIdentity(); + glOrtho( 0, 11, 9, 0, -Near, -Far ); + + glMatrixMode( GL_MODELVIEW ); + glLoadIdentity(); + glTranslatef(.25, .25, 0); +} + + +static void Key( unsigned char key, int x, int y ) +{ + (void) x; + (void) y; + switch (key) { + case 27: + exit(0); + break; + } + glutPostRedisplay(); +} + + +static void Init( void ) +{ + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + printf("GL_VERSION = %s\n", (char *) glGetString(GL_VERSION)); + /* setup lighting, etc */ + has_fogcoord = glutExtensionSupported("GL_EXT_fog_coord"); + if (!has_fogcoord) { + printf("Some output of this program requires GL_EXT_fog_coord\n"); + } +} + + +int main( int argc, char *argv[] ) +{ + glutInit( &argc, argv ); + glutInitWindowPosition( 0, 0 ); + glutInitWindowSize( Width, Height ); + glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ); + glutCreateWindow(argv[0]); + glutReshapeFunc( Reshape ); + glutKeyboardFunc( Key ); + glutDisplayFunc( Display ); + Init(); + glutMainLoop(); + return 0; +} diff --git a/progs/tests/fogcoord.c b/progs/tests/fogcoord.c new file mode 100644 index 00000000000..89355742aad --- /dev/null +++ b/progs/tests/fogcoord.c @@ -0,0 +1,102 @@ +/* + * Exercise GL_EXT_fog_coord + */ + + +#define GL_GLEXT_PROTOTYPES +#include +#include +#include +#include + +static int Width = 600; +static int Height = 200; +static GLfloat Near = 5.0, Far = 25.0; + + +static void Display( void ) +{ + GLfloat t; + + glClearColor(0.2, 0.2, 0.8, 0); + glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); + + for (t = 0.0; t <= 1.0; t += 0.25) { + GLfloat f = Near + t * (Far - Near); + printf("glFogCoord(%4.1f)\n", f); + glFogCoordfEXT(f); + + glPushMatrix(); + glTranslatef(t * 10.0 - 5.0, 0, 0); + glBegin(GL_POLYGON); + glVertex2f(-1, -1); + glVertex2f( 1, -1); + glVertex2f( 1, 1); + glVertex2f(-1, 1); + glEnd(); + glPopMatrix(); + } + glutSwapBuffers(); +} + + +static void Reshape( int width, int height ) +{ + GLfloat ar = (float) width / (float) height; + Width = width; + Height = height; + glViewport( 0, 0, width, height ); + glMatrixMode( GL_PROJECTION ); + glLoadIdentity(); + glFrustum( -ar, ar, -1.0, 1.0, Near, Far ); + glMatrixMode( GL_MODELVIEW ); + glLoadIdentity(); + glTranslatef( 0.0, 0.0, -15.0 ); +} + + +static void Key( unsigned char key, int x, int y ) +{ + (void) x; + (void) y; + switch (key) { + case 27: + exit(0); + break; + } + glutPostRedisplay(); +} + + +static void Init( void ) +{ + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + printf("GL_VERSION = %s\n", (char *) glGetString(GL_VERSION)); + /* setup lighting, etc */ + if (!glutExtensionSupported("GL_EXT_fog_coord")) { + printf("Sorry, this program requires GL_EXT_fog_coord\n"); + exit(1); + } + glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FOG_COORDINATE_EXT); + glFogi(GL_FOG_MODE, GL_LINEAR); + glFogf(GL_FOG_START, Near); + glFogf(GL_FOG_END, Far); + glEnable(GL_FOG); + printf("Squares should be colored from white -> gray -> black.\n"); +} + + +int main( int argc, char *argv[] ) +{ + glutInit( &argc, argv ); + glutInitWindowPosition( 0, 0 ); + glutInitWindowSize( Width, Height ); + glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ); + glutCreateWindow(argv[0]); + glutReshapeFunc( Reshape ); + glutKeyboardFunc( Key ); + glutDisplayFunc( Display ); + Init(); + glutMainLoop(); + return 0; +} diff --git a/progs/tests/fptest1.c b/progs/tests/fptest1.c new file mode 100644 index 00000000000..095190a8aef --- /dev/null +++ b/progs/tests/fptest1.c @@ -0,0 +1,225 @@ +/* Test GL_NV_fragment_program */ + +#include +#include +#include +#include +#include +#define GL_GLEXT_PROTOTYPES +#include + + + +static void Display( void ) +{ + glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); + + glPushMatrix(); + + glColor4f(0, 0.5, 0, 1); + glColor4f(0, 1, 0, 1); + glBegin(GL_POLYGON); + glVertex2f(-1, -1); + glVertex2f( 1, -1); + glVertex2f( 0, 1); + glEnd(); + + glPopMatrix(); + + glutSwapBuffers(); +} + + +static void Reshape( int width, int height ) +{ + glViewport( 0, 0, width, height ); + glMatrixMode( GL_PROJECTION ); + glLoadIdentity(); + glFrustum( -1.0, 1.0, -1.0, 1.0, 5.0, 25.0 ); + glMatrixMode( GL_MODELVIEW ); + glLoadIdentity(); + glTranslatef( 0.0, 0.0, -15.0 ); +} + + +static void Key( unsigned char key, int x, int y ) +{ + (void) x; + (void) y; + switch (key) { + case 27: + exit(0); + break; + } + glutPostRedisplay(); +} + + +static void Init( void ) +{ + static const char *prog0 = + "!!FP1.0\n" + "MUL o[COLR], R0, f[WPOS]; \n" + "ADD o[COLH], H3, f[TEX0]; \n" + "ADD_SAT o[COLH], H3, f[TEX0]; \n" + "ADDX o[COLH], H3, f[TEX0]; \n" + "ADDHC o[COLH], H3, f[TEX0]; \n" + "ADDXC o[COLH], H3, f[TEX0]; \n" + "ADDXC_SAT o[COLH], H30, f[TEX0]; \n" + "MUL o[COLR].xy, R0.wzyx, f[WPOS]; \n" + "MUL o[COLR], H0, f[WPOS]; \n" + "MUL o[COLR], -H0, f[WPOS]; \n" + "MOV RC, H1; \n" + "MOV HC, H2; \n" + "END \n" + ; + + /* masked updates, defines, declarations */ + static const char *prog1 = + "!!FP1.0\n" + "DEFINE foo = {1, 2, 3, 4}; \n" + "DEFINE foo2 = 5; \n" + "DECLARE foo3 = {5, 6, 7, 8}; \n" + "DECLARE bar = 3; \n" + "DECLARE bar2; \n" + "DECLARE bar3 = bar; \n" + "#DECLARE bar4 = { a, b, c, d }; \n" + "MOV o[COLR].xy, R0; \n" + "MOV o[COLR] (NE), R0; \n" + "MOV o[COLR] (NE.wzyx), R0; \n" + "MOV o[COLR].xy (NE.wzyx), R0; \n" + "MOV RC.x (EQ), R1.x; \n" + "KIL NE; \n" + "KIL EQ.xyxy; \n" + "END \n" + ; + + /* texture instructions */ + static const char *prog2 = + "!!FP1.0\n" + "TEX R0, f[TEX0], TEX0, 2D; \n" + "TEX R1, f[TEX1], TEX1, CUBE; \n" + "TEX R2, f[TEX2], TEX2, 3D; \n" + "TXP R3, f[TEX3], TEX3, RECT; \n" + "TXD R3, R2, R1, f[TEX3], TEX3, RECT; \n" + "MUL o[COLR], R0, f[COL0]; \n" + "END \n" + ; + + /* test negation, absolute value */ + static const char *prog3 = + "!!FP1.0\n" + "MOV R0, -R1; \n" + "MOV R0, +R1; \n" + "MOV R0, |-R1|; \n" + "MOV R0, |+R1|; \n" + "MOV R0, -|R1|; \n" + "MOV R0, +|R1|; \n" + "MOV R0, -|-R1|; \n" + "MOV R0, -|+R1|; \n" + "MOV o[COLR], R0; \n" + "END \n" + ; + + /* literal constant sources */ + static const char *prog4 = + "!!FP1.0\n" + "DEFINE Pi = 3.14159; \n" + "MOV R0, {1, -2, +3, 4}; \n" + "MOV R0, 5; \n" + "MOV R0, -5; \n" + "MOV R0, +5; \n" + "MOV R0, Pi; \n" + "MOV o[COLR], R0; \n" + "END \n" + ; + + /* change the fragment color in a simple way */ + static const char *prog10 = + "!!FP1.0\n" + "DEFINE blue = {0, 0, 1, 0};\n" + "DECLARE color; \n" + "MOV R0, f[COL0]; \n" + "#ADD o[COLR], R0, f[COL0]; \n" + "#ADD o[COLR], blue, f[COL0]; \n" + "#ADD o[COLR], {1, 0, 0, 0}, f[COL0]; \n" + "ADD o[COLR], color, f[COL0]; \n" + "END \n" + ; + + GLuint progs[20]; + + if (!glutExtensionSupported ("GL_NV_fragment_program")) { + printf("Sorry, this program requires GL_NV_fragment_program\n"); + exit(1); + } + + glGenProgramsNV(20, progs); + assert(progs[0]); + assert(progs[1]); + assert(progs[0] != progs[1]); + +#if 0 + glLoadProgramNV(GL_FRAGMENT_PROGRAM_NV, progs[0], + strlen(prog0), + (const GLubyte *) prog0); + assert(glIsProgramNV(progs[0])); +#endif + + glLoadProgramNV(GL_FRAGMENT_PROGRAM_NV, progs[1], + strlen(prog1), + (const GLubyte *) prog1); + assert(glIsProgramNV(progs[1])); + + glLoadProgramNV(GL_FRAGMENT_PROGRAM_NV, progs[2], + strlen(prog2), + (const GLubyte *) prog2); + assert(glIsProgramNV(progs[2])); + glBindProgramNV(GL_FRAGMENT_PROGRAM_NV, progs[2]); + + glLoadProgramNV(GL_FRAGMENT_PROGRAM_NV, progs[3], + strlen(prog3), + (const GLubyte *) prog3); + assert(glIsProgramNV(progs[3])); + glBindProgramNV(GL_FRAGMENT_PROGRAM_NV, progs[3]); + + glLoadProgramNV(GL_FRAGMENT_PROGRAM_NV, progs[4], + strlen(prog4), + (const GLubyte *) prog4); + assert(glIsProgramNV(progs[4])); + glBindProgramNV(GL_FRAGMENT_PROGRAM_NV, progs[4]); + + + /* a real program */ + glLoadProgramNV(GL_FRAGMENT_PROGRAM_NV, progs[10], + strlen(prog10), + (const GLubyte *) prog10); + assert(glIsProgramNV(progs[10])); + glBindProgramNV(GL_FRAGMENT_PROGRAM_NV, progs[10]); + + glProgramNamedParameter4fNV(progs[10], + strlen("color"), (const GLubyte *) "color", + 1, 0, 0, 1); + + glEnable(GL_FRAGMENT_PROGRAM_NV); + glEnable(GL_ALPHA_TEST); + glAlphaFunc(GL_ALWAYS, 0.0); + + printf("glGetError = %d\n", (int) glGetError()); +} + + +int main( int argc, char *argv[] ) +{ + glutInit( &argc, argv ); + glutInitWindowPosition( 0, 0 ); + glutInitWindowSize( 250, 250 ); + glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ); + glutCreateWindow(argv[0]); + glutReshapeFunc( Reshape ); + glutKeyboardFunc( Key ); + glutDisplayFunc( Display ); + Init(); + glutMainLoop(); + return 0; +} diff --git a/progs/tests/fptexture.c b/progs/tests/fptexture.c new file mode 100644 index 00000000000..f57ad628282 --- /dev/null +++ b/progs/tests/fptexture.c @@ -0,0 +1,151 @@ +/* GL_NV_fragment_program texture test */ + +#include +#include +#include +#include +#include +#define GL_GLEXT_PROTOTYPES +#include + +#include "../util/readtex.c" + + +#define TEXTURE_FILE "../images/girl.rgb" + +static GLfloat Xrot = 0.0, Yrot = 0.0, Zrot = 0.0; + + +static void Display( void ) +{ + glClear( GL_COLOR_BUFFER_BIT ); + + glPushMatrix(); + glRotatef(Xrot, 1.0, 0.0, 0.0); + glRotatef(Yrot, 0.0, 1.0, 0.0); + glRotatef(Zrot, 0.0, 0.0, 1.0); + + glBegin(GL_POLYGON); + glColor4f(1.0, 1.0, 1.0, 1); glTexCoord2f(0, 0); glVertex2f(-1, -1); + glColor4f(0.2, 0.2, 1.0, 1); glTexCoord2f(1, 0); glVertex2f( 1, -1); + glColor4f(0.2, 1.0, 0.2, 1); glTexCoord2f(1, 1); glVertex2f( 1, 1); + glColor4f(1.0, 0.2, 0.2, 1); glTexCoord2f(0, 1); glVertex2f(-1, 1); + glEnd(); + + glPopMatrix(); + + glutSwapBuffers(); +} + + +static void Reshape( int width, int height ) +{ + glViewport( 0, 0, width, height ); + glMatrixMode( GL_PROJECTION ); + glLoadIdentity(); + glFrustum( -1.0, 1.0, -1.0, 1.0, 5.0, 25.0 ); + glMatrixMode( GL_MODELVIEW ); + glLoadIdentity(); + glTranslatef( 0.0, 0.0, -8.0 ); +} + + +static void SpecialKey( int key, int x, int y ) +{ + float 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 Key( unsigned char key, int x, int y ) +{ + (void) x; + (void) y; + switch (key) { + case 27: + exit(0); + break; + } + glutPostRedisplay(); +} + + +static void Init( void ) +{ + static const char *modulate2D = + "!!FP1.0\n" + "TEX R0, f[TEX0], TEX0, 2D; \n" + "MUL o[COLR], R0, f[COL0]; \n" + "END" + ; + GLuint modulateProg; + GLuint Texture; + + if (!glutExtensionSupported("GL_NV_fragment_program")) { + printf("Error: GL_NV_fragment_program not supported!\n"); + exit(1); + } + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + /* Setup the fragment program */ + glGenProgramsNV(1, &modulateProg); + glLoadProgramNV(GL_FRAGMENT_PROGRAM_NV, modulateProg, + strlen(modulate2D), + (const GLubyte *) modulate2D); + printf("glGetError = 0x%x\n", (int) glGetError()); + printf("glError(GL_PROGRAM_ERROR_STRING_NV) = %s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_NV)); + assert(glIsProgramNV(modulateProg)); + + glBindProgramNV(GL_FRAGMENT_PROGRAM_NV, modulateProg); + glEnable(GL_FRAGMENT_PROGRAM_NV); + + /* Load texture */ + glGenTextures(1, &Texture); + glBindTexture(GL_TEXTURE_2D, Texture); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + if (!LoadRGBMipmaps(TEXTURE_FILE, GL_RGB)) { + printf("Error: couldn't load texture image file %s\n", TEXTURE_FILE); + exit(1); + } + /* XXX this enable shouldn't really be needed!!! */ + glEnable(GL_TEXTURE_2D); + + glClearColor(.3, .3, .3, 0); +} + + +int main( int argc, char *argv[] ) +{ + glutInit( &argc, argv ); + glutInitWindowPosition( 0, 0 ); + glutInitWindowSize( 250, 250 ); + glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ); + glutCreateWindow(argv[0]); + glutReshapeFunc( Reshape ); + glutKeyboardFunc( Key ); + glutSpecialFunc( SpecialKey ); + glutDisplayFunc( Display ); + Init(); + glutMainLoop(); + return 0; +} diff --git a/progs/tests/getprocaddress.c b/progs/tests/getprocaddress.c new file mode 100644 index 00000000000..2480ed44cc7 --- /dev/null +++ b/progs/tests/getprocaddress.c @@ -0,0 +1,438 @@ +/* + * Copyright (C) 1999-2002 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. + */ + +/* + * Test that glXGetProcAddress works. + */ + +#define GLX_GLXEXT_PROTOTYPES + +#include +#include +#include +#include +#include +#include +#include +#include + + +typedef void (*generic_func)(); + +#define EQUAL(X, Y) (fabs((X) - (Y)) < 0.001) + +static GLboolean +test_ActiveTextureARB(generic_func func) +{ + PFNGLACTIVETEXTUREARBPROC activeTexture = (PFNGLACTIVETEXTUREARBPROC) func; + GLint t; + GLboolean pass; + (*activeTexture)(GL_TEXTURE1_ARB); + glGetIntegerv(GL_ACTIVE_TEXTURE_ARB, &t); + pass = (t == GL_TEXTURE1_ARB); + (*activeTexture)(GL_TEXTURE0_ARB); /* restore default */ + return pass; +} + + +static GLboolean +test_SecondaryColor3fEXT(generic_func func) +{ + PFNGLSECONDARYCOLOR3FEXTPROC secColor3f = (PFNGLSECONDARYCOLOR3FEXTPROC) func; + GLfloat color[4]; + GLboolean pass; + (*secColor3f)(1.0, 1.0, 0.0); + glGetFloatv(GL_CURRENT_SECONDARY_COLOR_EXT, color); + pass = (color[0] == 1.0 && color[1] == 1.0 && color[2] == 0.0); + (*secColor3f)(0.0, 0.0, 0.0); /* restore default */ + return pass; +} + + +static GLboolean +test_ActiveStencilFaceEXT(generic_func func) +{ + PFNGLACTIVESTENCILFACEEXTPROC activeFace = (PFNGLACTIVESTENCILFACEEXTPROC) func; + GLint face; + GLboolean pass; + (*activeFace)(GL_BACK); + glGetIntegerv(GL_ACTIVE_STENCIL_FACE_EXT, &face); + pass = (face == GL_BACK); + (*activeFace)(GL_FRONT); /* restore default */ + return pass; +} + + +static GLboolean +test_VertexAttrib1fvARB(generic_func func) +{ + PFNGLVERTEXATTRIB1FVARBPROC vertexAttrib1fvARB = (PFNGLVERTEXATTRIB1FVARBPROC) func; + PFNGLGETVERTEXATTRIBFVARBPROC getVertexAttribfvARB = (PFNGLGETVERTEXATTRIBFVARBPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribfvARB"); + + const GLfloat v[1] = {25.0}; + const GLfloat def[1] = {0}; + GLfloat res[4]; + GLboolean pass; + (*vertexAttrib1fvARB)(6, v); + (*getVertexAttribfvARB)(6, GL_CURRENT_VERTEX_ATTRIB_ARB, res); + pass = (res[0] == 25.0 && res[1] == 0.0 && res[2] == 0.0 && res[3] == 1.0); + (*vertexAttrib1fvARB)(6, def); + return pass; +} + +static GLboolean +test_VertexAttrib4NubvARB(generic_func func) +{ + PFNGLVERTEXATTRIB4NUBVARBPROC vertexAttrib4NubvARB = (PFNGLVERTEXATTRIB4NUBVARBPROC) func; + PFNGLGETVERTEXATTRIBFVARBPROC getVertexAttribfvARB = (PFNGLGETVERTEXATTRIBFVARBPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribfvARB"); + + const GLubyte v[4] = {255, 0, 255, 0}; + const GLubyte def[4] = {0, 0, 0, 255}; + GLfloat res[4]; + GLboolean pass; + (*vertexAttrib4NubvARB)(6, v); + (*getVertexAttribfvARB)(6, GL_CURRENT_VERTEX_ATTRIB_ARB, res); + pass = (res[0] == 1.0 && res[1] == 0.0 && res[2] == 1.0 && res[3] == 0.0); + (*vertexAttrib4NubvARB)(6, def); + return pass; +} + + +static GLboolean +test_VertexAttrib4NuivARB(generic_func func) +{ + PFNGLVERTEXATTRIB4NUIVARBPROC vertexAttrib4NuivARB = (PFNGLVERTEXATTRIB4NUIVARBPROC) func; + PFNGLGETVERTEXATTRIBFVARBPROC getVertexAttribfvARB = (PFNGLGETVERTEXATTRIBFVARBPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribfvARB"); + + const GLuint v[4] = {0xffffffff, 0, 0xffffffff, 0}; + const GLuint def[4] = {0, 0, 0, 0xffffffff}; + GLfloat res[4]; + GLboolean pass; + (*vertexAttrib4NuivARB)(6, v); + (*getVertexAttribfvARB)(6, GL_CURRENT_VERTEX_ATTRIB_ARB, res); + pass = (EQUAL(res[0], 1.0) && EQUAL(res[1], 0.0) && EQUAL(res[2], 1.0) && EQUAL(res[3], 0.0)); + (*vertexAttrib4NuivARB)(6, def); + return pass; +} + + +static GLboolean +test_VertexAttrib4ivARB(generic_func func) +{ + PFNGLVERTEXATTRIB4IVARBPROC vertexAttrib4ivARB = (PFNGLVERTEXATTRIB4IVARBPROC) func; + PFNGLGETVERTEXATTRIBFVARBPROC getVertexAttribfvARB = (PFNGLGETVERTEXATTRIBFVARBPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribfvARB"); + + const GLint v[4] = {1, 2, -3, 4}; + const GLint def[4] = {0, 0, 0, 1}; + GLfloat res[4]; + GLboolean pass; + (*vertexAttrib4ivARB)(6, v); + (*getVertexAttribfvARB)(6, GL_CURRENT_VERTEX_ATTRIB_ARB, res); + pass = (EQUAL(res[0], 1.0) && EQUAL(res[1], 2.0) && EQUAL(res[2], -3.0) && EQUAL(res[3], 4.0)); + (*vertexAttrib4ivARB)(6, def); + return pass; +} + + +static GLboolean +test_VertexAttrib4NsvARB(generic_func func) +{ + PFNGLVERTEXATTRIB4NSVARBPROC vertexAttrib4NsvARB = (PFNGLVERTEXATTRIB4NSVARBPROC) func; + PFNGLGETVERTEXATTRIBFVARBPROC getVertexAttribfvARB = (PFNGLGETVERTEXATTRIBFVARBPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribfvARB"); + + const GLshort v[4] = {0, 32767, 32767, 0}; + const GLshort def[4] = {0, 0, 0, 32767}; + GLfloat res[4]; + GLboolean pass; + (*vertexAttrib4NsvARB)(6, v); + (*getVertexAttribfvARB)(6, GL_CURRENT_VERTEX_ATTRIB_ARB, res); + pass = (EQUAL(res[0], 0.0) && EQUAL(res[1], 1.0) && EQUAL(res[2], 1.0) && EQUAL(res[3], 0.0)); + (*vertexAttrib4NsvARB)(6, def); + return pass; +} + + +static GLboolean +test_VertexAttrib4NusvARB(generic_func func) +{ + PFNGLVERTEXATTRIB4NUSVARBPROC vertexAttrib4NusvARB = (PFNGLVERTEXATTRIB4NUSVARBPROC) func; + PFNGLGETVERTEXATTRIBFVARBPROC getVertexAttribfvARB = (PFNGLGETVERTEXATTRIBFVARBPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribfvARB"); + + const GLushort v[4] = {0xffff, 0, 0xffff, 0}; + const GLushort def[4] = {0, 0, 0, 0xffff}; + GLfloat res[4]; + GLboolean pass; + (*vertexAttrib4NusvARB)(6, v); + (*getVertexAttribfvARB)(6, GL_CURRENT_VERTEX_ATTRIB_ARB, res); + pass = (EQUAL(res[0], 1.0) && EQUAL(res[1], 0.0) && EQUAL(res[2], 1.0) && EQUAL(res[3], 0.0)); + (*vertexAttrib4NusvARB)(6, def); + return pass; +} + + +static GLboolean +test_VertexAttrib4ubNV(generic_func func) +{ + PFNGLVERTEXATTRIB4UBNVPROC vertexAttrib4ubNV = (PFNGLVERTEXATTRIB4UBNVPROC) func; + PFNGLGETVERTEXATTRIBFVNVPROC getVertexAttribfvNV = (PFNGLGETVERTEXATTRIBFVNVPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribfvNV"); + + const GLubyte v[4] = {255, 0, 255, 0}; + const GLubyte def[4] = {0, 0, 0, 255}; + GLfloat res[4]; + GLboolean pass; + (*vertexAttrib4ubNV)(6, v[0], v[1], v[2], v[3]); + (*getVertexAttribfvNV)(6, GL_CURRENT_ATTRIB_NV, res); + pass = (res[0] == 1.0 && res[1] == 0.0 && res[2] == 1.0 && res[3] == 0.0); + (*vertexAttrib4ubNV)(6, def[0], def[1], def[2], def[3]); + return pass; +} + + +static GLboolean +test_VertexAttrib2sNV(generic_func func) +{ + PFNGLVERTEXATTRIB2SNVPROC vertexAttrib2sNV = (PFNGLVERTEXATTRIB2SNVPROC) func; + PFNGLGETVERTEXATTRIBFVNVPROC getVertexAttribfvNV = (PFNGLGETVERTEXATTRIBFVNVPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribfvNV"); + + const GLshort v[2] = {2, -4,}; + const GLshort def[2] = {0, 0}; + GLfloat res[4]; + GLboolean pass; + (*vertexAttrib2sNV)(6, v[0], v[1]); + (*getVertexAttribfvNV)(6, GL_CURRENT_ATTRIB_NV, res); + pass = (EQUAL(res[0], 2) && EQUAL(res[1], -4) && EQUAL(res[2], 0) && res[3] == 1.0); + (*vertexAttrib2sNV)(6, def[0], def[1]); + return pass; +} + + +static GLboolean +test_VertexAttrib3fNV(generic_func func) +{ + PFNGLVERTEXATTRIB3FNVPROC vertexAttrib3fNV = (PFNGLVERTEXATTRIB3FNVPROC) func; + PFNGLGETVERTEXATTRIBFVNVPROC getVertexAttribfvNV = (PFNGLGETVERTEXATTRIBFVNVPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribfvNV"); + + const GLfloat v[3] = {0.2, 0.4, 0.8}; + const GLfloat def[3] = {0, 0, 0}; + GLfloat res[4]; + GLboolean pass; + (*vertexAttrib3fNV)(6, v[0], v[1], v[2]); + (*getVertexAttribfvNV)(6, GL_CURRENT_ATTRIB_NV, res); + pass = (EQUAL(res[0], 0.2) && EQUAL(res[1], 0.4) && EQUAL(res[2], 0.8) && res[3] == 1.0); + (*vertexAttrib3fNV)(6, def[0], def[1], def[2]); + return pass; +} + + +static GLboolean +test_VertexAttrib4dvNV(generic_func func) +{ + PFNGLVERTEXATTRIB4DVNVPROC vertexAttrib4dvNV = (PFNGLVERTEXATTRIB4DVNVPROC) func; + PFNGLGETVERTEXATTRIBFVNVPROC getVertexAttribfvNV = (PFNGLGETVERTEXATTRIBFVNVPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribfvNV"); + + const GLdouble v[4] = {0.2, 0.4, 0.8, 1.2}; + const GLdouble def[4] = {0, 0, 0, 1}; + GLfloat res[4]; + GLboolean pass; + (*vertexAttrib4dvNV)(6, v); + (*getVertexAttribfvNV)(6, GL_CURRENT_ATTRIB_NV, res); + pass = (EQUAL(res[0], 0.2) && EQUAL(res[1], 0.4) && EQUAL(res[2], 0.8) && EQUAL(res[3], 1.2)); + (*vertexAttrib4dvNV)(6, def); + return pass; +} + + +/* + * The following header file is auto-generated with Python. The Python + * script looks in this file for functions named "test_*" as seen above. + */ +#include "getproclist.h" + + + +static int +extension_supported(const char *haystack, const char *needle) +{ + if (strstr(haystack, needle)) + return 1; + else + return 0; +} + + +static void +check_functions( const char *extensions ) +{ + struct name_test_pair *entry; + int failures = 0, passes = 0; + int totalFail = 0, totalPass = 0; + int doTests; + + for (entry = functions; entry->name; entry++) { + if (entry->name[0] == '-') { + /* XXX update for OpenGL 2.0 */ + if (entry->name[1] == '1') { + /* check GL version X.Y */ + const char *version = (const char *) glGetString(GL_VERSION); + if (version[0] == entry->name[1] && + version[1] == entry->name[2] && + version[2] >= entry->name[3]) + doTests = 1; + else + doTests = 0; + } + else { + /* check if the named extension is available */ + doTests = extension_supported(extensions, entry->name+1); + } + if (doTests) + printf("Testing %s functions\n", entry->name + 1); + totalFail += failures; + totalPass += passes; + failures = 0; + passes = 0; + } + else if (doTests) { + generic_func funcPtr = (generic_func) glXGetProcAddressARB((const GLubyte *) entry->name); + if (funcPtr) { + if (entry->test) { + GLboolean b; + printf(" Validating %s:", entry->name); + b = (*entry->test)(funcPtr); + if (b) { + printf(" Pass\n"); + passes++; + } + else { + printf(" FAIL!!!\n"); + failures++; + } + } + else { + passes++; + } + } + else { + printf(" glXGetProcAddress(%s) failed!\n", entry->name); + failures++; + } + } + + if (doTests && (!(entry+1)->name || (entry+1)->name[0] == '-')) { + if (failures > 0) { + printf(" %d failed.\n", failures); + } + if (passes > 0) { + printf(" %d passed.\n", passes); + } + } + } + totalFail += failures; + totalPass += passes; + + printf("-----------------------------\n"); + printf("Total: %d pass %d fail\n", totalPass, totalFail); +} + + + +static void +print_screen_info(Display *dpy, int scrnum, Bool allowDirect) +{ + 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 }; + + XSetWindowAttributes attr; + unsigned long mask; + Window root; + GLXContext ctx; + 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; + } + } + + attr.background_pixel = 0; + attr.border_pixel = 0; + 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); + + ctx = glXCreateContext( dpy, visinfo, NULL, allowDirect ); + if (!ctx) { + fprintf(stderr, "Error: glXCreateContext failed\n"); + XDestroyWindow(dpy, win); + return; + } + + if (glXMakeCurrent(dpy, win, ctx)) { + check_functions( (const char *) glGetString(GL_EXTENSIONS) ); + } + else { + fprintf(stderr, "Error: glXMakeCurrent failed\n"); + } + + glXDestroyContext(dpy, ctx); + XDestroyWindow(dpy, win); +} + + +int +main(int argc, char *argv[]) +{ + char *displayName = NULL; + Display *dpy; + + dpy = XOpenDisplay(displayName); + if (!dpy) { + fprintf(stderr, "Error: unable to open display %s\n", displayName); + return -1; + } + + print_screen_info(dpy, 0, GL_TRUE); + + XCloseDisplay(dpy); + + return 0; +} diff --git a/progs/tests/getprocaddress.py b/progs/tests/getprocaddress.py new file mode 100644 index 00000000000..f3ed3192e1f --- /dev/null +++ b/progs/tests/getprocaddress.py @@ -0,0 +1,93 @@ +#!/usr/bin/env python + +# $Id: getprocaddress.py,v 1.7 2005-06-21 23:42:43 idr Exp $ + +# Helper for the getprocaddress.c test. + +import sys, getopt, re +sys.path.append("../../src/mesa/glapi/" ) +import gl_XML +import license + + +def FindTestFunctions(): + """Scan getprocaddress.c for lines that start with "test_" to find + extension function tests. Return a list of names found.""" + functions = [] + f = open("getprocaddress.c") + if not f: + return functions + for line in f.readlines(): + v = re.search("^test_([a-zA-Z0-9]+)", line) + if v: + func = v.group(1) + functions.append(func) + f.close + return functions + + +class PrintExports(gl_XML.gl_print_base): + def __init__(self): + gl_XML.gl_print_base.__init__(self) + + self.name = "getprocaddress.py (from Mesa)" + self.license = license.bsd_license_template % ( \ +"""Copyright (C) 1999-2001 Brian Paul All Rights Reserved. +(C) Copyright IBM Corporation 2004""", "BRIAN PAUL, IBM") + + self.tests = FindTestFunctions() + self.prevCategory = "" + return + + + def printRealHeader(self): + print """ +struct name_test_pair { + const char *name; + GLboolean (*test)(generic_func); +}; + +static struct name_test_pair functions[] = {""" + + def printBody(self, api): + prev_category = None + + + for f in api.functionIterateByOffset(): + [category, num] = api.get_category_for_name( f.name ) + if category != prev_category: + print ' { "-%s", NULL},' % category + prev_category = category + + test = "NULL" + for name in f.entry_points: + if name in self.tests: + test = "test_%s" % name + break + + print ' { "gl%s", %s },' % (f.name, test) + + print '' + print ' { NULL, NULL }' + print '};' + print '' + return + + +if __name__ == '__main__': + file_name = "../../src/mesa/glapi/gl_API.xml" + + try: + (args, trail) = getopt.getopt(sys.argv[1:], "f:") + except Exception,e: + show_usage() + + for (arg,val) in args: + if arg == "-f": + file_name = val + + printer = PrintExports() + + api = gl_XML.parse_GL_API( file_name, gl_XML.gl_item_factory() ) + + printer.Print( api ) diff --git a/progs/tests/interleave.c b/progs/tests/interleave.c new file mode 100644 index 00000000000..e98b3ed0469 --- /dev/null +++ b/progs/tests/interleave.c @@ -0,0 +1,406 @@ +/* + * (C) Copyright IBM Corporation 2005 + * 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 + * on the rights to use, copy, modify, merge, publish, distribute, sub + * license, 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 (including the next + * paragraph) 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 NON-INFRINGEMENT. IN NO EVENT SHALL + * VA LINUX SYSTEM, IBM AND/OR THEIR SUPPLIERS 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. + */ + +/** + * \file interleave.c + * + * Simple test of glInterleavedArrays functionality. For each mode, two + * meshes are drawn. One is drawn using interleaved arrays and the othe is + * drawn using immediate mode. Both should look identical. + * + * \author Ian Romanick + */ + +#include +#include +#include +#include +#include + +static int Width = 400; +static int Height = 300; +static const GLfloat Near = 5.0, Far = 25.0; + +static const GLfloat t[][4] = { + { 0.5, 0.0, 0.0, 1.0 }, + + { 0.25, 0.5, 0.0, 1.0 }, + { 0.75, 0.5, 0.0, 1.0 }, + + { 0.0, 1.0, 0.0, 1.0 }, + { 0.5, 1.0, 0.0, 1.0 }, + { 1.0, 1.0, 0.0, 1.0 }, +}; + +static const GLfloat c_f[][4] = { + { 1.0, 0.0, 0.0, 1.0 }, + + { 0.0, 1.0, 0.0, 1.0 }, + { 0.0, 1.0, 0.0, 1.0 }, + + { 0.0, 0.0, 1.0, 1.0 }, + { 1.0, 0.0, 1.0, 1.0 }, + { 0.0, 0.0, 1.0, 1.0 }, +}; + +static const GLubyte c_ub[][4] = { + { 0xff, 0x00, 0x00, 0xff }, + + { 0x00, 0xff, 0x00, 0xff }, + { 0x00, 0xff, 0x00, 0xff }, + + { 0x00, 0x00, 0xff, 0xff }, + { 0xff, 0x00, 0xff, 0xff }, + { 0x00, 0x00, 0xff, 0xff }, +}; + +static const GLfloat n[][3] = { + { 0.0, 0.0, -1.0 }, + + { 0.0, 0.0, -1.0 }, + { 0.0, 0.0, -1.0 }, + + { 0.0, 0.0, -1.0 }, + { 0.0, 0.0, -1.0 }, + { 0.0, 0.0, -1.0 }, +}; + +static const GLfloat v[][4] = { + { 0.0, 1.0, 0.0, 1.0, }, + + { -0.5, 0.0, 0.0, 1.0, }, + { 0.5, 0.0, 0.0, 1.0, }, + + { -1.0, -1.0, 0.0, 1.0, }, + { 0.0, -1.0, 0.0, 1.0, }, + { 1.0, -1.0, 0.0, 1.0, }, +}; + +static const unsigned indicies[12] = { + 0, 1, 2, + 1, 3, 4, + 2, 4, 5, + 1, 4, 2 +}; + +#define NONE { NULL, 0, 0, 0 } +#define V2F { v, 2, 2 * sizeof( GLfloat ), GL_FLOAT, sizeof( v[0] ) } +#define V3F { v, 3, 3 * sizeof( GLfloat ), GL_FLOAT, sizeof( v[0] ) } +#define V4F { v, 4, 4 * sizeof( GLfloat ), GL_FLOAT, sizeof( v[0] ) } + +#define C4UB { c_ub, 4, 4 * sizeof( GLubyte ), GL_UNSIGNED_BYTE, sizeof( c_ub[0] ) } +#define C3F { c_f, 3, 3 * sizeof( GLfloat ), GL_FLOAT, sizeof( c_f[0] ) } +#define C4F { c_f, 4, 4 * sizeof( GLfloat ), GL_FLOAT, sizeof( c_f[0] ) } + +#define T2F { t, 2, 2 * sizeof( GLfloat ), GL_FLOAT, sizeof( t[0] ) } +#define T4F { t, 4, 4 * sizeof( GLfloat ), GL_FLOAT, sizeof( t[0] ) } + +#define N3F { n, 3, 3 * sizeof( GLfloat ), GL_FLOAT, sizeof( n[0] ) } + +struct interleave_info { + const void * data; + unsigned count; + unsigned size; + GLenum type; + unsigned stride; +}; + +#define NUM_MODES 14 +#define INVALID_MODE 14 +#define INVALID_STRIDE 15 + +struct interleave_info info[ NUM_MODES ][4] = { + { NONE, NONE, NONE, V2F }, + { NONE, NONE, NONE, V3F }, + { NONE, C4UB, NONE, V2F }, + { NONE, C4UB, NONE, V3F }, + { NONE, C3F, NONE, V3F }, + + { NONE, NONE, N3F, V3F }, + { NONE, C4F, N3F, V3F }, + + { T2F, NONE, NONE, V3F }, + { T4F, NONE, NONE, V4F }, + + { T2F, C4UB, NONE, V3F }, + { T2F, C3F, NONE, V3F }, + { T2F, NONE, N3F, V3F }, + { T2F, C4F, N3F, V3F }, + { T4F, C4F, N3F, V4F }, +}; + +const char * const mode_names[ NUM_MODES ] = { + "GL_V2F", + "GL_V3F", + "GL_C4UB_V2F", + "GL_C4UB_V3F", + "GL_C3F_V3F", + "GL_N3F_V3F", + "GL_C4F_N3F_V3F", + "GL_T2F_V3F", + "GL_T4F_V4F", + "GL_T2F_C4UB_V3F", + "GL_T2F_C3F_V3F", + "GL_T2F_N3F_V3F", + "GL_T2F_C4F_N3F_V3F", + "GL_T4F_C4F_N3F_V4F", +}; + +static unsigned interleave_mode = 0; +static GLboolean use_invalid_mode = GL_FALSE; +static GLboolean use_invalid_stride = GL_FALSE; + +#define DEREF(item,idx) (void *) & ((char *)curr_info[item].data)[idx * curr_info[item].stride] + +static void Display( void ) +{ + const struct interleave_info * const curr_info = info[ interleave_mode ]; + + /* 4 floats for 12 verticies for 4 data elements. + */ + char data[ (sizeof( GLfloat ) * 4) * 12 * 4 ]; + + unsigned i; + unsigned offset; + GLenum err; + GLenum format; + GLsizei stride; + + + glClearColor(0.2, 0.2, 0.8, 0); + glClear( GL_COLOR_BUFFER_BIT ); + + glPushMatrix(); + + glTranslatef(-1.5, 0, 0); + + glColor3fv( c_f[0] ); + + if ( curr_info[0].data != NULL ) { + glEnable( GL_TEXTURE_2D ); + } + else { + glDisable( GL_TEXTURE_2D ); + } + + + offset = 0; + glBegin(GL_TRIANGLES); + for ( i = 0 ; i < 12 ; i++ ) { + const unsigned index = indicies[i]; + + + /* Handle the vertex texture coordinate. + */ + if ( curr_info[0].data != NULL ) { + if ( curr_info[0].count == 2 ) { + glTexCoord2fv( DEREF(0, index) ); + } + else { + glTexCoord4fv( DEREF(0, index) ); + } + + (void) memcpy( & data[ offset ], DEREF(0, index), + curr_info[0].size ); + offset += curr_info[0].size; + } + + + /* Handle the vertex color. + */ + if ( curr_info[1].data != NULL ) { + if ( curr_info[1].type == GL_FLOAT ) { + if ( curr_info[1].count == 3 ) { + glColor3fv( DEREF(1, index) ); + } + else { + glColor4fv( DEREF(1, index) ); + } + } + else { + glColor4ubv( DEREF(1, index) ); + } + + (void) memcpy( & data[ offset ], DEREF(1, index), + curr_info[1].size ); + offset += curr_info[1].size; + } + + + /* Handle the vertex normal. + */ + if ( curr_info[2].data != NULL ) { + glNormal3fv( DEREF(2, index) ); + + (void) memcpy( & data[ offset ], DEREF(2, index), + curr_info[2].size ); + offset += curr_info[2].size; + } + + + switch( curr_info[3].count ) { + case 2: + glVertex2fv( DEREF(3, index) ); + break; + case 3: + glVertex3fv( DEREF(3, index) ); + break; + case 4: + glVertex4fv( DEREF(3, index) ); + break; + } + + (void) memcpy( & data[ offset ], DEREF(3, index), + curr_info[3].size ); + offset += curr_info[3].size; + } + glEnd(); + + + glTranslatef(3.0, 0, 0); + + /* The masking with ~0x2A00 is a bit of a hack to make sure that format + * ends up with an invalid value no matter what rand() returns. + */ + format = (use_invalid_mode) + ? (rand() & ~0x2A00) : GL_V2F + interleave_mode; + stride = (use_invalid_stride) ? -abs(rand()) : 0; + + (void) glGetError(); + glInterleavedArrays( format, stride, data ); + err = glGetError(); + if ( err ) { + printf("glInterleavedArrays(0x%04x, %d, %p) generated the error 0x%04x\n", + format, stride, data, err ); + } + else { + glDrawArrays( GL_TRIANGLES, 0, 12 ); + } + + glPopMatrix(); + + glutSwapBuffers(); +} + + +static void Reshape( int width, int height ) +{ + GLfloat ar = (float) width / (float) height; + Width = width; + Height = height; + glViewport( 0, 0, width, height ); + glMatrixMode( GL_PROJECTION ); + glLoadIdentity(); + glFrustum( -ar, ar, -1.0, 1.0, Near, Far ); + glMatrixMode( GL_MODELVIEW ); + glLoadIdentity(); + glTranslatef( 0.0, 0.0, -15.0 ); +} + + +static void Key( unsigned char key, int x, int y ) +{ + (void) x; + (void) y; + switch (key) { + case 27: + exit(0); + break; + } + glutPostRedisplay(); +} + + +static void ModeMenu( int entry ) +{ + if ( entry == INVALID_MODE ) { + use_invalid_mode = GL_TRUE; + use_invalid_stride = GL_FALSE; + } + else if ( entry == INVALID_STRIDE ) { + use_invalid_mode = GL_FALSE; + use_invalid_stride = GL_TRUE; + } + else { + use_invalid_mode = GL_FALSE; + use_invalid_stride = GL_FALSE; + interleave_mode = entry; + } +} + +static void Init( void ) +{ + const char * const ver_string = (const char * const) + glGetString( GL_VERSION ); + const GLubyte tex[16] = { + 0xff, 0x00, 0xff, 0x00, + 0x00, 0xff, 0x00, 0xff, + 0xff, 0x00, 0xff, 0x00, + 0x00, 0xff, 0x00, 0xff, + }; + + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + printf("GL_VERSION = %s\n", ver_string); + + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST ); + glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE ); + glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, 4, 4, 0, + GL_LUMINANCE, GL_UNSIGNED_BYTE, tex ); + + printf("Use the context menu (right click) to select the interleaved array mode.\n"); + printf("Press ESCAPE to exit.\n\n"); + printf("NOTE: This is *NOT* a very good test of the modes that use normals.\n"); +} + + +int main( int argc, char *argv[] ) +{ + unsigned i; + + srand( time( NULL ) ); + + glutInit( &argc, argv ); + glutInitWindowPosition( 0, 0 ); + glutInitWindowSize( Width, Height ); + glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE ); + glutCreateWindow( "glInterleavedArrays test" ); + glutReshapeFunc( Reshape ); + glutKeyboardFunc( Key ); + glutDisplayFunc( Display ); + + glutCreateMenu( ModeMenu ); + for ( i = 0 ; i < NUM_MODES ; i++ ) { + glutAddMenuEntry( mode_names[i], i); + } + + glutAddMenuEntry( "Random invalid mode", INVALID_MODE); + glutAddMenuEntry( "Random invalid stride", INVALID_STRIDE); + + glutAttachMenu(GLUT_RIGHT_BUTTON); + + Init(); + glutMainLoop(); + return 0; +} diff --git a/progs/tests/invert.c b/progs/tests/invert.c new file mode 100644 index 00000000000..750592ed79f --- /dev/null +++ b/progs/tests/invert.c @@ -0,0 +1,195 @@ +/* + * (C) Copyright IBM Corporation 2005 + * 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 + * on the rights to use, copy, modify, merge, publish, distribute, sub + * license, 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 (including the next + * paragraph) 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 NON-INFRINGEMENT. IN NO EVENT SHALL + * VA LINUX SYSTEM, IBM AND/OR THEIR SUPPLIERS 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. + */ + +/** + * \file invert.c + * + * Simple test of GL_MESA_pack_invert functionality. Three squares are + * drawn. The first two should look the same, and the third one should + * look inverted. + * + * \author Ian Romanick + */ + +#include +#include +#include +#include + +#include "readtex.h" + +#define IMAGE_FILE "../images/tree3.rgb" + +static int Width = 420; +static int Height = 150; +static const GLfloat Near = 5.0, Far = 25.0; + +static GLubyte * image = NULL; +static GLubyte * temp_image = NULL; +static GLuint img_width = 0; +static GLuint img_height = 0; +static GLuint img_format = 0; + +PFNGLWINDOWPOS2IPROC win_pos_2i = NULL; + + +static void Display( void ) +{ + GLint err; + + + glClearColor(0.2, 0.2, 0.8, 0); + glClear( GL_COLOR_BUFFER_BIT ); + + + /* This is the "reference" square. + */ + + (*win_pos_2i)( 5, 5 ); + glDrawPixels( img_width, img_height, img_format, GL_UNSIGNED_BYTE, image ); + + glPixelStorei( GL_PACK_INVERT_MESA, GL_FALSE ); + err = glGetError(); + if ( err != GL_NO_ERROR ) { + printf( "Setting PACK_INVERT_MESA to false generated an error (0x%04x).\n", + err ); + } + + glReadPixels( 5, 5, img_width, img_height, img_format, GL_UNSIGNED_BYTE, temp_image ); + (*win_pos_2i)( 5 + 1 * (10 + img_width), 5 ); + glDrawPixels( img_width, img_height, img_format, GL_UNSIGNED_BYTE, temp_image ); + + glPixelStorei( GL_PACK_INVERT_MESA, GL_TRUE ); + err = glGetError(); + if ( err != GL_NO_ERROR ) { + printf( "Setting PACK_INVERT_MESA to true generated an error (0x%04x).\n", + err ); + } + + glReadPixels( 5, 5, img_width, img_height, img_format, GL_UNSIGNED_BYTE, temp_image ); + (*win_pos_2i)( 5 + 2 * (10 + img_width), 5 ); + glDrawPixels( img_width, img_height, img_format, GL_UNSIGNED_BYTE, temp_image ); + + glutSwapBuffers(); +} + + +static void Reshape( int width, int height ) +{ + GLfloat ar = (float) width / (float) height; + Width = width; + Height = height; + glViewport( 0, 0, width, height ); + glMatrixMode( GL_PROJECTION ); + glLoadIdentity(); + glFrustum( -ar, ar, -1.0, 1.0, Near, Far ); + glMatrixMode( GL_MODELVIEW ); + glLoadIdentity(); + glTranslatef( 0.0, 0.0, -15.0 ); +} + + +static void Key( unsigned char key, int x, int y ) +{ + (void) x; + (void) y; + switch (key) { + case 27: + exit(0); + break; + } + glutPostRedisplay(); +} + + +static void Init( void ) +{ + const char * const ver_string = (const char * const) + glGetString( GL_VERSION ); + const float ver = strtof( ver_string, NULL ); + + + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + printf("GL_VERSION = %s\n", ver_string); + + if ( !glutExtensionSupported("GL_MESA_pack_invert") ) { + printf("\nSorry, this program requires GL_MESA_pack_invert.\n"); + exit(1); + } + + if ( ver >= 1.4 ) { + win_pos_2i = (PFNGLWINDOWPOS2IPROC) glutGetProcAddress( "glWindowPos2i" ); + } + else if ( glutExtensionSupported("GL_ARB_window_pos") ) { + win_pos_2i = (PFNGLWINDOWPOS2IPROC) glutGetProcAddress( "glWindowPos2iARB" ); + } + else if ( glutExtensionSupported("GL_MESA_window_pos") ) { + win_pos_2i = (PFNGLWINDOWPOS2IPROC) glutGetProcAddress( "glWindowPos2iMESA" ); + } + + + /* Do this check as a separate if-statement instead of as an else in case + * one of the required extensions is supported but glutGetProcAddress + * returns NULL. + */ + + if ( win_pos_2i == NULL ) { + printf("\nSorry, this program requires either GL 1.4 (or higher),\n" + "GL_ARB_window_pos, or GL_MESA_window_pos.\n"); + exit(1); + } + + printf("\nThe left 2 squares should be the same color, and the right\n" + "square should look upside-down.\n"); + + + image = LoadRGBImage( IMAGE_FILE, & img_width, & img_height, + & img_format ); + if ( image == NULL ) { + printf( "Could not open image file \"%s\".\n", IMAGE_FILE ); + exit(1); + } + + temp_image = malloc( 3 * img_height * img_width ); + if ( temp_image == NULL ) { + printf( "Could not allocate memory for temporary image.\n" ); + exit(1); + } +} + + +int main( int argc, char *argv[] ) +{ + glutInit( &argc, argv ); + glutInitWindowPosition( 0, 0 ); + glutInitWindowSize( Width, Height ); + glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE ); + glutCreateWindow( "GL_MESA_pack_invert test" ); + glutReshapeFunc( Reshape ); + glutKeyboardFunc( Key ); + glutDisplayFunc( Display ); + Init(); + glutMainLoop(); + return 0; +} diff --git a/progs/tests/jkrahntest.c b/progs/tests/jkrahntest.c new file mode 100644 index 00000000000..9392e1ab2b9 --- /dev/null +++ b/progs/tests/jkrahntest.c @@ -0,0 +1,181 @@ +/* $Id: jkrahntest.c,v 1.2 2006-01-30 17:12:10 brianp Exp $ */ + +/* This is a good test for glXSwapBuffers on non-current windows, + * and the glXCopyContext function. Fixed several Mesa/DRI bugs with + * this program on 15 June 2002. + * + * Joe's comments follow: + * + * I have tried some different approaches for being able to + * draw to multiple windows using one context, or a copied + * context. Mesa/indirect rendering works to use one context + * for multiple windows, but crashes with glXCopyContext. + * DRI is badly broken, at least for ATI. + * + * I also noticed that glXMakeCurrent allows a window and context + * from different visuals to be attached (haven't tested recently). + * + * Joe Krahn + */ + +#include +#include +#include +#include +#include +#include +#include + +#ifndef M_PI +#define M_PI 3.14159 +#endif + +#define DEGTOR (M_PI/180.0) + +static int AttributeList[] = { GLX_RGBA, GLX_DOUBLEBUFFER, None }; + +int main(int argc, char **argv) +{ + Window win1, win2; + XVisualInfo *vi; + XSetWindowAttributes swa; + Display *dpy; + GLXContext ctx1, ctx2; + float angle; + int test; + + if (argc < 2) { + fprintf(stderr, "This program tests GLX context switching.\n"); + fprintf(stderr, "Usage: cxbug \n"); + fprintf(stderr, "Where n is:\n"); + fprintf(stderr, "\t1) Use two contexts and swap only when the context is current (typical case).\n"); + fprintf(stderr, "\t2) Use two contexts and swap at the same time.\n"); + fprintf(stderr, "\t\t Used to crash Mesa & nVidia, and DRI artifacts. Seems OK now.\n"); + fprintf(stderr, "\t3) Use one context, but only swap when a context is current.\n"); + fprintf(stderr, "\t\t Serious artifacts for DRI at least with ATI.\n"); + fprintf(stderr, "\t4) Use one context, swap both windows at the same time, so the left\n"); + fprintf(stderr, "\t\t window has no context at swap time. Severe artifacts for DRI.\n"); + fprintf(stderr, "\t5) Use two contexts, copying one to the other when switching windows.\n"); + fprintf(stderr, "\t\t DRI gives an error, indirect rendering crashes server.\n"); + + exit(1); + } + test = atoi(argv[1]); + + /* get a connection */ + dpy = XOpenDisplay(NULL); + + /* Get an appropriate visual */ + vi = glXChooseVisual(dpy, DefaultScreen(dpy), AttributeList); + if (vi == 0) { + fprintf(stderr, "No matching visuals found.\n"); + exit(-1); + } + + /* Create two GLX contexts, with list sharing */ + ctx1 = glXCreateContext(dpy, vi, 0, True); + ctx2 = glXCreateContext(dpy, vi, ctx1, True); + + /* create a colormap */ + swa.colormap = XCreateColormap(dpy, RootWindow(dpy, vi->screen), + vi->visual, AllocNone); + swa.border_pixel = 0; + + /* Create two windows */ + win1 = XCreateWindow(dpy, RootWindow(dpy, vi->screen), + 10, 10, 200, 200, + 0, vi->depth, InputOutput, vi->visual, + CWBorderPixel | CWColormap, &swa); + XStoreName(dpy, win1, "Test [L]"); + XMapWindow(dpy, win1); + XMoveWindow(dpy, win1, 10, 10); /* Initial requested x,y may not be honored */ + { + XSizeHints sizehints; + static const char *name = "window"; + sizehints.x = 10; + sizehints.y = 10; + sizehints.width = 200; + sizehints.height = 200; + sizehints.flags = USSize | USPosition; + XSetNormalHints(dpy, win1, &sizehints); + XSetStandardProperties(dpy, win1, name, name, + None, (char **)NULL, 0, &sizehints); + } + + + win2 = XCreateWindow(dpy, RootWindow(dpy, vi->screen), + 250, 10, 200, 200, + 0, vi->depth, InputOutput, vi->visual, + CWBorderPixel | CWColormap, &swa); + XStoreName(dpy, win1, "Test [R]"); + XMapWindow(dpy, win2); + XMoveWindow(dpy, win2, 260, 10); + { + XSizeHints sizehints; + static const char *name = "window"; + sizehints.x = 10; + sizehints.y = 10; + sizehints.width = 200; + sizehints.height = 200; + sizehints.flags = USSize | USPosition; + XSetNormalHints(dpy, win2, &sizehints); + XSetStandardProperties(dpy, win2, name, name, + None, (char **)NULL, 0, &sizehints); + } + + + /* Now draw some spinning things */ + for (angle = 0; angle < 360*4; angle += 10.0) { + /* Connect the context to window 1 */ + glXMakeCurrent(dpy, win1, ctx1); + + /* Clear and draw in window 1 */ + glDrawBuffer(GL_BACK); + glClearColor(1, 1, 0, 1); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glColor3f(1, 0, 0); + glBegin(GL_TRIANGLES); + glVertex2f(0, 0); + glVertex2f(cos(angle * DEGTOR), sin(angle * DEGTOR)); + glVertex2f(cos((angle + 20.0) * DEGTOR), + sin((angle + 20.0) * DEGTOR)); + glEnd(); + glFlush(); + + if (test == 1 || test == 3 || test == 5) + glXSwapBuffers(dpy, win1); + + if (test == 5) + glXCopyContext(dpy, ctx1, ctx2, GL_ALL_ATTRIB_BITS); + /* Connect the context to window 2 */ + if (test == 3 || test == 4) { + glXMakeCurrent(dpy, win2, ctx1); + } else { + glXMakeCurrent(dpy, win2, ctx2); + } + + /* Clear and draw in window 2 */ + glDrawBuffer(GL_BACK); + glClearColor(0, 0, 1, 1); + glClear(GL_COLOR_BUFFER_BIT); + glColor3f(1, 1, 0); + glBegin(GL_TRIANGLES); + glVertex2f(0, 0); + glVertex2f(cos(angle * DEGTOR), sin(angle * DEGTOR)); + glVertex2f(cos((angle + 20.0) * DEGTOR), + sin((angle + 20.0) * DEGTOR)); + glEnd(); + glFlush(); + + /* Swap buffers */ + if (test == 2 || test == 4) + glXSwapBuffers(dpy, win1); + glXSwapBuffers(dpy, win2); + + /* wait a while */ + glXWaitX(); + usleep(20000); + } + + return 0; +} diff --git a/progs/tests/manytex.c b/progs/tests/manytex.c new file mode 100644 index 00000000000..70ad4a767ec --- /dev/null +++ b/progs/tests/manytex.c @@ -0,0 +1,382 @@ +/* $Id: manytex.c,v 1.5 2005-09-15 01:58:39 brianp Exp $ */ + +/* + * test handling of many texture maps + * Also tests texture priority and residency. + * + * Brian Paul + * August 2, 2000 + */ + + +#include +#include +#include +#include +#include +#include + + +static GLint NumTextures = 20; +static GLuint *TextureID = NULL; +static GLint *TextureWidth = NULL, *TextureHeight = NULL; +static GLboolean *TextureResidency = NULL; +static GLint TexWidth = 128, TexHeight = 128; +static GLfloat Zrot = 0; +static GLboolean Anim = GL_TRUE; +static GLint WinWidth = 500, WinHeight = 400; +static GLboolean MipMap = GL_FALSE; +static GLboolean LinearFilter = GL_FALSE; +static GLboolean RandomSize = GL_FALSE; +static GLint Rows, Columns; +static GLint LowPriorityCount = 0; + + +static void Idle( void ) +{ + Zrot += 1.0; + glutPostRedisplay(); +} + + +static void Display( void ) +{ + GLfloat spacing = WinWidth / Columns; + GLfloat size = spacing * 0.4; + GLint i; + + /* test residency */ + if (0) + { + GLboolean b; + GLint i, resident; + b = glAreTexturesResident(NumTextures, TextureID, TextureResidency); + if (b) { + printf("all resident\n"); + } + else { + resident = 0; + for (i = 0; i < NumTextures; i++) { + if (TextureResidency[i]) { + resident++; + } + } + printf("%d of %d texture resident\n", resident, NumTextures); + } + } + + /* render the textured quads */ + glClear( GL_COLOR_BUFFER_BIT ); + for (i = 0; i < NumTextures; i++) { + GLint row = i / Columns; + GLint col = i % Columns; + GLfloat x = col * spacing + spacing * 0.5; + GLfloat y = row * spacing + spacing * 0.5; + + GLfloat maxDim = (TextureWidth[i] > TextureHeight[i]) + ? TextureWidth[i] : TextureHeight[i]; + GLfloat w = TextureWidth[i] / maxDim; + GLfloat h = TextureHeight[i] / maxDim; + + glPushMatrix(); + glTranslatef(x, y, 0.0); + glRotatef(Zrot, 0, 0, 1); + glScalef(size, size, 1); + + glBindTexture(GL_TEXTURE_2D, TextureID[i]); + glBegin(GL_POLYGON); +#if 0 + glTexCoord2f(0, 0); glVertex2f(-1, -1); + glTexCoord2f(1, 0); glVertex2f( 1, -1); + glTexCoord2f(1, 1); glVertex2f( 1, 1); + glTexCoord2f(0, 1); glVertex2f(-1, 1); +#else + glTexCoord2f(0, 0); glVertex2f(-w, -h); + glTexCoord2f(1, 0); glVertex2f( w, -h); + glTexCoord2f(1, 1); glVertex2f( w, h); + glTexCoord2f(0, 1); glVertex2f(-w, h); +#endif + glEnd(); + glPopMatrix(); + } + + glutSwapBuffers(); +} + + +static void Reshape( int width, int height ) +{ + WinWidth = width; + WinHeight = height; + glViewport( 0, 0, width, height ); + glMatrixMode( GL_PROJECTION ); + glLoadIdentity(); + glOrtho(0, width, 0, height, -1, 1); + glMatrixMode( GL_MODELVIEW ); + glLoadIdentity(); +} + + +/* + * Return a random int in [min, max]. + */ +static int RandomInt(int min, int max) +{ + int i = rand(); + int j = i % (max - min + 1); + return min + j; +} + + + +static void Init( void ) +{ + GLint i; + + if (RandomSize) { + printf("Creating %d %s random-size textures, ", NumTextures, + MipMap ? "Mipmapped" : "non-Mipmapped"); + } + else { + printf("Creating %d %s %d x %d textures, ", NumTextures, + MipMap ? "Mipmapped" : "non-Mipmapped", + TexWidth, TexHeight); + } + + if (LinearFilter) { + printf("bilinear filtering\n"); + } + else { + printf("nearest filtering\n"); + } + + + /* compute number of rows and columns of rects */ + { + GLfloat area = (GLfloat) (WinWidth * WinHeight) / (GLfloat) NumTextures; + GLfloat edgeLen = sqrt(area); + + Columns = WinWidth / edgeLen; + Rows = (NumTextures + Columns - 1) / Columns; + printf("Rows: %d Cols: %d\n", Rows, Columns); + } + + + if (!TextureID) { + TextureID = (GLuint *) malloc(sizeof(GLuint) * NumTextures); + assert(TextureID); + glGenTextures(NumTextures, TextureID); + } + + if (!TextureResidency) { + TextureResidency = (GLboolean *) malloc(sizeof(GLboolean) * NumTextures); + assert(TextureResidency); + } + + if (!TextureWidth) { + TextureWidth = (GLint *) malloc(sizeof(GLint) * NumTextures); + assert(TextureWidth); + } + if (!TextureHeight) { + TextureHeight = (GLint *) malloc(sizeof(GLint) * NumTextures); + assert(TextureHeight); + } + + for (i = 0; i < NumTextures; i++) { + GLubyte color[4]; + GLubyte *texImage; + GLint j, row, col; + + row = i / Columns; + col = i % Columns; + + glBindTexture(GL_TEXTURE_2D, TextureID[i]); + + if (i < LowPriorityCount) + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_PRIORITY, 0.5F); + + if (RandomSize) { +#if 0 + int k = (glutGet(GLUT_ELAPSED_TIME) % 7) + 2; + TexWidth = 1 << k; + TexHeight = 1 << k; +#else + TexWidth = 1 << RandomInt(2, 7); + TexHeight = 1 << RandomInt(2, 7); + printf("Random size of %3d: %d x %d\n", i, TexWidth, TexHeight); +#endif + } + + TextureWidth[i] = TexWidth; + TextureHeight[i] = TexHeight; + + texImage = (GLubyte*) malloc(4 * TexWidth * TexHeight * sizeof(GLubyte)); + assert(texImage); + + /* determine texture color */ + color[0] = (GLint) (255.0 * ((float) col / (Columns - 1))); + color[1] = 127; + color[2] = (GLint) (255.0 * ((float) row / (Rows - 1))); + color[3] = 255; + + /* fill in solid-colored teximage */ + for (j = 0; j < TexWidth * TexHeight; j++) { + texImage[j*4+0] = color[0]; + texImage[j*4+1] = color[1]; + texImage[j*4+2] = color[2]; + texImage[j*4+3] = color[3]; + } + + if (MipMap) { + GLint level = 0; + GLint w = TexWidth, h = TexHeight; + while (1) { + glTexImage2D(GL_TEXTURE_2D, level, GL_RGBA, w, h, 0, + GL_RGBA, GL_UNSIGNED_BYTE, texImage); + if (w == 1 && h == 1) + break; + if (w > 1) + w /= 2; + if (h > 1) + h /= 2; + level++; + /*printf("%d: %d x %d\n", level, w, h);*/ + } + if (LinearFilter) { + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, + GL_LINEAR_MIPMAP_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + } + else { + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, + GL_NEAREST_MIPMAP_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + } + } + else { + /* Set corners to white */ + int k = 0; + texImage[k+0] = texImage[k+1] = texImage[k+2] = texImage[k+3] = 255; + k = (TexWidth - 1) * 4; + texImage[k+0] = texImage[k+1] = texImage[k+2] = texImage[k+3] = 255; + k = (TexWidth * TexHeight - TexWidth) * 4; + texImage[k+0] = texImage[k+1] = texImage[k+2] = texImage[k+3] = 255; + k = (TexWidth * TexHeight - 1) * 4; + texImage[k+0] = texImage[k+1] = texImage[k+2] = texImage[k+3] = 255; + + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, TexWidth, TexHeight, 0, + GL_RGBA, GL_UNSIGNED_BYTE, texImage); + if (LinearFilter) { + 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); + } + } + + free(texImage); + } + + glEnable(GL_TEXTURE_2D); +} + + +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 's': + Idle(); + break; + case 'z': + Zrot -= step; + break; + case 'Z': + Zrot += step; + break; + case ' ': + Init(); + break; + case 27: + exit(0); + break; + } + glutPostRedisplay(); +} + + +int main( int argc, char *argv[] ) +{ + GLint i; + + glutInit( &argc, argv ); + glutInitWindowPosition( 0, 0 ); + glutInitWindowSize( WinWidth, WinHeight ); + glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE ); + glutCreateWindow(argv[0]); + glutReshapeFunc( Reshape ); + glutKeyboardFunc( Key ); + glutDisplayFunc( Display ); + if (Anim) + glutIdleFunc(Idle); + + for (i = 1; i < argc; i++) { + if (strcmp(argv[i], "-n") == 0) { + NumTextures = atoi(argv[i+1]); + if (NumTextures <= 0) { + printf("Error, bad number of textures\n"); + return 1; + } + i++; + } + else if (strcmp(argv[i], "-mipmap") == 0) { + MipMap = GL_TRUE; + } + else if (strcmp(argv[i], "-linear") == 0) { + LinearFilter = GL_TRUE; + } + else if (strcmp(argv[i], "-size") == 0) { + TexWidth = atoi(argv[i+1]); + TexHeight = atoi(argv[i+2]); + assert(TexWidth >= 1); + assert(TexHeight >= 1); + i += 2; + } + else if (strcmp(argv[i], "-randomsize") == 0) { + RandomSize = GL_TRUE; + } + else if (strcmp(argv[i], "-lowpri") == 0) { + LowPriorityCount = atoi(argv[i+1]); + i++; + } + else { + printf("Usage:\n"); + printf(" manytex [options]\n"); + printf("Options:\n"); + printf(" -n \n"); + printf(" -size - specify texture size\n"); + printf(" -randomsize - use random size textures\n"); + printf(" -mipmap - generate mipmaps\n"); + printf(" -linear - use linear filtering instead of nearest\n"); + printf(" -lowpri - Set lower priority on textures\n"); + return 0; + } + } + + Init(); + + glutMainLoop(); + + return 0; +} diff --git a/progs/tests/mipmap_limits.c b/progs/tests/mipmap_limits.c new file mode 100644 index 00000000000..6f6d893f77c --- /dev/null +++ b/progs/tests/mipmap_limits.c @@ -0,0 +1,233 @@ +/* Test GL_TEXTURE_BASE_LEVEL and GL_TEXTURE_MAX_LEVEL + * Brian Paul + * 10 May 2006 + */ + + +/* Copyright (c) Mark J. Kilgard, 1994. */ + +/* + * (c) Copyright 1993, Silicon Graphics, Inc. + * ALL RIGHTS RESERVED + * Permission to use, copy, modify, and distribute this software for + * any purpose and without fee is hereby granted, provided that the above + * copyright notice appear in all copies and that both the copyright notice + * and this permission notice appear in supporting documentation, and that + * the name of Silicon Graphics, Inc. not be used in advertising + * or publicity pertaining to distribution of the software without specific, + * written prior permission. + * + * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS" + * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR + * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON + * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, + * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY + * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, + * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF + * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN + * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE + * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE. + * + * US Government Users Restricted Rights + * Use, duplication, or disclosure by the Government is subject to + * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph + * (c)(1)(ii) of the Rights in Technical Data and Computer Software + * clause at DFARS 252.227-7013 and/or in similar or successor + * clauses in the FAR or the DOD or NASA FAR Supplement. + * Unpublished-- rights reserved under the copyright laws of the + * United States. Contractor/manufacturer is Silicon Graphics, + * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. + * + * OpenGL(TM) is a trademark of Silicon Graphics, Inc. + */ +/* mipmap.c + * This program demonstrates using mipmaps for texture maps. + * To overtly show the effect of mipmaps, each mipmap reduction + * level has a solidly colored, contrasting texture image. + * Thus, the quadrilateral which is drawn is drawn with several + * different colors. + */ +#include +#include +#include + +static GLint BaseLevel = 0, MaxLevel = 8; +static GLfloat LodBias = 0.0; +static GLboolean NearestFilter = GL_TRUE; + + +static void MakeImage(int level, int width, int height, const GLubyte color[4]) +{ + const int makeStripes = 0; + GLubyte img[256*256*3]; + int i, j; + for (i = 0; i < height; i++) { + for (j = 0; j < width; j++) { + int k = (i * width + j) * 3; + int p = (i/8) & makeStripes; + if (p == 0) { + img[k + 0] = color[0]; + img[k + 1] = color[1]; + img[k + 2] = color[2]; + } + else { + img[k + 0] = 0; + img[k + 1] = 0; + img[k + 2] = 0; + } + } + } + + glTexImage2D(GL_TEXTURE_2D, level, GL_RGB, width, height, 0, + GL_RGB, GL_UNSIGNED_BYTE, img); +} + + +static void makeImages(void) +{ + static const GLubyte colors[8][3] = { + {128, 128, 128 }, + { 0, 255, 255 }, + { 255, 255, 0 }, + { 255, 0, 255 }, + { 255, 0, 0 }, + { 0, 255, 0 }, + { 0, 0, 255 }, + { 255, 255, 255 } + }; + int i, sz = 128; + + for (i = 0; i < 8; i++) { + MakeImage(i, sz, sz, colors[i]); + sz /= 2; + } +} + +static void myinit(void) +{ + glEnable(GL_DEPTH_TEST); + glDepthFunc(GL_LESS); + glShadeModel(GL_FLAT); + + glTranslatef(0.0, 0.0, -3.6); + + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + makeImages(); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); + glEnable(GL_TEXTURE_2D); +} + +static void display(void) +{ + GLfloat tcm = 4.0; + printf("GL_TEXTURE_BASE_LEVEL = %d GL_TEXTURE_MAX_LEVEL = %d Bias = %.2g filter = %s\n", + BaseLevel, MaxLevel, LodBias, + NearestFilter ? "LINEAR" : "NEAREST"); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, BaseLevel); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, MaxLevel); + + if (NearestFilter) { + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, + GL_NEAREST_MIPMAP_NEAREST); + } + else { + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, + GL_LINEAR_MIPMAP_LINEAR); + } + + glTexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, LodBias); + + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glBegin(GL_QUADS); + glTexCoord2f(0.0, 0.0); glVertex3f(-2.0, -1.0, 0.0); + glTexCoord2f(0.0, tcm); glVertex3f(-2.0, 1.0, 0.0); + glTexCoord2f(tcm, tcm); glVertex3f(3000.0, 1.0, -6000.0); + glTexCoord2f(tcm, 0.0); glVertex3f(3000.0, -1.0, -6000.0); + glEnd(); + glFlush(); +} + +static void myReshape(int w, int h) +{ + glViewport(0, 0, w, h); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluPerspective(60.0, 1.0*(GLfloat)w/(GLfloat)h, 1.0, 30000.0); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); +} + +static void +key(unsigned char k, int x, int y) +{ + (void) x; + (void) y; + switch (k) { + case 'b': + BaseLevel--; + if (BaseLevel < 0) + BaseLevel = 0; + break; + case 'B': + BaseLevel++; + if (BaseLevel > 10) + BaseLevel = 10; + break; + case 'm': + MaxLevel--; + if (MaxLevel < 0) + MaxLevel = 0; + break; + case 'M': + MaxLevel++; + if (MaxLevel > 10) + MaxLevel = 10; + break; + case 'l': + LodBias -= 0.02; + break; + case 'L': + LodBias += 0.02; + break; + case 'f': + NearestFilter = !NearestFilter; + break; + case 27: /* Escape */ + exit(0); + break; + default: + return; + } + glutPostRedisplay(); +} + + +static void usage(void) +{ + printf("usage:\n"); + printf(" b/B decrease/increase GL_TEXTURE_BASE_LEVEL\n"); + printf(" m/M decrease/increase GL_TEXTURE_MAX_LEVEL\n"); + printf(" f toggle nearest/linear filtering\n"); +} + + +int main(int argc, char** argv) +{ + glutInit(&argc, argv); + glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH); + glutInitWindowSize (600, 600); + glutCreateWindow (argv[0]); + myinit(); + glutReshapeFunc (myReshape); + glutDisplayFunc(display); + glutKeyboardFunc(key); + usage(); + glutMainLoop(); + return 0; /* ANSI C requires main to return int. */ +} diff --git a/progs/tests/multipal.c b/progs/tests/multipal.c new file mode 100644 index 00000000000..6ae33d751a6 --- /dev/null +++ b/progs/tests/multipal.c @@ -0,0 +1,377 @@ +/* $Id: multipal.c,v 1.6 2003-12-08 09:03:36 joukj Exp $ */ + +/* + * Test multitexture and paletted textures. + */ + +#include +#include +#include +#include +#include +#ifdef __VMS +# include /* for ptrdiff_t, referenced by GL.h when GL_GLEXT_LEGACY defined */ +#else +# include /* for ptrdiff_t, referenced by GL.h when GL_GLEXT_LEGACY defined */ +#endif +#ifdef _WIN32 +#include +#endif +#define GL_GLEXT_LEGACY +#include + +#include "../util/readtex.c" /* I know, this is a hack. */ + +#define TEXTURE_1_FILE "../images/tile.rgb" +#define TEXTURE_2_FILE "../images/reflect.rgb" + +#define TEX0 1 +#define TEX1 2 +#define TEXBOTH 3 +#define ANIMATE 10 +#define QUIT 100 + +static GLboolean Animate = GL_TRUE; + +static GLfloat Drift = 0.0; +static GLfloat Xrot = 20.0, Yrot = 30.0, Zrot = 0.0; + + + +static void Idle( void ) +{ + if (Animate) { + Drift += 0.05; + if (Drift >= 1.0) + Drift = 0.0; + +#ifdef GL_ARB_multitexture + glActiveTextureARB(GL_TEXTURE0_ARB); +#endif + glMatrixMode(GL_TEXTURE); + glLoadIdentity(); + glTranslatef(Drift, 0.0, 0.0); + glMatrixMode(GL_MODELVIEW); + +#ifdef GL_ARB_multitexture + glActiveTextureARB(GL_TEXTURE1_ARB); +#endif + glMatrixMode(GL_TEXTURE); + glLoadIdentity(); + glTranslatef(0.0, Drift, 0.0); + glMatrixMode(GL_MODELVIEW); + + glutPostRedisplay(); + } +} + + +static void DrawObject(void) +{ + glBegin(GL_QUADS); + +#ifdef GL_ARB_multitexture + glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.0, 0.0); + glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.0, 0.0); + glVertex2f(-1.0, -1.0); + + glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 2.0, 0.0); + glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 1.0, 0.0); + glVertex2f(1.0, -1.0); + + glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 2.0, 2.0); + glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 1.0, 1.0); + glVertex2f(1.0, 1.0); + + glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.0, 2.0); + glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.0, 1.0); + glVertex2f(-1.0, 1.0); +#else + glTexCoord2f(0.0, 0.0); + glVertex2f(-1.0, -1.0); + + glTexCoord2f(1.0, 0.0); + glVertex2f(1.0, -1.0); + + glTexCoord2f(1.0, 1.0); + glVertex2f(1.0, 1.0); + + glTexCoord2f(0.0, 1.0); + glVertex2f(-1.0, 1.0); +#endif + + glEnd(); +} + + + +static void Display( void ) +{ + glClear( GL_COLOR_BUFFER_BIT ); + + glPushMatrix(); + glRotatef(Xrot, 1.0, 0.0, 0.0); + glRotatef(Yrot, 0.0, 1.0, 0.0); + glRotatef(Zrot, 0.0, 0.0, 1.0); + glScalef(5.0, 5.0, 5.0); + DrawObject(); + glPopMatrix(); + + glutSwapBuffers(); +} + + +static void Reshape( int width, int height ) +{ + glViewport( 0, 0, width, height ); + glMatrixMode( GL_PROJECTION ); + glLoadIdentity(); + glFrustum( -1.0, 1.0, -1.0, 1.0, 10.0, 100.0 ); + /*glOrtho( -6.0, 6.0, -6.0, 6.0, 10.0, 100.0 );*/ + glMatrixMode( GL_MODELVIEW ); + glLoadIdentity(); + glTranslatef( 0.0, 0.0, -70.0 ); +} + + +static void ModeMenu(int entry) +{ + GLboolean enable0 = GL_FALSE, enable1 = GL_FALSE; + if (entry==TEX0) { + enable0 = GL_TRUE; + } + else if (entry==TEX1) { + enable1 = GL_TRUE; + } + else if (entry==TEXBOTH) { + enable0 = GL_TRUE; + enable1 = GL_TRUE; + } + else if (entry==ANIMATE) { + Animate = !Animate; + } + else if (entry==QUIT) { + exit(0); + } + + if (entry != ANIMATE) { +#ifdef GL_ARB_multitexture + glActiveTextureARB(GL_TEXTURE0_ARB); +#endif + if (enable0) { + glEnable(GL_TEXTURE_2D); + } + else + glDisable(GL_TEXTURE_2D); + +#ifdef GL_ARB_multitexture + glActiveTextureARB(GL_TEXTURE1_ARB); +#endif + if (enable1) { + glEnable(GL_TEXTURE_2D); + } + else + glDisable(GL_TEXTURE_2D); + } + + glutPostRedisplay(); +} + + +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 ) +{ + float 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 load_tex(const char *fname, int channel) +{ + GLubyte *image; + GLenum format; + GLint w, h; + GLubyte *grayImage; + int i; + GLubyte table[256][4]; + + image = LoadRGBImage(fname, &w, &h, &format); + if (!image) + exit(1); + + printf("%s %d x %d\n", fname, w, h); + grayImage = malloc(w * h * 1); + assert(grayImage); + for (i = 0; i < w * h; i++) { + int g = (image[i*3+0] + image[i*3+1] + image[i*3+2]) / 3; + assert(g < 256); + grayImage[i] = g; + } + + glTexImage2D(GL_TEXTURE_2D, 0, GL_COLOR_INDEX, w, h, 0, GL_COLOR_INDEX, + GL_UNSIGNED_BYTE, grayImage); + + for (i = 0; i < 256; i++) { + table[i][0] = channel ? i : 0; + table[i][1] = i; + table[i][2] = channel ? 0 : i; + table[i][3] = 255; + } + + glColorTableEXT(GL_TEXTURE_2D, /* target */ + GL_RGBA, /* internal format */ + 256, /* table size */ + GL_RGBA, /* table format */ + GL_UNSIGNED_BYTE, /* table type */ + table); /* the color table */ + + free(grayImage); + free(image); +} + + + +static void Init( int argc, char *argv[] ) +{ + GLuint texObj[2]; + GLint units; + + if (!glutExtensionSupported("GL_ARB_multitexture")) { + printf("Sorry, GL_ARB_multitexture not supported by this renderer.\n"); + exit(1); + } + if (!glutExtensionSupported("GL_EXT_paletted_texture")) { + printf("Sorry, GL_EXT_paletted_texture not supported by this renderer.\n"); + exit(1); + } + + glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &units); + printf("%d texture units supported\n", units); + + /* allocate two texture objects */ + glGenTextures(2, texObj); + + /* setup texture obj 0 */ + glBindTexture(GL_TEXTURE_2D, texObj[0]); +#ifdef LINEAR_FILTER + /* linear filtering looks much nicer but is much slower for Mesa */ + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); +foo +#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_MODULATE); + + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + + load_tex(TEXTURE_1_FILE, 0); +#if 0 + if (!LoadRGBMipmaps(TEXTURE_1_FILE, GL_RGB)) { + printf("Error: couldn't load texture image\n"); + exit(1); + } +#endif + + /* setup texture obj 1 */ + glBindTexture(GL_TEXTURE_2D, texObj[1]); +#ifdef LINEAR_FILTER + /* linear filtering looks much nicer but is much slower for Mesa */ + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); +foo +#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_MODULATE); + + load_tex(TEXTURE_2_FILE, 1); +#if 0 + if (!LoadRGBMipmaps(TEXTURE_2_FILE, GL_RGB)) { + printf("Error: couldn't load texture image\n"); + exit(1); + } +#endif + + /* now bind the texture objects to the respective texture units */ +#ifdef GL_ARB_multitexture + glActiveTextureARB(GL_TEXTURE0_ARB); + glBindTexture(GL_TEXTURE_2D, texObj[0]); + glActiveTextureARB(GL_TEXTURE1_ARB); + glBindTexture(GL_TEXTURE_2D, texObj[1]); +#endif + + glShadeModel(GL_FLAT); + glClearColor(0.3, 0.3, 0.4, 1.0); + + ModeMenu(TEXBOTH); + + 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)); + } +} + + +int main( int argc, char *argv[] ) +{ + glutInit( &argc, argv ); + glutInitWindowSize( 300, 300 ); + glutInitWindowPosition( 0, 0 ); + glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE ); + glutCreateWindow(argv[0] ); + + Init( argc, argv ); + + glutReshapeFunc( Reshape ); + glutKeyboardFunc( Key ); + glutSpecialFunc( SpecialKey ); + glutDisplayFunc( Display ); + glutIdleFunc( Idle ); + + glutCreateMenu(ModeMenu); + glutAddMenuEntry("Texture 0", TEX0); + glutAddMenuEntry("Texture 1", TEX1); + glutAddMenuEntry("Multi-texture", TEXBOTH); + glutAddMenuEntry("Toggle Animation", ANIMATE); + glutAddMenuEntry("Quit", QUIT); + glutAttachMenu(GLUT_RIGHT_BUTTON); + + glutMainLoop(); + return 0; +} diff --git a/progs/tests/multitexarray.c b/progs/tests/multitexarray.c new file mode 100644 index 00000000000..b4fab004a63 --- /dev/null +++ b/progs/tests/multitexarray.c @@ -0,0 +1,238 @@ +/* + * Test vertex arrays and multitexture. + * Press 'a' to toggle vertex arrays on/off. + * When you run this program you should see a square with four colors: + * + * +------+------+ + * |yellow| pink | + * +------+------+ + * |green | blue | + * +------+------+ + */ + + +#include +#include +#include +#include +#include +#include "GL/glut.h" + +static GLuint Window = 0; + +static GLuint TexObj[2]; +static GLfloat Angle = 0.0f; +static GLboolean UseArrays = 1, Anim = 0; + +static GLfloat VertArray[4][2] = { + {-1.2, -1.2}, {1.2, -1.2}, {1.2, 1.2}, {-1.2, 1.2} +}; + +static GLfloat Tex0Array[4][2] = { + {0, 0}, {1, 0}, {1, 1}, {0, 1} +}; + +static GLfloat Tex1Array[4][2] = { + {0, 0}, {1, 0}, {1, 1}, {0, 1} +}; + + +static void init_arrays(void) +{ + glVertexPointer(2, GL_FLOAT, 0, VertArray); + glEnableClientState(GL_VERTEX_ARRAY); + + glClientActiveTextureARB(GL_TEXTURE0_ARB); + glTexCoordPointer(2, GL_FLOAT, 0, Tex0Array); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + + glClientActiveTextureARB(GL_TEXTURE1_ARB); + glTexCoordPointer(2, GL_FLOAT, 0, Tex1Array); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); +} + + +static void draw( void ) +{ + glClear( GL_COLOR_BUFFER_BIT ); + + glColor3f( 0.0, 0.0, 0.0 ); + + /* draw first polygon */ + glPushMatrix(); + glRotatef( Angle, 0.0, 0.0, 1.0 ); + + if (UseArrays) { + glDrawArrays(GL_POLYGON, 0, 4); + } + else { + glBegin( GL_POLYGON ); + glTexCoord2f( 0.0, 0.0 ); + glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.0, 0.0); + glVertex2f( -1.0, -1.0 ); + + glTexCoord2f( 1.0, 0.0 ); + glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 1.0, 0.0); + glVertex2f( 1.0, -1.0 ); + + glTexCoord2f( 1.0, 1.0 ); + glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 1.0, 1.0); + glVertex2f( 1.0, 1.0 ); + + glTexCoord2f( 0.0, 1.0 ); + glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.0, 1.0); + glVertex2f( -1.0, 1.0 ); + glEnd(); + } + + glPopMatrix(); + + glutSwapBuffers(); +} + + + +static void idle( void ) +{ + Angle += 2.0; + glutPostRedisplay(); +} + + + +/* change view Angle, exit upon ESC */ +static void key(unsigned char k, int x, int y) +{ + (void) x; + (void) y; + switch (k) { + case 'a': + UseArrays = !UseArrays; + printf("UseArrays: %d\n", UseArrays); + break; + case ' ': + Anim = !Anim; + if (Anim) + glutIdleFunc(idle); + else + glutIdleFunc(NULL); + break; + case 27: + glDeleteTextures( 2, TexObj ); + glutDestroyWindow(Window); + exit(0); + } + glutPostRedisplay(); +} + + + +/* new window size or exposure */ +static void reshape( int width, int height ) +{ + glViewport(0, 0, (GLint)width, (GLint)height); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + /* glOrtho( -3.0, 3.0, -3.0, 3.0, -10.0, 10.0 );*/ + 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 ) +{ + static int width=8, height=8; + GLubyte tex[64][3]; + GLint i, j; + + /* generate texture object IDs */ + glGenTextures( 2, TexObj ); + + /* + * setup first texture object + */ + glActiveTextureARB(GL_TEXTURE0_ARB); + glEnable( GL_TEXTURE_2D ); + glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_ADD ); + + glBindTexture( GL_TEXTURE_2D, TexObj[0] ); + assert(glIsTexture(TexObj[0])); + + /* red over black */ + for (i=0;i +#include +#include +#include + + +static GLint Window[2]; + +static GLfloat Xrot = 0, Yrot = 0, Zrot = 0; +static GLboolean Anim = GL_TRUE; + + +static void Idle( void ) +{ + Xrot += 3.0; + Yrot += 4.0; + Zrot += 2.0; + + glutSetWindow(Window[0]); + glutPostRedisplay(); + glutSetWindow(Window[1]); + glutPostRedisplay(); +} + + +static void Display0( void ) +{ + glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); + + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + glEnable(GL_DEPTH_TEST); + + glPushMatrix(); + glRotatef(Xrot, 1, 0, 0); + glRotatef(Yrot, 0, 1, 0); + glRotatef(Zrot, 0, 0, 1); + + glColor3f(0, 1, 0); + glutSolidCube(2.0); + + glPopMatrix(); + + glutSwapBuffers(); +} + + +static void Display1( void ) +{ + glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); + + glPushMatrix(); + glRotatef(Xrot, 1, 0, 0); + glRotatef(Yrot, 0, 1, 0); + glRotatef(Zrot, 0, 0, 1); + + glShadeModel(GL_FLAT); + + glBegin(GL_TRIANGLE_STRIP); + glColor3f(1, 0, 0); + glVertex2f(-1, -1); + glVertex2f( 1, -1); + glColor3f(1, 0, 0); + glVertex2f( -1, 1); + glColor3f(0, 0, 1); + glVertex2f( 1, 1); + glEnd(); + + glPopMatrix(); + + glutSwapBuffers(); +} + + +static void Reshape( int width, int height ) +{ + glViewport( 0, 0, width, height ); + glMatrixMode( GL_PROJECTION ); + glLoadIdentity(); + glFrustum( -1.0, 1.0, -1.0, 1.0, 5.0, 25.0 ); + glMatrixMode( GL_MODELVIEW ); + glLoadIdentity(); + glTranslatef( 0.0, 0.0, -15.0 ); +} + + +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 27: + exit(0); + break; + } + glutPostRedisplay(); +} + + + + +int main( int argc, char *argv[] ) +{ + glutInit( &argc, argv ); + + glutInitWindowPosition( 0, 0 ); + glutInitWindowSize( 400, 400 ); + glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ); + Window[0] = glutCreateWindow(argv[0]); + glutReshapeFunc( Reshape ); + glutKeyboardFunc( Key ); + glutDisplayFunc( Display0 ); + glutIdleFunc(Idle); + printf("GL_RENDERER[0] = %s\n", (char *) glGetString(GL_RENDERER)); + + glutInitWindowPosition( 500, 0 ); + glutInitWindowSize( 400, 400 ); + glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ); + Window[1] = glutCreateWindow(argv[0]); + glutReshapeFunc( Reshape ); + glutKeyboardFunc( Key ); + glutDisplayFunc( Display1 ); + glutIdleFunc(Idle); + printf("GL_RENDERER[1] = %s\n", (char *) glGetString(GL_RENDERER)); + + glutMainLoop(); + + return 0; +} diff --git a/progs/tests/no_s3tc.c b/progs/tests/no_s3tc.c new file mode 100644 index 00000000000..d3383ff98af --- /dev/null +++ b/progs/tests/no_s3tc.c @@ -0,0 +1,97 @@ +/* + * (C) Copyright IBM Corporation 2004 + * 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 + * on the rights to use, copy, modify, merge, publish, distribute, sub + * license, 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 (including the next + * paragraph) 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 NON-INFRINGEMENT. IN NO EVENT SHALL + * VA LINUX SYSTEM, IBM AND/OR THEIR SUPPLIERS 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. + */ + +/** + * \file no_s3tc.c + * Test program to verify the behavior of an OpenGL implementation when + * an application calls \c glCompressedTexImage2D with an unsupported (but + * valid) compression format. The most common example is calling it with + * \c GL_COMPRESSED_RGBA_S3TC_DXT1_EXT when GL_EXT_texture_compression_s3tc + * is not supported. + * + * This tests Mesa bug #1028405. + * + * \author Ian Romanick + */ + +#include +#include +#include +#include +#include + +static unsigned data[16]; + +int +main( int argc, char ** argv ) +{ + float gl_version; + GLenum format; + GLuint size; + GLuint width; + GLenum err; + + + glutInit( & argc, argv ); + glutInitDisplayMode( GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE ); + + glutInitWindowPosition( 0, 0 ); + glutInitWindowSize( 300, 300 ); + glutCreateWindow( "No S3TC Test" ); + + gl_version = strtod( (const char *) glGetString( GL_VERSION ), NULL ); + if ( ! glutExtensionSupported( "GL_ARB_texture_compression" ) + && (gl_version < 1.3) ) { + fprintf( stderr, "Either OpenGL 1.3 or GL_ARB_texture_compression " + "must be supported.\n" ); + return( EXIT_SUCCESS ); + } + + + if ( ! glutExtensionSupported( "GL_EXT_texture_compression_s3tc" ) ) { + format = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT; + width = 4; + size = 8; + } + else if ( ! glutExtensionSupported( "GL_3DFX_texture_compression_FXT1" ) ) { + format = GL_COMPRESSED_RGBA_FXT1_3DFX; + width = 8; + size = 16; + } + else { + fprintf( stderr, "Either GL_EXT_texture_compression_s3tc or " + "GL_3DFX_texture_compression_FXT1 must NOT be supported.\n" ); + return( EXIT_SUCCESS ); + } + + glCompressedTexImage2D( GL_TEXTURE_2D, 0, format, width, 4, 0, + size, data ); + err = glGetError(); + if ( err != GL_INVALID_ENUM ) { + fprintf( stderr, "GL error 0x%04x should have been generated, but " + "0x%04x was generated instead.\n", GL_INVALID_ENUM, err ); + } + + return (err == GL_INVALID_ENUM) ? EXIT_SUCCESS : EXIT_FAILURE; +} diff --git a/progs/tests/packedpixels.c b/progs/tests/packedpixels.c new file mode 100644 index 00000000000..67ffe088259 --- /dev/null +++ b/progs/tests/packedpixels.c @@ -0,0 +1,342 @@ +/* + * Test packed pixel formats for textures. + * Brian Paul + * 12 May 2004 + */ + +#include +#include +#include +#include +#include + + +struct pixel_format { + const char *name; + GLenum format; + GLenum type; + GLint bytes; + GLuint redTexel, greenTexel; +}; + +static const struct pixel_format Formats[] = { + + { "GL_RGBA/GL_UNSIGNED_INT_8_8_8_8", + GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, 4, 0xff000000, 0x00ff0000 }, + { "GL_RGBA/GL_UNSIGNED_INT_8_8_8_8_REV", + GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, 4, 0x000000ff, 0x0000ff00 }, + { "GL_RGBA/GL_UNSIGNED_INT_10_10_10_2", + GL_RGBA, GL_UNSIGNED_INT_10_10_10_2, 4, 0xffc00000, 0x3ff000 }, + { "GL_RGBA/GL_UNSIGNED_INT_2_10_10_10_REV", + GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV, 4, 0x3ff, 0xffc00 }, + { "GL_RGBA/GL_UNSIGNED_SHORT_4_4_4_4", + GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, 2, 0xf000, 0x0f00 }, + { "GL_RGBA/GL_UNSIGNED_SHORT_4_4_4_4_REV", + GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4_REV, 2, 0x000f, 0x00f0 }, + { "GL_RGBA/GL_UNSIGNED_SHORT_5_5_5_1", + GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, 2, 0xf800, 0x7c0 }, + { "GL_RGBA/GL_UNSIGNED_SHORT_1_5_5_5_REV", + GL_RGBA, GL_UNSIGNED_SHORT_1_5_5_5_REV, 2, 0x1f, 0x3e0 }, + + { "GL_BGRA/GL_UNSIGNED_INT_8_8_8_8", + GL_BGRA, GL_UNSIGNED_INT_8_8_8_8, 4, 0x0000ff00, 0x00ff0000 }, + { "GL_BGRA/GL_UNSIGNED_INT_8_8_8_8_REV", + GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, 4, 0x00ff0000, 0x0000ff00 }, + { "GL_BGRA/GL_UNSIGNED_SHORT_4_4_4_4", + GL_BGRA, GL_UNSIGNED_SHORT_4_4_4_4, 2, 0x00f0, 0x0f00 }, + { "GL_BGRA/GL_UNSIGNED_SHORT_4_4_4_4_REV", + GL_BGRA, GL_UNSIGNED_SHORT_4_4_4_4_REV, 2, 0x0f00, 0x00f0 }, + { "GL_BGRA/GL_UNSIGNED_SHORT_5_5_5_1", + GL_BGRA, GL_UNSIGNED_SHORT_5_5_5_1, 2, 0x3e, 0x7c0 }, + { "GL_BGRA/GL_UNSIGNED_SHORT_1_5_5_5_REV", + GL_BGRA, GL_UNSIGNED_SHORT_1_5_5_5_REV, 2, 0x7c00, 0x3e0 }, + + { "GL_ABGR_EXT/GL_UNSIGNED_INT_8_8_8_8", + GL_ABGR_EXT, GL_UNSIGNED_INT_8_8_8_8, 4, 0x000000ff, 0x0000ff00 }, + { "GL_ABGR_EXT/GL_UNSIGNED_INT_8_8_8_8_REV", + GL_ABGR_EXT, GL_UNSIGNED_INT_8_8_8_8_REV, 4, 0xff000000, 0x00ff0000 }, + { "GL_ABGR_EXT/GL_UNSIGNED_SHORT_4_4_4_4", + GL_ABGR_EXT, GL_UNSIGNED_SHORT_4_4_4_4, 2, 0x000f, 0x00f0 }, + { "GL_ABGR_EXT/GL_UNSIGNED_SHORT_4_4_4_4_REV", + GL_ABGR_EXT, GL_UNSIGNED_SHORT_4_4_4_4_REV, 2, 0xf000, 0x0f00 }, + { "GL_ABGR_EXT/GL_UNSIGNED_SHORT_5_5_5_1", + GL_ABGR_EXT, GL_UNSIGNED_SHORT_5_5_5_1, 2, 0x1, 0x3e }, + { "GL_ABGR_EXT/GL_UNSIGNED_SHORT_1_5_5_5_REV", + GL_ABGR_EXT, GL_UNSIGNED_SHORT_1_5_5_5_REV, 2, 0x8000, 0x7c00 }, + + { "GL_RGB/GL_UNSIGNED_SHORT_5_6_5", + GL_RGB, GL_UNSIGNED_SHORT_5_6_5, 2, 0xf800, 0x7e0 }, + { "GL_RGB/GL_UNSIGNED_SHORT_5_6_5_REV", + GL_RGB, GL_UNSIGNED_SHORT_5_6_5_REV, 2, 0x1f, 0x7e0 }, + { "GL_RGB/GL_UNSIGNED_BYTE_3_3_2", + GL_RGB, GL_UNSIGNED_BYTE_3_3_2, 1, 0xe0, 0x1c }, + { "GL_RGB/GL_UNSIGNED_BYTE_2_3_3_REV", + GL_RGB, GL_UNSIGNED_BYTE_2_3_3_REV, 1, 0x7, 0x38 }, + + { NULL, 0, 0, 0, 0, 0 } +}; + + +struct name_format { + const char *name; + GLenum format; +}; + +static const struct name_format IntFormats[] = { + { "GL_RGBA", GL_RGBA }, + { "GL_RGBA2", GL_RGBA2 }, + { "GL_RGBA4", GL_RGBA4 }, + { "GL_RGB5_A1", GL_RGB5_A1 }, + { "GL_RGBA8", GL_RGBA8 }, + { "GL_RGBA12", GL_RGBA12 }, + { "GL_RGBA16", GL_RGBA16 }, + { "GL_RGB10_A2", GL_RGB10_A2 }, + + { "GL_RGB", GL_RGB }, + { "GL_R3_G3_B2", GL_R3_G3_B2 }, + { "GL_RGB4", GL_RGB4 }, + { "GL_RGB5", GL_RGB5 }, + { "GL_RGB8", GL_RGB8 }, + { "GL_RGB10", GL_RGB10 }, + { "GL_RGB12", GL_RGB12 }, + { "GL_RGB16", GL_RGB16 }, + +}; + +#define NUM_INT_FORMATS (sizeof(IntFormats) / sizeof(IntFormats[0])) +static GLuint CurFormat = 0; + +static GLboolean Test3D = GL_FALSE; + + + +static void +PrintString(const char *s) +{ + while (*s) { + glutBitmapCharacter(GLUT_BITMAP_8_BY_13, (int) *s); + s++; + } +} + + +static void +MakeTexture(const struct pixel_format *format, GLenum intFormat, GLboolean swap) +{ + GLubyte texBuffer[1000]; + int i; + + glPixelStorei(GL_UNPACK_SWAP_BYTES, swap); + + if (format->bytes == 1) { + for (i = 0; i < 8; i++) { + texBuffer[i] = format->redTexel; + } + for (i = 8; i < 16; i++) { + texBuffer[i] = format->greenTexel; + } + } + else if (format->bytes == 2) { + GLushort *us = (GLushort *) texBuffer; + for (i = 0; i < 8; i++) { + us[i] = format->redTexel; + } + for (i = 8; i < 16; i++) { + us[i] = format->greenTexel; + } + if (swap) { + for (i = 0; i < 16; i++) + us[i] = (us[i] << 8) | (us[i] >> 8); + } + } + else if (format->bytes == 4) { + GLuint *ui = (GLuint *) texBuffer; + for (i = 0; i < 8; i++) { + ui[i] = format->redTexel; + } + for (i = 8; i < 16; i++) { + ui[i] = format->greenTexel; + } + if (swap) { + for (i = 0; i < 16; i++) { + GLuint b = ui[i]; + ui[i] = (b >> 24) + | ((b >> 8) & 0xff00) + | ((b << 8) & 0xff0000) + | ((b << 24) & 0xff000000); + } + } + } + else { + abort(); + } + + if (Test3D) { + /* 4 x 4 x 4 texture, undefined data */ + glTexImage3D(GL_TEXTURE_3D, 0, intFormat, 4, 4, 4, 0, + format->format, format->type, NULL); + /* fill in Z=1 and Z=2 slices with the real texture data */ + glTexSubImage3D(GL_TEXTURE_3D, 0, + 0, 0, 1, /* offset */ + 4, 4, 1, /* size */ + format->format, format->type, texBuffer); + glTexSubImage3D(GL_TEXTURE_3D, 0, + 0, 0, 2, /* offset */ + 4, 4, 1, /* size */ + format->format, format->type, texBuffer); + } + else { + glTexImage2D(GL_TEXTURE_2D, 0, intFormat, 4, 4, 0, + format->format, format->type, texBuffer); + } + + if (glGetError()) { + printf("GL Error for %s\n", format->name); + memset(texBuffer, 255, 1000); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 4, 4, 0, + GL_RGB, GL_UNSIGNED_BYTE, texBuffer); + } +} + + + +static void +Draw(void) +{ + char s[1000]; + int w = 350, h = 20; + int i, swap; + + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + for (swap = 0; swap < 2; swap++) { + for (i = 0; Formats[i].name; i++) { + glPushMatrix(); + glTranslatef(swap * (w + 2), i * (h + 2), 0); + + MakeTexture(Formats + i, IntFormats[CurFormat].format, swap); + + if (Test3D) + glEnable(GL_TEXTURE_3D); + else + glEnable(GL_TEXTURE_2D); + glBegin(GL_POLYGON); + glTexCoord3f(0, 0, 0.5); glVertex2f(0, 0); + glTexCoord3f(1, 0, 0.5); glVertex2f(w, 0); + glTexCoord3f(1, 1, 0.5); glVertex2f(w, h); + glTexCoord3f(0, 1, 0.5); glVertex2f(0, h); + glEnd(); + + if (Test3D) + glDisable(GL_TEXTURE_3D); + else + glDisable(GL_TEXTURE_2D); + glColor3f(0, 0, 0); + glRasterPos2i(8, 6); + PrintString(Formats[i].name); + + glPopMatrix(); + } + } + + glPushMatrix(); + glTranslatef(2, i * (h + 2), 0); + glColor3f(1, 1, 1); + glRasterPos2i(8, 6); + PrintString("Normal"); + glRasterPos2i(w + 2, 6); + PrintString("Byte Swapped"); + glPopMatrix(); + + glPushMatrix(); + glTranslatef(2, (i + 1) * (h + 2), 0); + glRasterPos2i(8, 6); + sprintf(s, "Internal Texture Format [f/F]: %s (%d of %d)", + IntFormats[CurFormat].name, CurFormat + 1, NUM_INT_FORMATS); + PrintString(s); + glPopMatrix(); + + glPushMatrix(); + glTranslatef(2, (i + 2) * (h + 2), 0); + glRasterPos2i(8, 6); + if (Test3D) + PrintString("Target [2/3]: GL_TEXTURE_3D"); + else + PrintString("Target [2/3]: GL_TEXTURE_2D"); + glPopMatrix(); + + 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 'F': + if (CurFormat == 0) + CurFormat = NUM_INT_FORMATS - 1; + else + CurFormat--; + break; + case 'f': + CurFormat++; + if (CurFormat == NUM_INT_FORMATS) + CurFormat = 0; + break; + case '2': + Test3D = GL_FALSE; + break; + case '3': + Test3D = GL_TRUE; + break; + case 27: + exit(0); + break; + } + glutPostRedisplay(); +} + + +static void +Init(void) +{ + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + printf("GL_VERSION = %s\n", (char *) glGetString(GL_VERSION)); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); +} + + +int +main(int argc, char *argv[]) +{ + glutInit(&argc, argv); + glutInitWindowPosition(0, 0); + glutInitWindowSize(700, 800); + glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); + glutCreateWindow(argv[0]); + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + Init(); + glutMainLoop(); + return 0; +} diff --git a/progs/tests/pbo.c b/progs/tests/pbo.c new file mode 100644 index 00000000000..b31b36cc121 --- /dev/null +++ b/progs/tests/pbo.c @@ -0,0 +1,296 @@ +/* + * GL_EXT_pixel_buffer_object test + * + * Brian Paul + * 11 March 2004 + */ + +#define GL_GLEXT_PROTOTYPES + +#include +#include +#include +#include +#include + +#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 GLuint DrawPBO, TempPBO; + + +static GLenum ReadFormat = GL_BGRA; +static GLenum ReadType = GL_UNSIGNED_INT_8_8_8_8_REV; + + + +static void +CheckError(int line) +{ + GLenum err = glGetError(); + if (err) { + printf("GL Error 0x%x at line %d\n", (int) err, line); + } +} + + +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 ) +{ + glClearColor(.3, .3, .3, 1); + glClear( GL_COLOR_BUFFER_BIT ); + + CheckError(__LINE__); + + /** Unbind UNPACK pixel buffer before calling glBitmap */ + glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_EXT, 0); + + glRasterPos2i(5, ImgHeight+25); + PrintString("f = toggle front/back s = toggle scale/bias b = benchmark"); + + glRasterPos2i(5, ImgHeight+40); + PrintString("GL_EXT_pixel_buffer_object test"); + + /* draw original image */ + glRasterPos2i(APosX, 5); + PrintString("Original"); + glRasterPos2i(APosX, APosY); + glEnable(GL_DITHER); + SetupPixelTransfer(GL_FALSE); + /*** Draw from the DrawPBO */ + glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_EXT, DrawPBO); + glDrawPixels(ImgWidth, ImgHeight, ImgFormat, GL_UNSIGNED_BYTE, 0); + glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_EXT, 0); + + CheckError(__LINE__); + + /* do readpixels, drawpixels */ + glRasterPos2i(BPosX, 5); + PrintString("Read/DrawPixels"); + SetupPixelTransfer(ScaleAndBias); + /*** read into the Temp PBO */ + glBindBufferARB(GL_PIXEL_PACK_BUFFER_EXT, TempPBO); + CheckError(__LINE__); + 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, 0); + 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, 0); + } + CheckError(__LINE__); + glRasterPos2i(BPosX, BPosY); + glDisable(GL_DITHER); + SetupPixelTransfer(GL_FALSE); + + CheckError(__LINE__); + + /*** draw from the Temp PBO */ + glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_EXT, TempPBO); + glDrawPixels(ImgWidth, ImgHeight, ReadFormat, ReadType, 0); + glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_EXT, 0); + + CheckError(__LINE__); + + /* do copypixels */ + glRasterPos2i(CPosX, 5); + PrintString("CopyPixels"); + glRasterPos2i(CPosX, CPosY); + glDisable(GL_DITHER); + SetupPixelTransfer(ScaleAndBias); + glCopyPixels(APosX, APosY, ImgWidth, ImgHeight, GL_COLOR); + + CheckError(__LINE__); + + if (!DrawFront) + glutSwapBuffers(); + else + glFinish(); +} + + +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(void) +{ + printf("GL_VERSION = %s\n", (char *) glGetString(GL_VERSION)); + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + if (!glutExtensionSupported("GL_EXT_pixel_buffer_object")) { + printf("Sorry, this demo requires GL_EXT_pixel_buffer_object\n"); + exit(0); + } + + Image = LoadRGBImage( IMAGE_FILE, &ImgWidth, &ImgHeight, &ImgFormat ); + if (!Image) { + printf("Couldn't read %s\n", IMAGE_FILE); + exit(0); + } + + printf("Loaded %d by %d image\n", ImgWidth, ImgHeight ); + + if (ImgFormat == GL_RGB) { + /* convert to RGBA */ + int i; + GLubyte *image2 = (GLubyte *) malloc(ImgWidth * ImgHeight * 4); + printf("Converting RGB image to RGBA\n"); + for (i = 0; i < ImgWidth * ImgHeight; i++) { + image2[i*4+0] = Image[i*3+0]; + image2[i*4+1] = Image[i*3+1]; + image2[i*4+2] = Image[i*3+2]; + image2[i*4+3] = 255; + } + free(Image); + Image = image2; + ImgFormat = GL_RGBA; + } + + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + glPixelStorei(GL_UNPACK_ROW_LENGTH, ImgWidth); + glPixelStorei(GL_PACK_ALIGNMENT, 1); + glPixelStorei(GL_PACK_ROW_LENGTH, ImgWidth); + + Reset(); + + /* put image into DrawPBO */ + glGenBuffersARB(1, &DrawPBO); + glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_EXT, DrawPBO); + glBufferDataARB(GL_PIXEL_UNPACK_BUFFER_EXT, + ImgWidth * ImgHeight * 4, Image, GL_STATIC_DRAW); + + /* Setup TempPBO - used for glReadPixels & glDrawPixels */ + glGenBuffersARB(1, &TempPBO); + glBindBufferARB(GL_PIXEL_PACK_BUFFER_EXT, TempPBO); + glBufferDataARB(GL_PIXEL_PACK_BUFFER_EXT, + ImgWidth * ImgHeight * 4, NULL, GL_DYNAMIC_COPY); + +} + + +int +main( int argc, char *argv[] ) +{ + glutInit( &argc, argv ); + glutInitWindowPosition( 0, 0 ); + glutInitWindowSize( 750, 250 ); + glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE ); + glutCreateWindow(argv[0]); + Init(); + glutReshapeFunc( Reshape ); + glutKeyboardFunc( Key ); + glutDisplayFunc( Display ); + glutMainLoop(); + return 0; +} diff --git a/progs/tests/projtex.c b/progs/tests/projtex.c new file mode 100644 index 00000000000..e3ef948ab6a --- /dev/null +++ b/progs/tests/projtex.c @@ -0,0 +1,1028 @@ + +/* projtex.c - by David Yu and David Blythe, SGI */ + +/** + ** Demonstrates simple projective texture mapping. + ** + ** Button1 changes view, Button2 moves texture. + ** + ** (See: Segal, Korobkin, van Widenfelt, Foran, and Haeberli + ** "Fast Shadows and Lighting Effects Using Texture Mapping", SIGGRAPH '92) + ** + ** 1994,1995 -- David G Yu + ** + ** cc -o projtex projtex.c texture.c -lglut -lGLU -lGL -lX11 -lm + **/ + +#include +#include +#include +#include +#include +#if 0 +#include "texture.h" +#else +#include "../util/readtex.c" +#endif + + +/* Some files do not define M_PI... */ +#ifndef M_PI +#define M_PI 3.14159265358979323846 +#endif + +#define MAX_TEX 4 +int NumTextures = 1; + +int winWidth, winHeight; + +GLboolean redrawContinuously = GL_FALSE; + +float angle, axis[3]; +enum MoveModes { + MoveNone, MoveView, MoveObject, MoveTexture +}; +enum MoveModes mode = MoveNone; + +GLfloat objectXform[4][4]; +GLfloat textureXform[MAX_TEX][4][4]; + +void (*drawObject) (void); +void (*loadTexture) (void); +GLboolean textureEnabled = GL_TRUE; +GLboolean showProjection = GL_TRUE; +GLboolean linearFilter = GL_TRUE; + +char *texFilename[MAX_TEX] = { + "../images/girl.rgb", + "../images/tile.rgb", + "../images/bw.rgb", + "../images/reflect.rgb" +}; + + +GLfloat zoomFactor = 1.0; + +/*****************************************************************/ + + +void ActiveTexture(int i) +{ + glActiveTextureARB(i); +} + + +/* matrix = identity */ +void +matrixIdentity(GLfloat matrix[16]) +{ + matrix[0] = 1.0; + matrix[1] = 0.0; + matrix[2] = 0.0; + matrix[3] = 0.0; + matrix[4] = 0.0; + matrix[5] = 1.0; + matrix[6] = 0.0; + matrix[7] = 0.0; + matrix[8] = 0.0; + matrix[9] = 0.0; + matrix[10] = 1.0; + matrix[11] = 0.0; + matrix[12] = 0.0; + matrix[13] = 0.0; + matrix[14] = 0.0; + matrix[15] = 1.0; +} + +/* matrix2 = transpose(matrix1) */ +void +matrixTranspose(GLfloat matrix2[16], GLfloat matrix1[16]) +{ + matrix2[0] = matrix1[0]; + matrix2[1] = matrix1[4]; + matrix2[2] = matrix1[8]; + matrix2[3] = matrix1[12]; + + matrix2[4] = matrix1[1]; + matrix2[5] = matrix1[5]; + matrix2[6] = matrix1[9]; + matrix2[7] = matrix1[13]; + + matrix2[8] = matrix1[2]; + matrix2[9] = matrix1[6]; + matrix2[10] = matrix1[10]; + matrix2[11] = matrix1[14]; + + matrix2[12] = matrix1[3]; + matrix2[13] = matrix1[7]; + matrix2[14] = matrix1[14]; + matrix2[15] = matrix1[15]; +} + +/*****************************************************************/ + +/* load SGI .rgb image (pad with a border of the specified width and color) */ +#if 0 +static void +imgLoad(char *filenameIn, int borderIn, GLfloat borderColorIn[4], + int *wOut, int *hOut, GLubyte ** imgOut) +{ + int border = borderIn; + int width, height; + int w, h; + GLubyte *image, *img, *p; + int i, j, components; + + image = (GLubyte *) read_texture(filenameIn, &width, &height, &components); + w = width + 2 * border; + h = height + 2 * border; + img = (GLubyte *) calloc(w * h, 4 * sizeof(unsigned char)); + + p = img; + for (j = -border; j < height + border; ++j) { + for (i = -border; i < width + border; ++i) { + if (0 <= j && j <= height - 1 && 0 <= i && i <= width - 1) { + p[0] = image[4 * (j * width + i) + 0]; + p[1] = image[4 * (j * width + i) + 1]; + p[2] = image[4 * (j * width + i) + 2]; + p[3] = 0xff; + } else { + p[0] = borderColorIn[0] * 0xff; + p[1] = borderColorIn[1] * 0xff; + p[2] = borderColorIn[2] * 0xff; + p[3] = borderColorIn[3] * 0xff; + } + p += 4; + } + } + free(image); + *wOut = w; + *hOut = h; + *imgOut = img; +} +#endif + + +/*****************************************************************/ + +/* Load the image file specified on the command line as the current texture */ +void +loadImageTextures(void) +{ + GLfloat borderColor[4] = + {1.0, 1.0, 1.0, 1.0}; + int tex; + + for (tex = 0; tex < NumTextures; tex++) { + GLubyte *image, *texData3, *texData4; + GLint imgWidth, imgHeight; + GLenum imgFormat; + int i, j; + + printf("loading %s\n", texFilename[tex]); + image = LoadRGBImage(texFilename[tex], &imgWidth, &imgHeight, &imgFormat); + if (!image) { + printf("can't find %s\n", texFilename[tex]); + exit(1); + } + assert(imgFormat == GL_RGB); + + /* scale to 256x256 */ + texData3 = malloc(256 * 256 * 4); + texData4 = malloc(256 * 256 * 4); + assert(texData3); + assert(texData4); + gluScaleImage(imgFormat, imgWidth, imgHeight, GL_UNSIGNED_BYTE, image, + 256, 256, GL_UNSIGNED_BYTE, texData3); + + /* convert to rgba */ + for (i = 0; i < 256 * 256; i++) { + texData4[i*4+0] = texData3[i*3+0]; + texData4[i*4+1] = texData3[i*3+1]; + texData4[i*4+2] = texData3[i*3+2]; + texData4[i*4+3] = 128; + } + + /* put transparent border around image */ + for (i = 0; i < 256; i++) { + texData4[i*4+0] = 255; + texData4[i*4+1] = 255; + texData4[i*4+2] = 255; + texData4[i*4+3] = 0; + } + j = 256 * 255 * 4; + for (i = 0; i < 256; i++) { + texData4[j + i*4+0] = 255; + texData4[j + i*4+1] = 255; + texData4[j + i*4+2] = 255; + texData4[j + i*4+3] = 0; + } + for (i = 0; i < 256; i++) { + j = i * 256 * 4; + texData4[j+0] = 255; + texData4[j+1] = 255; + texData4[j+2] = 255; + texData4[j+3] = 0; + } + for (i = 0; i < 256; i++) { + j = i * 256 * 4 + 255 * 4; + texData4[j+0] = 255; + texData4[j+1] = 255; + texData4[j+2] = 255; + texData4[j+3] = 0; + } + + ActiveTexture(GL_TEXTURE0_ARB + tex); + glBindTexture(GL_TEXTURE_2D, tex + 1); + + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 256, 256, 0, + GL_RGBA, GL_UNSIGNED_BYTE, texData4); + + if (linearFilter) { + 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); + } + glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, borderColor); + } +} + +/* Create a simple spotlight pattern and make it the current texture */ +void +loadSpotlightTexture(void) +{ + static int texWidth = 64, texHeight = 64; + static GLubyte *texData; + GLfloat borderColor[4] = + {0.1, 0.1, 0.1, 1.0}; + + if (!texData) { + GLubyte *p; + int i, j; + + texData = (GLubyte *) malloc(texWidth * texHeight * 4 * sizeof(GLubyte)); + + p = texData; + for (j = 0; j < texHeight; ++j) { + float dy = (texHeight * 0.5 - j + 0.5) / (texHeight * 0.5); + + for (i = 0; i < texWidth; ++i) { + float dx = (texWidth * 0.5 - i + 0.5) / (texWidth * 0.5); + float r = cos(M_PI / 2.0 * sqrt(dx * dx + dy * dy)); + float c; + + r = (r < 0) ? 0 : r * r; + c = 0xff * (r + borderColor[0]); + p[0] = (c <= 0xff) ? c : 0xff; + c = 0xff * (r + borderColor[1]); + p[1] = (c <= 0xff) ? c : 0xff; + c = 0xff * (r + borderColor[2]); + p[2] = (c <= 0xff) ? c : 0xff; + c = 0xff * (r + borderColor[3]); + p[3] = (c <= 0xff) ? c : 0xff; + p += 4; + } + } + } + if (linearFilter) { + 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); + } + glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, borderColor); + gluBuild2DMipmaps(GL_TEXTURE_2D, 4, texWidth, texHeight, + GL_RGBA, GL_UNSIGNED_BYTE, texData); +} + +/*****************************************************************/ + +void +checkErrors(void) +{ + GLenum error; + while ((error = glGetError()) != GL_NO_ERROR) { + fprintf(stderr, "Error: %s\n", (char *) gluErrorString(error)); + } +} + +void +drawCube(void) +{ + glBegin(GL_QUADS); + + glNormal3f(-1.0, 0.0, 0.0); + glColor3f(0.80, 0.50, 0.50); + glVertex3f(-0.5, -0.5, -0.5); + glVertex3f(-0.5, -0.5, 0.5); + glVertex3f(-0.5, 0.5, 0.5); + glVertex3f(-0.5, 0.5, -0.5); + + glNormal3f(1.0, 0.0, 0.0); + glColor3f(0.50, 0.80, 0.50); + glVertex3f(0.5, 0.5, 0.5); + glVertex3f(0.5, -0.5, 0.5); + glVertex3f(0.5, -0.5, -0.5); + glVertex3f(0.5, 0.5, -0.5); + + glNormal3f(0.0, -1.0, 0.0); + glColor3f(0.50, 0.50, 0.80); + glVertex3f(-0.5, -0.5, -0.5); + glVertex3f(0.5, -0.5, -0.5); + glVertex3f(0.5, -0.5, 0.5); + glVertex3f(-0.5, -0.5, 0.5); + + glNormal3f(0.0, 1.0, 0.0); + glColor3f(0.50, 0.80, 0.80); + glVertex3f(0.5, 0.5, 0.5); + glVertex3f(0.5, 0.5, -0.5); + glVertex3f(-0.5, 0.5, -0.5); + glVertex3f(-0.5, 0.5, 0.5); + + glNormal3f(0.0, 0.0, -1.0); + glColor3f(0.80, 0.50, 0.80); + glVertex3f(-0.5, -0.5, -0.5); + glVertex3f(-0.5, 0.5, -0.5); + glVertex3f(0.5, 0.5, -0.5); + glVertex3f(0.5, -0.5, -0.5); + + glNormal3f(0.0, 0.0, 1.0); + glColor3f(1.00, 0.80, 0.50); + glVertex3f(0.5, 0.5, 0.5); + glVertex3f(-0.5, 0.5, 0.5); + glVertex3f(-0.5, -0.5, 0.5); + glVertex3f(0.5, -0.5, 0.5); + glEnd(); +} + +void +drawDodecahedron(void) +{ +#define A (0.5 * 1.61803) /* (sqrt(5) + 1) / 2 */ +#define B (0.5 * 0.61803) /* (sqrt(5) - 1) / 2 */ +#define C (0.5 * 1.0) + GLfloat vertexes[20][3] = + { + {-A, 0.0, B}, + {-A, 0.0, -B}, + {A, 0.0, -B}, + {A, 0.0, B}, + {B, -A, 0.0}, + {-B, -A, 0.0}, + {-B, A, 0.0}, + {B, A, 0.0}, + {0.0, B, -A}, + {0.0, -B, -A}, + {0.0, -B, A}, + {0.0, B, A}, + {-C, -C, C}, + {-C, -C, -C}, + {C, -C, -C}, + {C, -C, C}, + {-C, C, C}, + {-C, C, -C}, + {C, C, -C}, + {C, C, C}, + }; +#undef A +#undef B +#undef C + GLint polygons[12][5] = + { + {0, 12, 10, 11, 16}, + {1, 17, 8, 9, 13}, + {2, 14, 9, 8, 18}, + {3, 19, 11, 10, 15}, + {4, 14, 2, 3, 15}, + {5, 12, 0, 1, 13}, + {6, 17, 1, 0, 16}, + {7, 19, 3, 2, 18}, + {8, 17, 6, 7, 18}, + {9, 14, 4, 5, 13}, + {10, 12, 5, 4, 15}, + {11, 19, 7, 6, 16}, + }; + int i; + + glColor3f(0.75, 0.75, 0.75); + for (i = 0; i < 12; ++i) { + GLfloat *p0, *p1, *p2, d; + GLfloat u[3], v[3], n[3]; + + p0 = &vertexes[polygons[i][0]][0]; + p1 = &vertexes[polygons[i][1]][0]; + p2 = &vertexes[polygons[i][2]][0]; + + u[0] = p2[0] - p1[0]; + u[1] = p2[1] - p1[1]; + u[2] = p2[2] - p1[2]; + + v[0] = p0[0] - p1[0]; + v[1] = p0[1] - p1[1]; + v[2] = p0[2] - p1[2]; + + n[0] = u[1] * v[2] - u[2] * v[1]; + n[1] = u[2] * v[0] - u[0] * v[2]; + n[2] = u[0] * v[1] - u[1] * v[0]; + + d = 1.0 / sqrt(n[0] * n[0] + n[1] * n[1] + n[2] * n[2]); + n[0] *= d; + n[1] *= d; + n[2] *= d; + + glBegin(GL_POLYGON); + glNormal3fv(n); + glVertex3fv(p0); + glVertex3fv(p1); + glVertex3fv(p2); + glVertex3fv(vertexes[polygons[i][3]]); + glVertex3fv(vertexes[polygons[i][4]]); + glEnd(); + } +} + +void +drawSphere(void) +{ + int numMajor = 24; + int numMinor = 32; + float radius = 0.8; + double majorStep = (M_PI / numMajor); + double minorStep = (2.0 * M_PI / numMinor); + int i, j; + + glColor3f(0.50, 0.50, 0.50); + for (i = 0; i < numMajor; ++i) { + double a = i * majorStep; + double b = a + majorStep; + double r0 = radius * sin(a); + double r1 = radius * sin(b); + GLfloat z0 = radius * cos(a); + GLfloat z1 = radius * cos(b); + + glBegin(GL_TRIANGLE_STRIP); + for (j = 0; j <= numMinor; ++j) { + double c = j * minorStep; + GLfloat x = cos(c); + GLfloat y = sin(c); + + glNormal3f((x * r0) / radius, (y * r0) / radius, z0 / radius); + glTexCoord2f(j / (GLfloat) numMinor, i / (GLfloat) numMajor); + glVertex3f(x * r0, y * r0, z0); + + glNormal3f((x * r1) / radius, (y * r1) / radius, z1 / radius); + glTexCoord2f(j / (GLfloat) numMinor, (i + 1) / (GLfloat) numMajor); + glVertex3f(x * r1, y * r1, z1); + } + glEnd(); + } +} + +/*****************************************************************/ + +float xmin = -0.035, xmax = 0.035; +float ymin = -0.035, ymax = 0.035; +float nnear = 0.1; +float ffar = 1.9; +float distance = -1.0; + +static void +loadTextureProjection(int texUnit, GLfloat m[16]) +{ + GLfloat mInverse[4][4]; + + /* Should use true inverse, but since m consists only of rotations, we can + just use the transpose. */ + matrixTranspose((GLfloat *) mInverse, m); + + ActiveTexture(GL_TEXTURE0_ARB + texUnit); + glMatrixMode(GL_TEXTURE); + glLoadIdentity(); + glTranslatef(0.5, 0.5, 0.0); + glScalef(0.5, 0.5, 1.0); + glFrustum(xmin, xmax, ymin, ymax, nnear, ffar); + glTranslatef(0.0, 0.0, distance); + glMultMatrixf((GLfloat *) mInverse); + glMatrixMode(GL_MODELVIEW); +} + +static void +drawTextureProjection(void) +{ + float t = ffar / nnear; + GLfloat n[4][3]; + GLfloat f[4][3]; + + n[0][0] = xmin; + n[0][1] = ymin; + n[0][2] = -(nnear + distance); + + n[1][0] = xmax; + n[1][1] = ymin; + n[1][2] = -(nnear + distance); + + n[2][0] = xmax; + n[2][1] = ymax; + n[2][2] = -(nnear + distance); + + n[3][0] = xmin; + n[3][1] = ymax; + n[3][2] = -(nnear + distance); + + f[0][0] = xmin * t; + f[0][1] = ymin * t; + f[0][2] = -(ffar + distance); + + f[1][0] = xmax * t; + f[1][1] = ymin * t; + f[1][2] = -(ffar + distance); + + f[2][0] = xmax * t; + f[2][1] = ymax * t; + f[2][2] = -(ffar + distance); + + f[3][0] = xmin * t; + f[3][1] = ymax * t; + f[3][2] = -(ffar + distance); + + glColor3f(1.0, 1.0, 0.0); + glBegin(GL_LINE_LOOP); + glVertex3fv(n[0]); + glVertex3fv(n[1]); + glVertex3fv(n[2]); + glVertex3fv(n[3]); + glVertex3fv(f[3]); + glVertex3fv(f[2]); + glVertex3fv(f[1]); + glVertex3fv(f[0]); + glVertex3fv(n[0]); + glVertex3fv(n[1]); + glVertex3fv(f[1]); + glVertex3fv(f[0]); + glVertex3fv(f[3]); + glVertex3fv(f[2]); + glVertex3fv(n[2]); + glVertex3fv(n[3]); + glEnd(); +} + +/*****************************************************************/ + +void +initialize(void) +{ + GLfloat light0Pos[4] = + {0.3, 0.3, 0.0, 1.0}; + GLfloat matAmb[4] = + {0.01, 0.01, 0.01, 1.00}; + GLfloat matDiff[4] = + {0.65, 0.65, 0.65, 1.00}; + GLfloat matSpec[4] = + {0.30, 0.30, 0.30, 1.00}; + GLfloat matShine = 10.0; + GLfloat eyePlaneS[] = + {1.0, 0.0, 0.0, 0.0}; + GLfloat eyePlaneT[] = + {0.0, 1.0, 0.0, 0.0}; + GLfloat eyePlaneR[] = + {0.0, 0.0, 1.0, 0.0}; + GLfloat eyePlaneQ[] = + {0.0, 0.0, 0.0, 1.0}; + int i; + + /* Setup Misc. */ + glClearColor(0.41, 0.41, 0.31, 0.0); + + glEnable(GL_DEPTH_TEST); + + /* glLineWidth(2.0);*/ + + glCullFace(GL_FRONT); + glEnable(GL_CULL_FACE); + + glMatrixMode(GL_PROJECTION); + glFrustum(-0.5, 0.5, -0.5, 0.5, 1, 3); + glMatrixMode(GL_MODELVIEW); + glTranslatef(0, 0, -2); + + matrixIdentity((GLfloat *) objectXform); + for (i = 0; i < NumTextures; i++) { + matrixIdentity((GLfloat *) textureXform[i]); + } + + glMatrixMode(GL_PROJECTION); + glPushMatrix(); + glLoadIdentity(); + glOrtho(0, 1, 0, 1, -1, 1); + glMatrixMode(GL_MODELVIEW); + glPushMatrix(); + glLoadIdentity(); + + glRasterPos2i(0, 0); + + glPopMatrix(); + glMatrixMode(GL_PROJECTION); + glPopMatrix(); + glMatrixMode(GL_MODELVIEW); + + /* Setup Lighting */ + glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, matAmb); + glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, matDiff); + glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, matSpec); + glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, matShine); + + glEnable(GL_COLOR_MATERIAL); + + glLightfv(GL_LIGHT0, GL_POSITION, light0Pos); + glEnable(GL_LIGHT0); + + glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE); + glEnable(GL_LIGHTING); + + /* Setup Texture */ + + (*loadTexture) (); + + + for (i = 0; i < NumTextures; i++) { + ActiveTexture(GL_TEXTURE0_ARB + i); + + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + + glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR); + glTexGenfv(GL_S, GL_EYE_PLANE, eyePlaneS); + + glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR); + glTexGenfv(GL_T, GL_EYE_PLANE, eyePlaneT); + + glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR); + glTexGenfv(GL_R, GL_EYE_PLANE, eyePlaneR); + + glTexGeni(GL_Q, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR); + glTexGenfv(GL_Q, GL_EYE_PLANE, eyePlaneQ); + } +} + +void +display(void) +{ + int i; + + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + if (textureEnabled) { + if (mode == MoveTexture || mode == MoveView) { + /* Have OpenGL compute the new transformation (simple but slow). */ + for (i = 0; i < NumTextures; i++) { + glPushMatrix(); + glLoadIdentity(); +#if 0 + if (i & 1) + glRotatef(angle, axis[0], axis[1], axis[2]); + else +#endif + glRotatef(angle*(i+1), axis[0], axis[1], axis[2]); + + glMultMatrixf((GLfloat *) textureXform[i]); + glGetFloatv(GL_MODELVIEW_MATRIX, (GLfloat *) textureXform[i]); + glPopMatrix(); + } + } + for (i = 0; i < NumTextures; i++) { + loadTextureProjection(i, (GLfloat *) textureXform[i]); + } + + if (showProjection) { + for (i = 0; i < NumTextures; i++) { + ActiveTexture(GL_TEXTURE0_ARB + i); + glPushMatrix(); + glMultMatrixf((GLfloat *) textureXform[i]); + glDisable(GL_LIGHTING); + drawTextureProjection(); + glEnable(GL_LIGHTING); + glPopMatrix(); + } + } + for (i = 0; i < NumTextures; i++) { + ActiveTexture(GL_TEXTURE0_ARB + i); + glEnable(GL_TEXTURE_2D); + glEnable(GL_TEXTURE_GEN_S); + glEnable(GL_TEXTURE_GEN_T); + glEnable(GL_TEXTURE_GEN_R); + glEnable(GL_TEXTURE_GEN_Q); + } + } + if (mode == MoveObject || mode == MoveView) { + /* Have OpenGL compute the new transformation (simple but slow). */ + glPushMatrix(); + glLoadIdentity(); + glRotatef(angle, axis[0], axis[1], axis[2]); + glMultMatrixf((GLfloat *) objectXform); + glGetFloatv(GL_MODELVIEW_MATRIX, (GLfloat *) objectXform); + glPopMatrix(); + } + glPushMatrix(); + glMultMatrixf((GLfloat *) objectXform); + (*drawObject) (); + glPopMatrix(); + + for (i = 0; i < NumTextures; i++) { + ActiveTexture(GL_TEXTURE0_ARB + i); + glDisable(GL_TEXTURE_2D); + glDisable(GL_TEXTURE_GEN_S); + glDisable(GL_TEXTURE_GEN_T); + glDisable(GL_TEXTURE_GEN_R); + glDisable(GL_TEXTURE_GEN_Q); + } + + if (zoomFactor > 1.0) { + glDisable(GL_DEPTH_TEST); + glCopyPixels(0, 0, winWidth / zoomFactor, winHeight / zoomFactor, GL_COLOR); + glEnable(GL_DEPTH_TEST); + } + glFlush(); + glutSwapBuffers(); + checkErrors(); +} + +/*****************************************************************/ + +/* simple trackball-like motion control */ +float lastPos[3]; +int lastTime; + +void +ptov(int x, int y, int width, int height, float v[3]) +{ + float d, a; + + /* project x,y onto a hemi-sphere centered within width, height */ + v[0] = (2.0 * x - width) / width; + v[1] = (height - 2.0 * y) / height; + d = sqrt(v[0] * v[0] + v[1] * v[1]); + v[2] = cos((M_PI / 2.0) * ((d < 1.0) ? d : 1.0)); + a = 1.0 / sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]); + v[0] *= a; + v[1] *= a; + v[2] *= a; +} + +void +startMotion(int x, int y, int but, int time) +{ + if (but == GLUT_LEFT_BUTTON) { + mode = MoveView; + } else if (but == GLUT_MIDDLE_BUTTON) { + mode = MoveTexture; + } else { + return; + } + + lastTime = time; + ptov(x, y, winWidth, winHeight, lastPos); +} + +void +animate(void) +{ + glutPostRedisplay(); +} + +void +vis(int visible) +{ + if (visible == GLUT_VISIBLE) { + if (redrawContinuously) + glutIdleFunc(animate); + } else { + if (redrawContinuously) + glutIdleFunc(NULL); + } +} + +void +stopMotion(int but, int time) +{ + if ((but == GLUT_LEFT_BUTTON && mode == MoveView) || + (but == GLUT_MIDDLE_BUTTON && mode == MoveTexture)) { + } else { + return; + } + + if (time == lastTime) { + /* redrawContinuously = GL_TRUE;*/ + glutIdleFunc(animate); + } else { + angle = 0.0; + redrawContinuously = GL_FALSE; + glutIdleFunc(0); + } + if (!redrawContinuously) { + mode = MoveNone; + } +} + +void +trackMotion(int x, int y) +{ + float curPos[3], dx, dy, dz; + + ptov(x, y, winWidth, winHeight, curPos); + + dx = curPos[0] - lastPos[0]; + dy = curPos[1] - lastPos[1]; + dz = curPos[2] - lastPos[2]; + angle = 90.0 * sqrt(dx * dx + dy * dy + dz * dz); + + axis[0] = lastPos[1] * curPos[2] - lastPos[2] * curPos[1]; + axis[1] = lastPos[2] * curPos[0] - lastPos[0] * curPos[2]; + axis[2] = lastPos[0] * curPos[1] - lastPos[1] * curPos[0]; + + lastTime = glutGet(GLUT_ELAPSED_TIME); + lastPos[0] = curPos[0]; + lastPos[1] = curPos[1]; + lastPos[2] = curPos[2]; + glutPostRedisplay(); +} + +/*****************************************************************/ + +void +object(void) +{ + static int object; + + object++; + object %= 3; + switch (object) { + case 0: + drawObject = drawCube; + break; + case 1: + drawObject = drawDodecahedron; + break; + case 2: + drawObject = drawSphere; + break; + default: + break; + } +} + +static void +nop(void) +{ +} + +void +texture(void) +{ + static int texture = 0; + + texture++; + texture %= 3; + if (texture == 1 && texFilename == NULL) { + /* Skip file texture if not loaded. */ + texture++; + } + switch (texture) { + case 0: + loadTexture = nop; + textureEnabled = GL_FALSE; + break; + case 1: + loadTexture = loadImageTextures; + (*loadTexture) (); + textureEnabled = GL_TRUE; + break; + case 2: + loadTexture = loadSpotlightTexture; + (*loadTexture) (); + textureEnabled = GL_TRUE; + break; + default: + break; + } +} + +void +help(void) +{ + printf("'h' - help\n"); + printf("'l' - toggle linear/nearest filter\n"); + printf("'s' - toggle projection frustum\n"); + printf("'t' - toggle projected texture\n"); + printf("'o' - toggle object\n"); + printf("'z' - increase zoom factor\n"); + printf("'Z' - decrease zoom factor\n"); + printf("left mouse - move view\n"); + printf("middle mouse - move projection\n"); +} + +/* ARGSUSED1 */ +void +key(unsigned char key, int x, int y) +{ + switch (key) { + case '\033': + exit(0); + break; + case 'l': + linearFilter = !linearFilter; + (*loadTexture) (); + break; + case 's': + showProjection = !showProjection; + break; + case 't': + texture(); + break; + case 'o': + object(); + break; + case 'z': + zoomFactor += 1.0; + glPixelZoom(zoomFactor, zoomFactor); + glViewport(0, 0, winWidth / zoomFactor, winHeight / zoomFactor); + break; + case 'Z': + zoomFactor -= 1.0; + if (zoomFactor < 1.0) + zoomFactor = 1.0; + glPixelZoom(zoomFactor, zoomFactor); + glViewport(0, 0, winWidth / zoomFactor, winHeight / zoomFactor); + break; + case 'h': + help(); + break; + } + glutPostRedisplay(); +} + +void +mouse(int button, int state, int x, int y) +{ + if (state == GLUT_DOWN) + startMotion(x, y, button, glutGet(GLUT_ELAPSED_TIME)); + else if (state == GLUT_UP) + stopMotion(button, glutGet(GLUT_ELAPSED_TIME)); + glutPostRedisplay(); +} + +void +reshape(int w, int h) +{ + winWidth = w; + winHeight = h; + glViewport(0, 0, w / zoomFactor, h / zoomFactor); +} + + +void +menu(int selection) +{ + if (selection == 666) { + exit(0); + } + key((unsigned char) selection, 0, 0); +} + +int +main(int argc, char **argv) +{ + glutInit(&argc, argv); + + if (argc > 1) { + NumTextures = atoi(argv[1]); + } + assert(NumTextures <= MAX_TEX); + + glutInitDisplayMode(GLUT_RGBA | GLUT_DEPTH | GLUT_DOUBLE); + (void) glutCreateWindow("projtex"); + + loadTexture = loadImageTextures; + drawObject = drawCube; + initialize(); + glutDisplayFunc(display); + glutKeyboardFunc(key); + glutReshapeFunc(reshape); + glutMouseFunc(mouse); + glutMotionFunc(trackMotion); + glutVisibilityFunc(vis); + glutCreateMenu(menu); + glutAddMenuEntry("Toggle showing projection", 's'); + glutAddMenuEntry("Switch texture", 't'); + glutAddMenuEntry("Switch object", 'o'); + glutAddMenuEntry("Toggle filtering", 'l'); + glutAddMenuEntry("Quit", 666); + glutAttachMenu(GLUT_RIGHT_BUTTON); + texture(); + glutMainLoop(); + return 0; /* ANSI C requires main to return int. */ +} diff --git a/progs/tests/readrate.c b/progs/tests/readrate.c new file mode 100644 index 00000000000..42ae62d48a9 --- /dev/null +++ b/progs/tests/readrate.c @@ -0,0 +1,285 @@ +/* + * Test glReadPixels speed + * Brian Paul + * 9 April 2004 + * + * Compile: + * gcc readrate.c -L/usr/X11R6/lib -lglut -lGLU -lGL -lX11 -o readrate + */ + +#define GL_GLEXT_PROTOTYPES +#include +#include +#include +#include +#include + +/* Hack, to test drawing instead of reading */ +#define DRAW 0 + +#define MAX_WIDTH 1280 +#define MAX_HEIGHT 1024 + +#define NUM_WIDTHS 4 +#define NUM_HEIGHTS 4 +static const GLint Widths[] = {256, 512, 1024, 1280}; +static const GLint Heights[] = {4, 32, 256, 512, 768, 1024}; +static int WidthIndex = 1, HeightIndex = 3; +static GLubyte *Buffer = NULL; +static GLboolean Benchmark = GL_TRUE; + +#define NUM_PBO 2 + +static GLuint PBObjects[4]; + +static GLboolean HavePBO = GL_FALSE; + + +struct format_type { + const char *Name; + GLuint Bytes; + GLenum Format; + GLenum Type; +}; + +static struct format_type Formats[] = { + { "GL_RGB, GLubyte", 3, GL_RGB, GL_UNSIGNED_BYTE }, + { "GL_BGR, GLubyte", 3, GL_BGR, GL_UNSIGNED_BYTE }, + { "GL_RGBA, GLubyte", 4, GL_RGBA, GL_UNSIGNED_BYTE }, + { "GL_BGRA, GLubyte", 4, GL_BGRA, GL_UNSIGNED_BYTE }, + { "GL_ABGR, GLubyte", 4, GL_ABGR_EXT, GL_UNSIGNED_BYTE }, + { "GL_RGBA, GLuint_8_8_8_8", 4, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8 }, + { "GL_BGRA, GLuint_8_8_8_8", 4, GL_BGRA_EXT, GL_UNSIGNED_INT_8_8_8_8 }, + { "GL_BGRA, GLuint_8_8_8_8_rev", 4, GL_BGRA_EXT, GL_UNSIGNED_INT_8_8_8_8_REV }, +#ifdef GL_EXT_packed_depth_stencil + { "GL_DEPTH_STENCIL_EXT, GLuint24+8", 4, GL_DEPTH_STENCIL_EXT, GL_UNSIGNED_INT_24_8_EXT }, +#endif + { "GL_DEPTH_COMPONENT, GLfloat", 4, GL_DEPTH_COMPONENT, GL_FLOAT }, + { "GL_DEPTH_COMPONENT, GLuint", 4, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT } +}; + +#define NUM_FORMATS (sizeof(Formats) / sizeof(struct format_type)) + + +static void +PrintString(const char *s) +{ + while (*s) { + glutBitmapCharacter(GLUT_BITMAP_8_BY_13, (int) *s); + s++; + } +} + + +static void +MeasureFormat(struct format_type *fmt, GLint width, GLint height, GLuint pbo) +{ + double t0 = glutGet(GLUT_ELAPSED_TIME) * 0.001; + double t1; + int j; + + for (j = 0; ; j++) { + + glBegin(GL_POINTS); + glVertex2f(1,1); + glEnd(); + +#if DRAW + glWindowPos2iARB(0,0); + glDrawPixels(width, height, + fmt->Format, fmt->Type, Buffer); + glFinish(); +#else + if (pbo) { + glBindBufferARB(GL_PIXEL_PACK_BUFFER_EXT, PBObjects[j % NUM_PBO]); + glReadPixels(0, 0, width, height, + fmt->Format, fmt->Type, 0); + } + else { + glReadPixels(0, 0, width, height, + fmt->Format, fmt->Type, Buffer); + } +#endif + + t1 = glutGet(GLUT_ELAPSED_TIME) * 0.001; + if (t1 - t0 > 2.0) { + GLdouble rate = width * height / (1024.0 * 1024.0) * j / (t1 - t0); +#if DRAW + printf("%-32s %.2f draws/sec %.2f MPixels/sec %.2f MBytes/sec\n", + fmt->Name, j / (t1-t0), rate, rate * fmt->Bytes); +#else + printf("%-32s %.2f reads/sec %.2f MPixels/sec %.2f MBytes/sec\n", + fmt->Name, j / (t1-t0), rate, rate * fmt->Bytes); +#endif + break; + } + + if (j == 0) { + /* check for error */ + GLenum err = glGetError(); + if (err) { + printf("GL Error 0x%x for %s\n", err, fmt->Name); + return; + } + } + } +} + + + +static void +Draw(void) +{ + char str[1000]; + int width = Widths[WidthIndex]; + int height = Heights[HeightIndex]; + int y = MAX_HEIGHT - 50; + + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + glWindowPos2iARB(10, y); + sprintf(str, "ReadPixels size: %d x %d", width, height); + PrintString(str); + y -= 14; + + glWindowPos2iARB(10, y); + PrintString("Press up/down/left/right to change image size."); + y -= 14; + + glWindowPos2iARB(10, y); + PrintString("Press 'b' to run benchmark test."); + y -= 14; + + if (Benchmark) { + glWindowPos2iARB(10, y); + PrintString("Testing..."); + } + + glutSwapBuffers(); + + if (Benchmark) { + GLuint i, pbo; +#if DRAW + printf("Draw size: Width=%d Height=%d\n", width, height); +#else + printf("Read size: Width=%d Height=%d\n", width, height); +#endif + for (pbo = 0; pbo <= HavePBO; pbo++) { + printf("Pixel Buffer Object: %d\n", pbo); + + if (pbo == 0) { + glBindBufferARB(GL_PIXEL_PACK_BUFFER_EXT, 0); + } + + for (i = 0; i < NUM_FORMATS; i++) { + MeasureFormat(Formats + i, width, height, pbo); + } + } + + Benchmark = GL_FALSE; + + /* redraw window text */ + glutPostRedisplay(); + } + +} + + +static void +Reshape(int width, int height) +{ + glViewport(0, 0, width, height); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-1, 1, -1, 1, -1, 1); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); +} + + +static void +Key(unsigned char key, int x, int y) +{ + (void) x; + (void) y; + switch (key) { + case 'b': + Benchmark = 1; + 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 (HeightIndex + 1 < NUM_WIDTHS) + HeightIndex++; + break; + case GLUT_KEY_DOWN: + if (HeightIndex > 0) + HeightIndex--; + break; + case GLUT_KEY_LEFT: + if (WidthIndex > 0) + WidthIndex--; + break; + case GLUT_KEY_RIGHT: + if (WidthIndex + 1 < NUM_HEIGHTS) + WidthIndex++; + break; + } + glutPostRedisplay(); +} + + +static void +Init(void) +{ + Buffer = malloc(MAX_WIDTH * MAX_HEIGHT * 4); + assert(Buffer); +#if DRAW + printf("glDrawPixels test report:\n"); +#else + printf("glReadPixels test report:\n"); +#endif + printf("GL_RENDERER: %s\n", (char *) glGetString(GL_RENDERER)); + printf("GL_VERSION: %s\n", (char *) glGetString(GL_VERSION)); + + if (glutExtensionSupported("GL_ARB_pixel_buffer_object")) { + int i; + HavePBO = 1; + glGenBuffersARB(NUM_PBO, PBObjects); + for (i = 0; i < NUM_PBO; i++) { + glBindBufferARB(GL_PIXEL_PACK_BUFFER_EXT, PBObjects[i]); + glBufferDataARB(GL_PIXEL_PACK_BUFFER_EXT, + MAX_WIDTH * MAX_HEIGHT * 4, NULL, GL_STREAM_READ); + } + } +} + + +int +main(int argc, char *argv[]) +{ + glutInit(&argc, argv); + glutInitWindowPosition(0, 0); + glutInitWindowSize(MAX_WIDTH, MAX_HEIGHT); + glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH | GLUT_STENCIL); + glutCreateWindow(argv[0]); + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutSpecialFunc(SpecialKey); + glutDisplayFunc(Draw); + Init(); + glutMainLoop(); + return 0; +} diff --git a/progs/tests/seccolor.c b/progs/tests/seccolor.c new file mode 100644 index 00000000000..77fd40647ba --- /dev/null +++ b/progs/tests/seccolor.c @@ -0,0 +1,145 @@ +/* + * Exercise GL_EXT_secondary_color + */ + + +#define GL_GLEXT_PROTOTYPES +#include +#include +#include +#include + +static int Width = 600; +static int Height = 200; +static GLfloat Near = 5.0, Far = 25.0; + + +static void Display( void ) +{ + GLfloat t; + + glClearColor(0.2, 0.2, 0.8, 0); + glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); + + for (t = 0.0; t <= 1.0; t += 0.25) { + GLfloat x = t * 10.0 - 5.0; + GLfloat g = t; + + /* top row: untextured */ + glColor3f(1, 0, 0); + glPushMatrix(); + glTranslatef(x, 1.2, 0); +#if defined(GL_EXT_secondary_color) + glSecondaryColor3fEXT(0, g, 0); +#endif + glBegin(GL_POLYGON); + glVertex2f(-1, -1); + glVertex2f( 1, -1); + glVertex2f( 1, 1); + glVertex2f(-1, 1); + glEnd(); + glPopMatrix(); + + /* bottom row: textured */ + glColor3f(1, 1, 1); + glEnable(GL_TEXTURE_2D); + glPushMatrix(); + glTranslatef(x, -1.2, 0); +#if defined(GL_EXT_secondary_color) + glSecondaryColor3fEXT(0, g, 0); +#endif + glBegin(GL_POLYGON); + glTexCoord2f(0, 0); glVertex2f(-1, -1); + glTexCoord2f(1, 0); glVertex2f( 1, -1); + glTexCoord2f(1, 1); glVertex2f( 1, 1); + glTexCoord2f(0, 1); glVertex2f(-1, 1); + glEnd(); + glPopMatrix(); + glDisable(GL_TEXTURE_2D); + } + glutSwapBuffers(); +} + + +static void Reshape( int width, int height ) +{ + GLfloat ar = (float) width / (float) height; + Width = width; + Height = height; + glViewport( 0, 0, width, height ); + glMatrixMode( GL_PROJECTION ); + glLoadIdentity(); + glFrustum( -ar, ar, -1.0, 1.0, Near, Far ); + glMatrixMode( GL_MODELVIEW ); + glLoadIdentity(); + glTranslatef( 0.0, 0.0, -15.0 ); +} + + +static void Key( unsigned char key, int x, int y ) +{ + (void) x; + (void) y; + switch (key) { + case 27: + exit(0); + break; + } + glutPostRedisplay(); +} + + +static void Init( void ) +{ + GLubyte image[4*4][3]; + GLint i; + if (!glutExtensionSupported("GL_EXT_secondary_color")) { + printf("Sorry, this program requires GL_EXT_secondary_color\n"); + exit(1); + } + + /* setup red texture with one back texel */ + for (i = 0; i < 4*4; i++) { + if (i == 0) { + image[i][0] = 0; + image[i][1] = 0; + image[i][2] = 0; + } + else { + image[i][0] = 255; + image[i][1] = 0; + image[i][2] = 0; + } + } + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 4, 4, 0, + GL_RGB, GL_UNSIGNED_BYTE, image); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + +#if defined(GL_EXT_secondary_color) + glEnable(GL_COLOR_SUM_EXT); +#endif + glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR); + + printf("Squares should be colored from red -> orange -> yellow.\n"); + printf("Top row is untextured.\n"); + printf("Bottom row is textured (red texture with one black texel).\n"); + printf("Rows should be identical, except for lower-left texel.\n"); +} + + +int main( int argc, char *argv[] ) +{ + glutInit( &argc, argv ); + glutInitWindowPosition( 0, 0 ); + glutInitWindowSize( Width, Height ); + glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE ); + glutCreateWindow(argv[0]); + glutReshapeFunc( Reshape ); + glutKeyboardFunc( Key ); + glutDisplayFunc( Display ); + Init(); + glutMainLoop(); + return 0; +} diff --git a/progs/tests/sharedtex.c b/progs/tests/sharedtex.c new file mode 100644 index 00000000000..c3eef95fb35 --- /dev/null +++ b/progs/tests/sharedtex.c @@ -0,0 +1,438 @@ +/* $Id: sharedtex.c,v 1.2 2002-01-16 14:32:46 joukj Exp $ */ + +/* + * Test sharing of display lists and texture objects between GLX contests. + * Brian Paul + * Summer 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 +#include +#include +#include +#include +#include + + +struct window { + char DisplayName[1000]; + Display *Dpy; + Window Win; + GLXContext Context; + float Angle; + int Id; +}; + + +#define MAX_WINDOWS 20 +static struct window Windows[MAX_WINDOWS]; +static int NumWindows = 0; + + +static GLuint Textures[3]; +static GLuint CubeList; + + + +static void +Error(const char *display, const char *msg) +{ + fprintf(stderr, "Error on display %s - %s\n", display, msg); + exit(1); +} + + +static struct window * +AddWindow(const char *displayName, int xpos, int ypos, + const struct window *shareWindow) +{ + Display *dpy; + Window win; + GLXContext ctx; + int attrib[] = { GLX_RGBA, + GLX_RED_SIZE, 1, + GLX_GREEN_SIZE, 1, + GLX_BLUE_SIZE, 1, + GLX_DOUBLEBUFFER, + GLX_DEPTH_SIZE, 1, + None }; + int scrnum; + XSetWindowAttributes attr; + unsigned long mask; + Window root; + XVisualInfo *visinfo; + int width = 300, height = 300; + + if (NumWindows >= MAX_WINDOWS) + 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, 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, displayName, displayName, + None, (char **)NULL, 0, &sizehints); + } + + + ctx = glXCreateContext(dpy, visinfo, + shareWindow ? shareWindow->Context : 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 NULL; + } + + /* save the info for this window */ + { + static int id = 0; + struct window *h = &Windows[NumWindows]; + strcpy(h->DisplayName, displayName); + h->Dpy = dpy; + h->Win = win; + h->Context = ctx; + h->Angle = 0.0; + h->Id = id++; + NumWindows++; + return &Windows[NumWindows-1]; + } + +} + + +static void +InitGLstuff(struct window *h) +{ + if (!glXMakeCurrent(h->Dpy, h->Win, h->Context)) { + Error(h->DisplayName, "glXMakeCurrent failed in InitGLstuff"); + return; + } + + glGenTextures(3, Textures); + + /* setup first texture object */ + { + GLubyte image[16][16][4]; + GLint i, j; + glBindTexture(GL_TEXTURE_2D, Textures[0]); + + /* red/white checkerboard */ + for (i = 0; i < 16; i++) { + for (j = 0; j < 16; j++) { + if ((i ^ j) & 1) { + image[i][j][0] = 255; + image[i][j][1] = 255; + image[i][j][2] = 255; + image[i][j][3] = 255; + } + else { + image[i][j][0] = 255; + image[i][j][1] = 0; + image[i][j][2] = 0; + image[i][j][3] = 255; + } + } + } + + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, GL_RGBA, + GL_UNSIGNED_BYTE, image); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + } + + /* setup second texture object */ + { + GLubyte image[8][8][3]; + GLint i, j; + glBindTexture(GL_TEXTURE_2D, Textures[1]); + + /* green/yellow checkerboard */ + for (i = 0; i < 8; i++) { + for (j = 0; j < 8; j++) { + if ((i ^ j) & 1) { + image[i][j][0] = 0; + image[i][j][1] = 255; + image[i][j][2] = 0; + } + else { + image[i][j][0] = 255; + image[i][j][1] = 255; + image[i][j][2] = 0; + } + } + } + + glPixelStorei(GL_UNPACK_ALIGNMENT, 2); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 8, 8, 0, GL_RGB, + GL_UNSIGNED_BYTE, image); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + } + + /* setup second texture object */ + { + GLubyte image[4][4][3]; + GLint i, j; + glBindTexture(GL_TEXTURE_2D, Textures[2]); + + /* blue/gray checkerboard */ + for (i = 0; i < 4; i++) { + for (j = 0; j < 4; j++) { + if ((i ^ j) & 1) { + image[i][j][0] = 0; + image[i][j][1] = 0; + image[i][j][2] = 255; + } + else { + image[i][j][0] = 200; + image[i][j][1] = 200; + image[i][j][2] = 200; + } + } + } + + glPixelStorei(GL_UNPACK_ALIGNMENT, 2); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 4, 4, 0, GL_RGB, + GL_UNSIGNED_BYTE, image); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + } + + /* Now make the cube object display list */ + CubeList = glGenLists(1); + glNewList(CubeList, GL_COMPILE); + { + glBindTexture(GL_TEXTURE_2D, Textures[0]); + glBegin(GL_POLYGON); + glTexCoord2f(0, 0); glVertex3f(-1, -1, -1); + glTexCoord2f(1, 0); glVertex3f(-1, 1, -1); + glTexCoord2f(1, 1); glVertex3f(-1, 1, 1); + glTexCoord2f(0, 1); glVertex3f(-1, -1, 1); + glEnd(); + glBegin(GL_POLYGON); + glTexCoord2f(0, 0); glVertex3f(1, -1, -1); + glTexCoord2f(1, 0); glVertex3f(1, 1, -1); + glTexCoord2f(1, 1); glVertex3f(1, 1, 1); + glTexCoord2f(0, 1); glVertex3f(1, -1, 1); + glEnd(); + + glBindTexture(GL_TEXTURE_2D, Textures[1]); + glBegin(GL_POLYGON); + glTexCoord2f(0, 0); glVertex3f(-1, -1, -1); + glTexCoord2f(1, 0); glVertex3f( 1, -1, -1); + glTexCoord2f(1, 1); glVertex3f( 1, -1, 1); + glTexCoord2f(0, 1); glVertex3f(-1, -1, 1); + glEnd(); + glBegin(GL_POLYGON); + glTexCoord2f(0, 0); glVertex3f(-1, 1, -1); + glTexCoord2f(1, 0); glVertex3f( 1, 1, -1); + glTexCoord2f(1, 1); glVertex3f( 1, 1, 1); + glTexCoord2f(0, 1); glVertex3f(-1, 1, 1); + glEnd(); + + glBindTexture(GL_TEXTURE_2D, Textures[2]); + glBegin(GL_POLYGON); + glTexCoord2f(0, 0); glVertex3f(-1, -1, -1); + glTexCoord2f(1, 0); glVertex3f( 1, -1, -1); + glTexCoord2f(1, 1); glVertex3f( 1, 1, -1); + glTexCoord2f(0, 1); glVertex3f(-1, 1, -1); + glEnd(); + glBegin(GL_POLYGON); + glTexCoord2f(0, 0); glVertex3f(-1, -1, 1); + glTexCoord2f(1, 0); glVertex3f( 1, -1, 1); + glTexCoord2f(1, 1); glVertex3f( 1, 1, 1); + glTexCoord2f(0, 1); glVertex3f(-1, 1, 1); + glEnd(); + } + glEndList(); + + 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)); +} + + + +static void +Redraw(struct window *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.25, 0.25, 0.25, 1.0); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + glEnable(GL_TEXTURE_2D); + glEnable(GL_DEPTH_TEST); + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); + + glColor3f(1, 1, 1); + + glPushMatrix(); + if (h->Id == 0) + glRotatef(h->Angle, 0, 1, -1); + else if (h->Id == 1) + glRotatef(-(h->Angle), 0, 1, -1); + else if (h->Id == 2) + glRotatef(h->Angle, 0, 1, 1); + else if (h->Id == 3) + glRotatef(-(h->Angle), 0, 1, 1); + glCallList(CubeList); + glPopMatrix(); + + glXSwapBuffers(h->Dpy, h->Win); +} + + + +static void +Resize(const struct window *h, unsigned int width, unsigned int height) +{ + if (!glXMakeCurrent(h->Dpy, h->Win, h->Context)) { + Error(h->DisplayName, "glXMakeCurrent failed in Resize()"); + return; + } + glViewport(0, 0, width, height); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glFrustum(-1, 1, -1, 1, 2, 10); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTranslatef(0, 0, -3.5); +} + + + +static void +EventLoop(void) +{ + while (1) { + int i; + for (i = 0; i < NumWindows; i++) { + struct window *h = &Windows[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 window *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); +} + + +int +main(int argc, char *argv[]) +{ + int i; + struct window *h0, *h1, *h2, *h3; + + /* four windows and contexts sharing display lists and texture objects */ + h0 = AddWindow(":0", 10, 10, NULL); + h1 = AddWindow(":0", 330, 10, h0); + h2 = AddWindow(":0", 10, 350, h0); + h3 = AddWindow(":0", 330, 350, h0); + + InitGLstuff(h0); + + EventLoop(); + return 0; +} diff --git a/progs/tests/stencil_wrap.c b/progs/tests/stencil_wrap.c new file mode 100644 index 00000000000..88cf3809caf --- /dev/null +++ b/progs/tests/stencil_wrap.c @@ -0,0 +1,257 @@ +/* + * (C) Copyright IBM Corporation 2004 + * 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 + * on the rights to use, copy, modify, merge, publish, distribute, sub + * license, 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 (including the next + * paragraph) 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 NON-INFRINGEMENT. IN NO EVENT SHALL + * VA LINUX SYSTEM, IBM AND/OR THEIR SUPPLIERS 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. + */ + +/** + * \file stencil_wrap.c + * + * Simple test of GL_EXT_stencil_wrap functionality. Four squares are drawn + * with different stencil modes, but all should be rendered with the same + * final color. + * + * \author Ian Romanick + */ + +#include +#include +#include + +static int Width = 550; +static int Height = 200; +static const GLfloat Near = 5.0, Far = 25.0; + + +static void Display( void ) +{ + GLint max_stencil; + GLint stencil_bits; + unsigned i; + + + glGetIntegerv( GL_STENCIL_BITS, & stencil_bits ); + max_stencil = (1U << stencil_bits) - 1; + printf( "Stencil bits = %u, maximum stencil value = 0x%08x\n", + stencil_bits, max_stencil ); + + glClearStencil( 0 ); + glClearColor( 0.2, 0.2, 0.8, 0 ); + glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT + | GL_STENCIL_BUFFER_BIT ); + + + glPushMatrix(); + + /* This is the "reference" square. + */ + + glDisable(GL_STENCIL_TEST); + glTranslatef(-6.0, 0, 0); + glBegin(GL_QUADS); + glColor3f( 0.5, 0.5, 0.5 ); + glVertex2f(-1, -1); + glVertex2f( 1, -1); + glVertex2f( 1, 1); + glVertex2f(-1, 1); + glEnd(); + + + glEnable(GL_STENCIL_TEST); + + /* Draw the first two squares using the two non-wrap (i.e., saturate) + * modes. + */ + + glStencilFunc(GL_ALWAYS, 0, ~0); + glStencilOp(GL_KEEP, GL_KEEP, GL_INCR); + + glTranslatef(3.0, 0, 0); + glBegin(GL_QUADS); + glColor3f( 0.9, 0.9, 0.9 ); + + for ( i = 0 ; i < (max_stencil + 5) ; i++ ) { + glVertex2f(-1, -1); + glVertex2f( 1, -1); + glVertex2f( 1, 1); + glVertex2f(-1, 1); + } + glEnd(); + + glStencilFunc(GL_EQUAL, max_stencil, ~0); + glBegin(GL_QUADS); + glColor3f( 0.5, 0.5, 0.5 ); + glVertex2f(-1, -1); + glVertex2f( 1, -1); + glVertex2f( 1, 1); + glVertex2f(-1, 1); + glEnd(); + + + glStencilFunc(GL_ALWAYS, 0, ~0); + glStencilOp(GL_KEEP, GL_KEEP, GL_DECR); + + glTranslatef(3.0, 0, 0); + glBegin(GL_QUADS); + glColor3f( 0.9, 0.9, 0.9 ); + + for ( i = 0 ; i < (max_stencil + 5) ; i++ ) { + glVertex2f(-1, -1); + glVertex2f( 1, -1); + glVertex2f( 1, 1); + glVertex2f(-1, 1); + } + glEnd(); + + glStencilFunc(GL_EQUAL, 0, ~0); + glBegin(GL_QUADS); + glColor3f( 0.5, 0.5, 0.5 ); + glVertex2f(-1, -1); + glVertex2f( 1, -1); + glVertex2f( 1, 1); + glVertex2f(-1, 1); + glEnd(); + + + + + /* Draw the last two squares using the two wrap modes. + */ + + glStencilFunc(GL_ALWAYS, 0, ~0); + glStencilOp(GL_KEEP, GL_KEEP, GL_INCR_WRAP); + + glTranslatef(3.0, 0, 0); + glBegin(GL_QUADS); + glColor3f( 0.9, 0.9, 0.9 ); + + for ( i = 0 ; i < (max_stencil + 5) ; i++ ) { + glVertex2f(-1, -1); + glVertex2f( 1, -1); + glVertex2f( 1, 1); + glVertex2f(-1, 1); + } + glEnd(); + + glStencilFunc(GL_EQUAL, 4, ~0); + glBegin(GL_QUADS); + glColor3f( 0.5, 0.5, 0.5 ); + glVertex2f(-1, -1); + glVertex2f( 1, -1); + glVertex2f( 1, 1); + glVertex2f(-1, 1); + glEnd(); + + + + glStencilFunc(GL_ALWAYS, 0, ~0); + glStencilOp(GL_KEEP, GL_KEEP, GL_DECR_WRAP); + + glTranslatef(3.0, 0, 0); + glBegin(GL_QUADS); + glColor3f( 0.9, 0.9, 0.9 ); + + for ( i = 0 ; i < 5 ; i++ ) { + glVertex2f(-1, -1); + glVertex2f( 1, -1); + glVertex2f( 1, 1); + glVertex2f(-1, 1); + } + glEnd(); + + glStencilFunc(GL_EQUAL, (max_stencil - 4), ~0); + glBegin(GL_QUADS); + glColor3f( 0.5, 0.5, 0.5 ); + glVertex2f(-1, -1); + glVertex2f( 1, -1); + glVertex2f( 1, 1); + glVertex2f(-1, 1); + glEnd(); + + + + glPopMatrix(); + + glutSwapBuffers(); +} + + +static void Reshape( int width, int height ) +{ + GLfloat ar = (float) width / (float) height; + Width = width; + Height = height; + glViewport( 0, 0, width, height ); + glMatrixMode( GL_PROJECTION ); + glLoadIdentity(); + glFrustum( -ar, ar, -1.0, 1.0, Near, Far ); + glMatrixMode( GL_MODELVIEW ); + glLoadIdentity(); + glTranslatef( 0.0, 0.0, -15.0 ); +} + + +static void Key( unsigned char key, int x, int y ) +{ + (void) x; + (void) y; + switch (key) { + case 27: + exit(0); + break; + } + glutPostRedisplay(); +} + + +static void Init( void ) +{ + const char * const ver_string = (const char * const) + glGetString( GL_VERSION ); + + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + printf("GL_VERSION = %s\n", ver_string); + + if ( !glutExtensionSupported("GL_EXT_stencil_wrap") + && (atof( ver_string ) < 1.4) ) { + printf("Sorry, this program requires either GL_EXT_stencil_wrap or OpenGL 1.4.\n"); + exit(1); + } + + printf("\nAll 5 squares should be the same color.\n"); + glEnable( GL_BLEND ); +} + + +int main( int argc, char *argv[] ) +{ + glutInit( &argc, argv ); + glutInitWindowPosition( 0, 0 ); + glutInitWindowSize( Width, Height ); + glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH | GLUT_STENCIL ); + glutCreateWindow( "GL_EXT_stencil_wrap test" ); + glutReshapeFunc( Reshape ); + glutKeyboardFunc( Key ); + glutDisplayFunc( Display ); + Init(); + glutMainLoop(); + return 0; +} diff --git a/progs/tests/stencilwrap.c b/progs/tests/stencilwrap.c new file mode 100644 index 00000000000..753375d0f3a --- /dev/null +++ b/progs/tests/stencilwrap.c @@ -0,0 +1,281 @@ +/* Test GL_EXT_stencil_wrap extension. + * This is by no means complete, just a quick check. + * + * Brian Paul 30 October 2002 + */ + +#include +#include +#include +#include +#include + +GLboolean wrapping; + +static void RunTest(void) +{ + const GLenum prim = GL_QUAD_STRIP; + GLubyte val; + int bits, max, i; + int expected; + GLboolean failed; + + glGetIntegerv(GL_STENCIL_BITS, &bits); + max = (1 << bits) - 1; + + + glEnable(GL_STENCIL_TEST); + glStencilFunc(GL_ALWAYS, 0, ~0); + + /* test GL_KEEP */ + glClearStencil(max); + glClear(GL_STENCIL_BUFFER_BIT); + glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); + failed = GL_FALSE; + printf("Testing GL_KEEP...\n"); + expected = max; + glBegin(prim); + glVertex2f(0, 0); + glVertex2f(10, 0); + glVertex2f(0, 10); + glVertex2f(10, 10); + glEnd(); + glReadPixels(0, 0, 1, 1, GL_STENCIL_INDEX, GL_UNSIGNED_BYTE, &val); + if (val != expected) { + printf("Failed GL_KEEP test(got %u, expected %u)\n", val, expected); + failed = GL_TRUE; + } + else + printf("OK!\n"); + + /* test GL_ZERO */ + glClearStencil(max); + glClear(GL_STENCIL_BUFFER_BIT); + glStencilOp(GL_KEEP, GL_KEEP, GL_ZERO); + failed = GL_FALSE; + printf("Testing GL_ZERO...\n"); + expected = 0; + glBegin(prim); + glVertex2f(0, 0); + glVertex2f(10, 0); + glVertex2f(0, 10); + glVertex2f(10, 10); + glEnd(); + glReadPixels(0, 0, 1, 1, GL_STENCIL_INDEX, GL_UNSIGNED_BYTE, &val); + if (val != expected) { + printf("Failed GL_ZERO test(got %u, expected %u)\n", val, expected); + failed = GL_TRUE; + } + else + printf("OK!\n"); + + /* test GL_REPLACE */ + glClearStencil(max); + glClear(GL_STENCIL_BUFFER_BIT); + glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE); + failed = GL_FALSE; + printf("Testing GL_REPLACE...\n"); + expected = 0; + glBegin(prim); + glVertex2f(0, 0); + glVertex2f(10, 0); + glVertex2f(0, 10); + glVertex2f(10, 10); + glEnd(); + glReadPixels(0, 0, 1, 1, GL_STENCIL_INDEX, GL_UNSIGNED_BYTE, &val); + if (val != expected) { + printf("Failed GL_REPLACE test(got %u, expected %u)\n", val, expected); + failed = GL_TRUE; + } + else + printf("OK!\n"); + + /* test GL_INCR (saturation) */ + glClearStencil(0); + glClear(GL_STENCIL_BUFFER_BIT); + glStencilOp(GL_KEEP, GL_KEEP, GL_INCR); + failed = GL_FALSE; + printf("Testing GL_INCR...\n"); + for (i = 1; i < max+10; i++) { + expected = (i > max) ? max : i; + glBegin(prim); + glVertex2f(0, 0); glVertex2f(10, 0); + glVertex2f(0, 10); glVertex2f(10, 10); + glEnd(); + + glReadPixels(0, 0, 1, 1, GL_STENCIL_INDEX, GL_UNSIGNED_BYTE, &val); + if (val != expected) { + printf( "Failed GL_INCR test on iteration #%u " + "(got %u, expected %u)\n", i, val, expected ); + failed = GL_TRUE; + } + } + if ( !failed ) + printf("OK!\n"); + + /* test GL_DECR (saturation) */ + glClearStencil(max); + glClear(GL_STENCIL_BUFFER_BIT); + glStencilOp(GL_KEEP, GL_KEEP, GL_DECR); + failed = GL_FALSE; + printf("Testing GL_DECR...\n"); + for (i = max-1; i > -10; i--) { + expected = (i < 0) ? 0 : i; + glBegin(prim); + glVertex2f(0, 0); glVertex2f(10, 0); + glVertex2f(0, 10); glVertex2f(10, 10); + glEnd(); + glReadPixels(0, 0, 1, 1, GL_STENCIL_INDEX, GL_UNSIGNED_BYTE, &val); + if (val != expected) { + printf( "Failed GL_DECR test on iteration #%u " + "(got %u, expected %u)\n", max - i, val, expected ); + failed = GL_TRUE; + } + } + if ( !failed ) + printf("OK!\n"); + + /* test GL_INVERT */ + glClearStencil(0); + glClear(GL_STENCIL_BUFFER_BIT); + glStencilOp(GL_KEEP, GL_KEEP, GL_INVERT); + failed = GL_FALSE; + printf("Testing GL_INVERT...\n"); + expected = max; + glBegin(prim); + glVertex2f(0, 0); + glVertex2f(10, 0); + glVertex2f(0, 10); + glVertex2f(10, 10); + glEnd(); + glReadPixels(0, 0, 1, 1, GL_STENCIL_INDEX, GL_UNSIGNED_BYTE, &val); + if (val != expected) { + printf("Failed GL_INVERT test(got %u, expected %u)\n", val, expected); + failed = GL_TRUE; + } + else + printf("OK!\n"); + + if(wrapping) + { + /* test GL_INCR_WRAP_EXT (wrap around) */ + glClearStencil(0); + glClear(GL_STENCIL_BUFFER_BIT); + glStencilOp(GL_KEEP, GL_KEEP, GL_INCR_WRAP_EXT); + failed = GL_FALSE; + printf("Testing GL_INCR_WRAP_EXT...\n"); + for (i = 1; i < max+10; i++) { + expected = i % (max + 1); + glBegin(prim); + glVertex2f(0, 0); glVertex2f(10, 0); + glVertex2f(0, 10); glVertex2f(10, 10); + glEnd(); + glReadPixels(0, 0, 1, 1, GL_STENCIL_INDEX, GL_UNSIGNED_BYTE, &val); + if (val != expected) { + printf( "Failed GL_INCR_WRAP test on iteration #%u " + "(got %u, expected %u)\n", i, val, expected ); + failed = GL_TRUE; + } + } + if ( !failed ) + printf("OK!\n"); + + /* test GL_DECR_WRAP_EXT (wrap-around) */ + glClearStencil(max); + glClear(GL_STENCIL_BUFFER_BIT); + glStencilOp(GL_KEEP, GL_KEEP, GL_DECR_WRAP_EXT); + failed = GL_FALSE; + printf("Testing GL_DECR_WRAP_EXT...\n"); + for (i = max-1; i > -10; i--) { + expected = (i < 0) ? max + i + 1: i; + glBegin(prim); + glVertex2f(0, 0); glVertex2f(10, 0); + glVertex2f(0, 10); glVertex2f(10, 10); + glEnd(); + glReadPixels(0, 0, 1, 1, GL_STENCIL_INDEX, GL_UNSIGNED_BYTE, &val); + if (val != expected) { + printf( "Failed GL_DECR_WRAP test on iteration #%u " + "(got %u, expected %u)\n", max - i, val, expected ); + failed = GL_TRUE; + } + } + if ( !failed ) + printf("OK!\n"); + } + + glDisable(GL_STENCIL_TEST); +} + + +static void Display( void ) +{ + glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); + + RunTest(); + + 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 27: + exit(0); + break; + } + glutPostRedisplay(); +} + + +static void Init( void ) +{ + const char * ver_str; + float version; + + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + printf("GL_VERSION = %s\n", (char *) glGetString(GL_VERSION)); + + + /* Check for both the extension string and GL version 1.4 on the + * outside chance that some vendor exports version 1.4 but doesn't + * export the extension string. The stencil-wrap modes are a required + * part of GL 1.4. + */ + + ver_str = glGetString( GL_VERSION ); + version = (ver_str == NULL) ? 1.0 : atof( ver_str ); + + wrapping = (glutExtensionSupported("GL_EXT_stencil_wrap") || (version >= 1.4)); + if (!wrapping) + printf("GL_EXT_stencil_wrap not supported. Only testing the rest.\n"); +} + + +int main( int argc, char *argv[] ) +{ + glutInit( &argc, argv ); + glutInitWindowPosition( 0, 0 ); + glutInitWindowSize( 400, 400 ); + glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_STENCIL ); + glutCreateWindow(argv[0]); + glutReshapeFunc( Reshape ); + glutKeyboardFunc( Key ); + glutDisplayFunc( Display ); + Init(); + glutMainLoop(); + return 0; +} diff --git a/progs/tests/subtexrate.c b/progs/tests/subtexrate.c new file mode 100644 index 00000000000..568b68d552d --- /dev/null +++ b/progs/tests/subtexrate.c @@ -0,0 +1,350 @@ +/* + * Measure glTexSubImage and glCopyTexSubImage speed + * + * Brian Paul + * 26 Jan 2006 + */ + +#define GL_GLEXT_PROTOTYPES +#include +#include +#include +#include +#include + +static GLint WinWidth = 1024, WinHeight = 512; +static GLint TexWidth = 512, TexHeight = 512; + +static GLuint TexObj = 1; + +static GLenum IntFormat = GL_RGBA8; +static GLenum ReadFormat = GL_RGBA; /* for glReadPixels */ + +static GLboolean DrawQuad = GL_TRUE; + + +/** + * draw teapot image, size TexWidth by TexHeight + */ +static void +DrawTestImage(void) +{ + GLfloat ar; + + glViewport(0, 0, TexWidth, TexHeight); + glScissor(0, 0, TexWidth, TexHeight); + glEnable(GL_SCISSOR_TEST); + + glClearColor(0.5, 0.5, 0.5, 0.0); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + ar = (float) TexWidth / TexHeight; + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glFrustum(-ar, ar, -1.0, 1.0, 5.0, 25.0); + glMatrixMode(GL_MODELVIEW); + + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + glEnable(GL_DEPTH_TEST); + glFrontFace(GL_CW); + glPushMatrix(); + glRotatef(45, 1, 0, 0); + glRotatef(45, 0, 1, 0); + glutSolidTeapot(2.3); + glPopMatrix(); + glFrontFace(GL_CCW); + glDisable(GL_DEPTH_TEST); + glDisable(GL_LIGHTING); + + glDisable(GL_SCISSOR_TEST); + + glViewport(0, 0, WinWidth, WinHeight); + glFinish(); +} + + +/** + * Do glCopyTexSubImage2D call (update texture with framebuffer data) + * If doSubRect is true, do the copy in four pieces instead of all at once. + */ +static void +DoCopyTex(GLboolean doSubRect) +{ + if (doSubRect) { + /* copy in four parts */ + int w = TexWidth / 2, h = TexHeight / 2; + int x0 = 0, y0 = 0; + int x1 = w, y1 = h; +#if 1 + glCopyTexSubImage2D(GL_TEXTURE_2D, 0, x0, y0, x0, y0, w, h); + glCopyTexSubImage2D(GL_TEXTURE_2D, 0, x1, y0, x1, y0, w, h); + glCopyTexSubImage2D(GL_TEXTURE_2D, 0, x0, y1, x0, y1, w, h); + glCopyTexSubImage2D(GL_TEXTURE_2D, 0, x1, y1, x1, y1, w, h); +#else + /* scramble */ + glCopyTexSubImage2D(GL_TEXTURE_2D, 0, x0, y0, x1, y1, w, h); + glCopyTexSubImage2D(GL_TEXTURE_2D, 0, x1, y0, x0, y1, w, h); + glCopyTexSubImage2D(GL_TEXTURE_2D, 0, x0, y1, x1, y0, w, h); + glCopyTexSubImage2D(GL_TEXTURE_2D, 0, x1, y1, x0, y0, w, h); +#endif + } + else { + glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, TexWidth, TexHeight); + } +} + + +/** + * Do glTexSubImage2D (update texture w/ user data) + * If doSubRect, do update in four pieces, else all at once. + */ +static void +SubTex(GLboolean doSubRect, const GLubyte *image) +{ + if (doSubRect) { + /* four pieces */ + int w = TexWidth / 2, h = TexHeight / 2; + int x0 = 0, y0 = 0; + int x1 = w, y1 = h; + glPixelStorei(GL_UNPACK_ROW_LENGTH, TexWidth); + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + + glPixelStorei(GL_UNPACK_SKIP_ROWS, y0); + glPixelStorei(GL_UNPACK_SKIP_PIXELS, x0); + glTexSubImage2D(GL_TEXTURE_2D, 0, x0, y0, w, h, + ReadFormat, GL_UNSIGNED_BYTE, image); + + glPixelStorei(GL_UNPACK_SKIP_ROWS, y0); + glPixelStorei(GL_UNPACK_SKIP_PIXELS, x1); + glTexSubImage2D(GL_TEXTURE_2D, 0, x1, y0, w, h, + ReadFormat, GL_UNSIGNED_BYTE, image); + + glPixelStorei(GL_UNPACK_SKIP_ROWS, y1); + glPixelStorei(GL_UNPACK_SKIP_PIXELS, x0); + glTexSubImage2D(GL_TEXTURE_2D, 0, x0, y1, w, h, + ReadFormat, GL_UNSIGNED_BYTE, image); + + glPixelStorei(GL_UNPACK_SKIP_ROWS, y1); + glPixelStorei(GL_UNPACK_SKIP_PIXELS, x1); + glTexSubImage2D(GL_TEXTURE_2D, 0, x1, y1, w, h, + ReadFormat, GL_UNSIGNED_BYTE, image); + } + else { + /* all at once */ + glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, TexWidth, TexHeight, + ReadFormat, GL_UNSIGNED_BYTE, image); + } +} + + +/** + * Measure gl[Copy]TexSubImage rate. + * This actually also includes time to render a quad and SwapBuffers. + */ +static void +RunTest(GLboolean copyTex, GLboolean doSubRect) +{ + double t0, t1; + int iters = 0; + float copyRate, mbRate; + float rot = 0.0; + int bpp, r, g, b, a; + int w, h; + GLubyte *image = NULL; + + 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); + bpp = (r + g + b + a) / 8; + + if (!copyTex) { + /* read image from frame buffer */ + image = (GLubyte *) malloc(TexWidth * TexHeight * bpp); + glPixelStorei(GL_PACK_ALIGNMENT, 1); + glReadPixels(0, 0, TexWidth, TexHeight, + ReadFormat, GL_UNSIGNED_BYTE, image); + } + + glEnable(GL_TEXTURE_2D); + glViewport(WinWidth / 2, 0, WinWidth / 2, WinHeight); + + t0 = glutGet(GLUT_ELAPSED_TIME) / 1000.0; + + do { + if (copyTex) + /* Framebuffer -> Texture */ + DoCopyTex(doSubRect); + else { + /* Main Mem -> Texture */ + SubTex(doSubRect, image); + } + + /* draw textured quad */ + if (DrawQuad) { + glPushMatrix(); + glRotatef(rot, 0, 0, 1); + glTranslatef(1, 0, 0); + glBegin(GL_POLYGON); + glTexCoord2f(0, 0); glVertex2f(-1, -1); + glTexCoord2f(1, 0); glVertex2f( 1, -1); + glTexCoord2f(1, 1); glVertex2f( 1, 1); + glTexCoord2f(0, 1); glVertex2f(-1, 1); + glEnd(); + glPopMatrix(); + } + + iters++; + rot += 2.0; + + t1 = glutGet(GLUT_ELAPSED_TIME) / 1000.0; + if (DrawQuad) { + glutSwapBuffers(); + } + } while (t1 - t0 < 5.0); + + glDisable(GL_TEXTURE_2D); + if (image) + free(image); + + if (doSubRect) { + w = TexWidth / 2; + h = TexHeight / 2; + iters *= 4; + } + else { + w = TexWidth; + h = TexHeight; + } + + copyRate = iters / (t1 - t0); + mbRate = w * h * bpp * copyRate / (1024 * 1024); + + if (copyTex) + printf("glCopyTexSubImage: %d x %d, %d Bpp:\n", w, h, bpp); + else + printf("glTexSubImage: %d x %d, %d Bpp:\n", w, h, bpp); + printf(" %d calls in %.2f = %.2f calls/sec, %.2f MB/s\n", + iters, t1-t0, copyRate, mbRate); +} + + +static void +Draw(void) +{ + glClearColor(0.2, 0.2, 0.8, 0); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + DrawTestImage(); + if (!DrawQuad) { + glutSwapBuffers(); + } + + RunTest(GL_FALSE, GL_FALSE); + RunTest(GL_FALSE, GL_TRUE); + RunTest(GL_TRUE, GL_FALSE); + RunTest(GL_TRUE, GL_TRUE); + + glutSwapBuffers(); + + printf("exiting\n"); + exit(0); +} + + +static void +Reshape(int width, int height) +{ + glViewport(0, 0, width, height); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glFrustum(-1.0, 1.0, -1.0, 1.0, 5.0, 25.0); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTranslatef(0.0, 0.0, -15.0); +} + + +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) +{ + (void) x; + (void) y; + switch (key) { + case GLUT_KEY_UP: + break; + case GLUT_KEY_DOWN: + break; + case GLUT_KEY_LEFT: + break; + case GLUT_KEY_RIGHT: + break; + } + glutPostRedisplay(); +} + + +static void +Init(void) +{ + /* create initial, empty teximage */ + glBindTexture(GL_TEXTURE_2D, TexObj); + glTexImage2D(GL_TEXTURE_2D, 0, IntFormat, TexWidth, TexHeight, 0, + GL_RGBA, GL_UNSIGNED_BYTE, NULL); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); +} + + + +static void +ParseArgs(int argc, char *argv[]) +{ + int i; + for (i = 1; i < argc; i++) { + if (strcmp(argv[i], "-nodraw") == 0) + DrawQuad = GL_FALSE; + } +} + + +int +main(int argc, char *argv[]) +{ + GLint mode = GLUT_RGB | GLUT_ALPHA | GLUT_DOUBLE | GLUT_DEPTH; + glutInit(&argc, argv); + + ParseArgs(argc, argv); + + glutInitWindowPosition(0, 0); + glutInitWindowSize(WinWidth, WinHeight); + glutInitDisplayMode(mode); + glutCreateWindow(argv[0]); + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutSpecialFunc(SpecialKey); + glutDisplayFunc(Draw); + + printf("GL_RENDERER: %s\n", (char *) glGetString(GL_RENDERER)); + Init(); + + glutMainLoop(); + return 0; +} diff --git a/progs/tests/tex1d.c b/progs/tests/tex1d.c new file mode 100644 index 00000000000..1fab849dd3e --- /dev/null +++ b/progs/tests/tex1d.c @@ -0,0 +1,139 @@ + +/* Exercise 1D textures + */ + +#include +#include +#include +#include +#include +#include "GL/glut.h" + +static GLuint Window = 0; +static GLuint TexObj[2]; +static GLfloat Angle = 0.0f; + + +static void draw( void ) +{ + glClear( GL_COLOR_BUFFER_BIT ); + + glColor3f( 1.0, 1.0, 1.0 ); + + /* draw first polygon */ + glPushMatrix(); + glTranslatef( -1.0, 0.0, 0.0 ); + glRotatef( Angle, 0.0, 0.0, 1.0 ); + glBindTexture( GL_TEXTURE_1D, TexObj[0] ); + glBegin( GL_POLYGON ); + glTexCoord1f( 0.0 ); glVertex2f( -1.0, -1.0 ); + glTexCoord1f( 1.0 ); glVertex2f( 1.0, -1.0 ); + glTexCoord1f( 1.0 ); glVertex2f( 1.0, 1.0 ); + glTexCoord1f( 0.0 ); glVertex2f( -1.0, 1.0 ); + glEnd(); + glPopMatrix(); + + glutSwapBuffers(); +} + + + +static void idle( void ) +{ + Angle += 2.0; + glutPostRedisplay(); +} + + + +/* change view Angle, exit upon ESC */ +static void key(unsigned char k, int x, int y) +{ + (void) x; + (void) y; + switch (k) { + case 27: + exit(0); + } +} + + + +/* new window size or exposure */ +static void reshape( int width, int height ) +{ + glViewport(0, 0, (GLint)width, (GLint)height); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + /* glOrtho( -3.0, 3.0, -3.0, 3.0, -10.0, 10.0 );*/ + 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 ) +{ + GLubyte tex[256][3]; + GLint i; + + + glDisable( GL_DITHER ); + + /* Setup texturing */ + glEnable( GL_TEXTURE_1D ); + glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL ); + + + /* generate texture object IDs */ + glGenTextures( 2, TexObj ); + + /* setup first texture object */ + glBindTexture( GL_TEXTURE_1D, TexObj[0] ); + + + for (i = 0; i < 256; i++) { + GLfloat f; + + /* map 0..255 to -PI .. PI */ + f = ((i / 255.0) - .5) * (3.141592 * 2); + + f = sin(f); + + /* map -1..1 to 0..255 */ + tex[i][0] = (f+1.0)/2.0 * 255.0; + tex[i][1] = 0; + tex[i][2] = 0; + } + + glTexImage1D( GL_TEXTURE_1D, 0, 3, 256, 0, GL_RGB, GL_UNSIGNED_BYTE, tex ); + glTexParameteri( GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_NEAREST ); + glTexParameteri( GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_NEAREST ); + glTexParameteri( GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, GL_REPEAT ); + glTexParameteri( GL_TEXTURE_1D, GL_TEXTURE_WRAP_T, GL_REPEAT ); +} + + + +int main( int argc, char *argv[] ) +{ + glutInit(&argc, argv); + glutInitWindowPosition(0, 0); + glutInitWindowSize(300, 300); + glutInitDisplayMode( GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE ); + + Window = glutCreateWindow("Texture Objects"); + if (!Window) { + exit(1); + } + + init(); + + glutReshapeFunc( reshape ); + glutKeyboardFunc( key ); +/* glutIdleFunc( idle ); */ + glutDisplayFunc( draw ); + glutMainLoop(); + return 0; +} diff --git a/progs/tests/texcmp.c b/progs/tests/texcmp.c new file mode 100644 index 00000000000..6e822fb6895 --- /dev/null +++ b/progs/tests/texcmp.c @@ -0,0 +1,414 @@ +/* + * Compressed texture demo. Written by Daniel Borca. + * This program is in the public domain. + */ + +#include +#include +#include +#include +#define GL_GLEXT_PROTOTYPES 1 +#include + +#include "readtex.c" /* I know, this is a hack. */ +#define TEXTURE_FILE "../images/tree2.rgba" + + +static float Rot = 0.0; +static GLboolean Anim = 1; + +typedef struct { + GLubyte *data; + GLuint size; + GLenum format; + GLuint w, h; + + GLenum TC; + + GLubyte *cData; + GLuint cSize; + GLenum cFormat; +} TEXTURE; + +static TEXTURE *Tx, t1, t2, t3; +static GLboolean fxt1, dxtc, s3tc; + + +static const char *TextureName (GLenum TC) +{ + switch (TC) { + case GL_RGB: + return "RGB"; + case GL_RGBA: + return "RGBA"; + case GL_COMPRESSED_RGB: + return "COMPRESSED_RGB"; + case GL_COMPRESSED_RGBA: + return "COMPRESSED_RGBA"; + case GL_COMPRESSED_RGB_FXT1_3DFX: + return "GL_COMPRESSED_RGB_FXT1_3DFX"; + case GL_COMPRESSED_RGBA_FXT1_3DFX: + return "GL_COMPRESSED_RGBA_FXT1_3DFX"; + case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: + return "GL_COMPRESSED_RGB_S3TC_DXT1_EXT"; + case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: + return "GL_COMPRESSED_RGBA_S3TC_DXT1_EXT"; + case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: + return "GL_COMPRESSED_RGBA_S3TC_DXT3_EXT"; + case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: + return "GL_COMPRESSED_RGBA_S3TC_DXT5_EXT"; + case GL_RGB_S3TC: + return "GL_RGB_S3TC"; + case GL_RGB4_S3TC: + return "GL_RGB4_S3TC"; + case GL_RGBA_S3TC: + return "GL_RGBA_S3TC"; + case GL_RGBA4_S3TC: + return "GL_RGBA4_S3TC"; + case 0: + return "Invalid format"; + default: + return "Unknown format"; + } +} + + +static void +PrintString(const char *s) +{ + while (*s) { + glutBitmapCharacter(GLUT_BITMAP_8_BY_13, (int) *s); + s++; + } +} + + +static void Idle( void ) +{ + float t = glutGet(GLUT_ELAPSED_TIME) * 0.001; /* in seconds */ + Rot = t * 360 / 4; /* 1 rotation per 4 seconds */ + glutPostRedisplay(); +} + + +static void Display( void ) +{ + /* draw background gradient */ + glDisable(GL_TEXTURE_2D); + glBegin(GL_POLYGON); + glColor3f(1.0, 0.0, 0.2); glVertex2f(-1.5, -1.0); + glColor3f(1.0, 0.0, 0.2); glVertex2f( 1.5, -1.0); + glColor3f(0.0, 0.0, 1.0); glVertex2f( 1.5, 1.0); + glColor3f(0.0, 0.0, 1.0); glVertex2f(-1.5, 1.0); + glEnd(); + + glPushMatrix(); + glRotatef(Rot, 0, 0, 1); + + glEnable(GL_TEXTURE_2D); + glBegin(GL_POLYGON); + glTexCoord2f(0, 1); glVertex2f(-1, -0.5); + glTexCoord2f(1, 1); glVertex2f( 1, -0.5); + glTexCoord2f(1, 0); glVertex2f( 1, 0.5); + glTexCoord2f(0, 0); glVertex2f(-1, 0.5); + glEnd(); + + glPopMatrix(); + + /* info */ + glColor4f(1, 1, 1, 1); + + glRasterPos3f(-1.2, -0.7, 0); + PrintString("Selected: "); + PrintString(TextureName(Tx->TC)); + if (Tx->cData) { + char tmp[64]; + glRasterPos3f(-1.2, -0.8, 0); + PrintString("Internal: "); + PrintString(TextureName(Tx->cFormat)); + glRasterPos3f(-1.2, -0.9, 0); + PrintString("Size : "); + sprintf(tmp, "%d (%d%% of %d)", Tx->cSize, Tx->cSize * 100 / Tx->size, Tx->size); + PrintString(tmp); + } + + glutSwapBuffers(); +} + + +static void Reshape( int width, int height ) +{ + glViewport( 0, 0, width, height ); + glMatrixMode( GL_PROJECTION ); + glLoadIdentity(); + glOrtho( -1.5, 1.5, -1.0, 1.0, -1.0, 1.0 ); + glMatrixMode( GL_MODELVIEW ); + glLoadIdentity(); +} + + +static void ReInit( GLenum TC, TEXTURE *Tx ) +{ + GLint rv; + + if ((Tx->TC == TC) && (Tx->cData != NULL)) { + glCompressedTexImage2DARB(GL_TEXTURE_2D, /* target */ + 0, /* level */ + Tx->cFormat, /* real format */ + Tx->w, /* original width */ + Tx->h, /* original height */ + 0, /* border */ + Tx->cSize, /* compressed size*/ + Tx->cData); /* compressed data*/ + } else { + glTexImage2D(GL_TEXTURE_2D, /* target */ + 0, /* level */ + TC, /* internal format */ + Tx->w, Tx->h, /* width, height */ + 0, /* border */ + Tx->format, /* texture format */ + GL_UNSIGNED_BYTE, /* texture type */ + Tx->data); /* the texture */ + + /* okay, now cache the compressed texture */ + Tx->TC = TC; + if (Tx->cData != NULL) { + free(Tx->cData); + Tx->cData = NULL; + } + glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_COMPRESSED_ARB, &rv); + if (rv) { + glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_INTERNAL_FORMAT, (GLint *)&Tx->cFormat); + glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB, (GLint *)&Tx->cSize); + if ((Tx->cData = malloc(Tx->cSize)) != NULL) { + glGetCompressedTexImageARB(GL_TEXTURE_2D, 0, Tx->cData); + } + } + } +} + + +static void Init( void ) +{ + /* HEIGHT * WIDTH + 1 (for trailing '\0') */ + static char pattern[8 * 32 + 1] = {"\ + \ + MMM EEEE SSS AAA \ + M M M E S S A A \ + M M M EEEE SS A A \ + M M M E SS AAAAA \ + M M E S S A A \ + M M EEEE SSS A A \ + " + }; + + GLuint i, j; + + GLubyte (*texture1)[8 * 32][4]; + GLubyte (*texture2)[256][256][4]; + + t1.w = 32; + t1.h = 8; + t1.size = t1.w * t1.h * 4; + t1.data = malloc(t1.size); + t1.format = GL_RGBA; + t1.TC = GL_RGBA; + + texture1 = (GLubyte (*)[8 * 32][4])t1.data; + for (i = 0; i < sizeof(pattern) - 1; i++) { + switch (pattern[i]) { + default: + case ' ': + (*texture1)[i][0] = 255; + (*texture1)[i][1] = 255; + (*texture1)[i][2] = 255; + (*texture1)[i][3] = 64; + break; + case 'M': + (*texture1)[i][0] = 255; + (*texture1)[i][1] = 0; + (*texture1)[i][2] = 0; + (*texture1)[i][3] = 255; + break; + case 'E': + (*texture1)[i][0] = 0; + (*texture1)[i][1] = 255; + (*texture1)[i][2] = 0; + (*texture1)[i][3] = 255; + break; + case 'S': + (*texture1)[i][0] = 0; + (*texture1)[i][1] = 0; + (*texture1)[i][2] = 255; + (*texture1)[i][3] = 255; + break; + case 'A': + (*texture1)[i][0] = 255; + (*texture1)[i][1] = 255; + (*texture1)[i][2] = 0; + (*texture1)[i][3] = 255; + break; + } + } + + t2.w = 256; + t2.h = 256; + t2.size = t2.w * t2.h * 4; + t2.data = malloc(t2.size); + t2.format = GL_RGBA; + t2.TC = GL_RGBA; + + texture2 = (GLubyte (*)[256][256][4])t2.data; + for (j = 0; j < t2.h; j++) { + for (i = 0; i < t2.w; i++) { + (*texture2)[j][i][0] = sqrt(i * j * 255 * 255 / (t2.w * t2.h)); + (*texture2)[j][i][1] = 0; + (*texture2)[j][i][2] = 0; + (*texture2)[j][i][3] = 255; + } + } + + t3.data = LoadRGBImage(TEXTURE_FILE, (GLint *)&t3.w, (GLint *)&t3.h, &t3.format); + t3.size = t3.w * t3.h * ((t3.format == GL_RGB) ? 3 : 4); + t3.TC = GL_RGBA; + + ReInit(GL_RGBA, Tx = &t1); + + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); + glEnable(GL_TEXTURE_2D); + + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); +} + + +static void Key( unsigned char key, int x, int y ) +{ + (void) x; + (void) y; + switch (key) { + case 27: + exit(0); + break; + case ' ': + Anim = !Anim; + if (Anim) + glutIdleFunc( Idle ); + else + glutIdleFunc( NULL ); + break; + case 't': + if (Tx == &t1) { + Tx = &t2; + } else if (Tx == &t2) { + Tx = &t3; + } else { + Tx = &t1; + } + ReInit(Tx->TC, Tx); + break; + case '9': + ReInit(GL_RGB, Tx); + break; + case '0': + ReInit(GL_RGBA, Tx); + break; + case '1': + ReInit(GL_COMPRESSED_RGB, Tx); + break; + case '2': + ReInit(GL_COMPRESSED_RGBA, Tx); + break; + case '3': + if (fxt1) ReInit(GL_COMPRESSED_RGB_FXT1_3DFX, Tx); + break; + case '4': + if (fxt1) ReInit(GL_COMPRESSED_RGBA_FXT1_3DFX, Tx); + break; + case '5': + if (dxtc) ReInit(GL_COMPRESSED_RGB_S3TC_DXT1_EXT, Tx); + break; + case '6': + if (dxtc) ReInit(GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, Tx); + break; + case '7': + if (dxtc) ReInit(GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, Tx); + break; + case '8': + if (dxtc) ReInit(GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, Tx); + break; + case 'a': + if (s3tc) ReInit(GL_RGB_S3TC, Tx); + break; + case 's': + if (s3tc) ReInit(GL_RGB4_S3TC, Tx); + break; + case 'd': + if (s3tc) ReInit(GL_RGBA_S3TC, Tx); + break; + case 'f': + if (s3tc) ReInit(GL_RGBA4_S3TC, Tx); + break; + } + glutPostRedisplay(); +} + + +int main( int argc, char *argv[] ) +{ + float gl_version; + GLint num_formats; + GLint i; + GLint formats[64]; + + + glutInit( &argc, argv ); + glutInitWindowPosition( 0, 0 ); + glutInitWindowSize( 400, 300 ); + + glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE ); + + if (glutCreateWindow(argv[0]) <= 0) { + printf("Couldn't create window\n"); + exit(0); + } + + gl_version = atof( (const char *) glGetString( GL_VERSION ) ); + if ( (gl_version < 1.3) + && !glutExtensionSupported("GL_ARB_texture_compression") ) { + printf("Sorry, GL_ARB_texture_compression not supported\n"); + exit(0); + } + if (glutExtensionSupported("GL_3DFX_texture_compression_FXT1")) { + fxt1 = GL_TRUE; + } + if (glutExtensionSupported("GL_EXT_texture_compression_s3tc")) { + dxtc = GL_TRUE; + } + if (glutExtensionSupported("GL_S3_s3tc")) { + s3tc = GL_TRUE; + } + + glGetIntegerv( GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB, & num_formats ); + + (void) memset( formats, 0, sizeof( formats ) ); + glGetIntegerv( GL_COMPRESSED_TEXTURE_FORMATS_ARB, formats ); + + printf( "The following texture formats are supported:\n" ); + for ( i = 0 ; i < num_formats ; i++ ) { + printf( "\t%s\n", TextureName( formats[i] ) ); + } + + Init(); + + glutReshapeFunc( Reshape ); + glutKeyboardFunc( Key ); + glutDisplayFunc( Display ); + if (Anim) + glutIdleFunc( Idle ); + + glutMainLoop(); + return 0; +} diff --git a/progs/tests/texcompress2.c b/progs/tests/texcompress2.c new file mode 100644 index 00000000000..e2eed756b62 --- /dev/null +++ b/progs/tests/texcompress2.c @@ -0,0 +1,273 @@ +/* + * Test texture compression. + */ + + +#define GL_GLEXT_PROTOTYPES +#include +#include +#include +#include +#include "readtex.c" + +#define IMAGE_FILE "../images/arch.rgb" + +static int ImgWidth, ImgHeight; +static GLenum ImgFormat; +static GLenum CompFormat; +static GLfloat EyeDist = 5.0; +static GLfloat Rot = 0.0; +const GLenum Target = GL_TEXTURE_2D; + + +static void +CheckError(int line) +{ + GLenum err = glGetError(); + if (err) { + printf("GL Error %d at line %d\n", (int) err, line); + } +} + + +static const char * +LookupFormat(GLenum format) +{ + switch (format) { + case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: + return "GL_COMPRESSED_RGB_S3TC_DXT1_EXT"; + case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: + return "GL_COMPRESSED_RGBA_S3TC_DXT1_EXT"; + case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: + return "GL_COMPRESSED_RGBA_S3TC_DXT3_EXT"; + default: + return "other"; + } +} + + +static void +TestSubTex(void) +{ + GLboolean all = 0*GL_TRUE; + GLubyte *buffer; + GLint size, fmt; + int i; + + glGetTexLevelParameteriv(Target, 0, + GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB, &size); + glGetTexLevelParameteriv(Target, 0, GL_TEXTURE_INTERNAL_FORMAT, &fmt); + + buffer = (GLubyte *) malloc(size); + glGetCompressedTexImageARB(Target, 0, buffer); + + printf("Testing sub-texture replacement\n"); + if (all) + glCompressedTexImage2DARB(Target, 0, + fmt, ImgWidth, ImgHeight, 0, + size, buffer); + else { + /* bottom half */ + glCompressedTexSubImage2DARB(Target, 0, + 0, 0, /* pos */ + ImgWidth, ImgHeight / 2, + fmt, size/2, buffer); + /* top half */ + glCompressedTexSubImage2DARB(Target, 0, + 0, ImgHeight / 2, /* pos */ + ImgWidth, ImgHeight / 2, + fmt, size/2, buffer + size / 2); + } + + free(buffer); +} + + +static void +LoadCompressedImage(const char *file) +{ + const GLenum filter = GL_LINEAR; + GLubyte *image; + GLint p; + + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + glPixelStorei(GL_PACK_ALIGNMENT, 1); + + /* + * Load image and scale if needed. + */ + image = LoadRGBImage( file, &ImgWidth, &ImgHeight, &ImgFormat ); + if (!image) { + printf("Couldn't read %s\n", IMAGE_FILE); + exit(0); + } + printf("Image is %d x %d\n", ImgWidth, ImgHeight); + + /* power of two */ + assert(ImgWidth == 128 || ImgWidth == 256 || ImgWidth == 512); + assert(ImgWidth == 128 || ImgHeight == 256 || ImgHeight == 512); + + if (ImgFormat == GL_RGB) + CompFormat = GL_COMPRESSED_RGB_S3TC_DXT1_EXT; + else + CompFormat = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT; + + if (ImgFormat == GL_RGBA) { + int i, numAlpha = 0; + for (i = 0; i < ImgWidth * ImgHeight; i++) { + if (image[i*4+3] != 0 && image[i*4+3] != 0xff) { + numAlpha++; + } + if (image[i*4+3] == 0) + image[i*4+3] = 4 * i / ImgWidth; + } + printf("Num Alpha !=0,255: %d\n", numAlpha); + } + + CompFormat = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; + + + /* + * Give image to OpenGL and have it compress it. + */ + glTexImage2D(Target, 0, CompFormat, ImgWidth, ImgHeight, 0, + ImgFormat, GL_UNSIGNED_BYTE, image); + CheckError(__LINE__); + + free(image); + + glGetTexLevelParameteriv(Target, 0, GL_TEXTURE_INTERNAL_FORMAT, &p); + printf("Compressed Internal Format: %s (0x%x)\n", LookupFormat(p), p); + assert(p == CompFormat); + + printf("Original size: %d bytes\n", ImgWidth * ImgHeight * 3); + glGetTexLevelParameteriv(Target, 0, GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB, &p); + printf("Compressed size: %d bytes\n", p); + + glTexParameteri(Target, GL_TEXTURE_MIN_FILTER, filter); + glTexParameteri(Target, GL_TEXTURE_MAG_FILTER, filter); + + TestSubTex(); + +} + + +static void +Init(const char *file) +{ + GLint numFormats, formats[100]; + GLint p; + + if (!glutExtensionSupported("GL_ARB_texture_compression")) { + printf("Sorry, GL_ARB_texture_compression is required.\n"); + exit(1); + } + if (!glutExtensionSupported("GL_EXT_texture_compression_s3tc")) { + printf("Sorry, GL_EXT_texture_compression_s3tc is required.\n"); + exit(1); + } + + printf("GL_VERSION = %s\n", (char *) glGetString(GL_VERSION)); + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + glGetIntegerv(GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB, &numFormats); + glGetIntegerv(GL_COMPRESSED_TEXTURE_FORMATS_ARB, formats); + printf("%d supported compression formats: ", numFormats); + for (p = 0; p < numFormats; p++) + printf("0x%x ", formats[p]); + printf("\n"); + + LoadCompressedImage(file); + + glEnable(GL_TEXTURE_2D); + + if (ImgFormat == GL_RGBA) { + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_BLEND); + } +} + + +static void +Reshape( int width, int height ) +{ + glViewport( 0, 0, width, height ); + glMatrixMode( GL_PROJECTION ); + glLoadIdentity(); + glFrustum(-1, 1, -1, 1, 4, 100); + glMatrixMode( GL_MODELVIEW ); + glLoadIdentity(); +} + + +static void +Key( unsigned char key, int x, int y ) +{ + (void) x; + (void) y; + switch (key) { + case 'd': + EyeDist -= 1.0; + if (EyeDist < 4.0) + EyeDist = 4.0; + break; + case 'D': + EyeDist += 1.0; + break; + case 'z': + Rot += 5.0; + break; + case 'Z': + Rot -= 5.0; + break; + case 27: + exit(0); + break; + } + glutPostRedisplay(); +} + + +static void +Draw( void ) +{ + glClearColor(0.3, 0.3, .8, 0); + glClear(GL_COLOR_BUFFER_BIT); + + glPushMatrix(); + glTranslatef(0, 0, -(EyeDist+0.01)); + glRotatef(Rot, 0, 0, 1); + glBegin(GL_POLYGON); + glTexCoord2f(0, 0); glVertex2f(-1, -1); + glTexCoord2f(1, 0); glVertex2f( 1, -1); + glTexCoord2f(1, 1); glVertex2f( 1, 1); + glTexCoord2f(0, 1); glVertex2f(-1, 1); + glEnd(); + glPopMatrix(); + + glutSwapBuffers(); +} + + +int +main( int argc, char *argv[] ) +{ + glutInit( &argc, argv ); + glutInitWindowSize( 600, 600 ); + + glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE); + + glutCreateWindow(argv[0]); + + glutReshapeFunc( Reshape ); + glutKeyboardFunc( Key ); + glutDisplayFunc( Draw ); + + if (argc > 1) + Init(argv[1]); + else + Init(IMAGE_FILE); + + glutMainLoop(); + return 0; +} diff --git a/progs/tests/texfilt.c b/progs/tests/texfilt.c new file mode 100644 index 00000000000..6ee4bc4eae3 --- /dev/null +++ b/progs/tests/texfilt.c @@ -0,0 +1,398 @@ +/* + * (C) Copyright IBM Corporation 2005 + * 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 + * on the rights to use, copy, modify, merge, publish, distribute, sub + * license, 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 (including the next + * paragraph) 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 NON-INFRINGEMENT. IN NO EVENT SHALL + * IBM AND/OR THEIR SUPPLIERS 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 +#include +#include +#include +#include + +const GLenum filter_modes[] = { + GL_NEAREST, + GL_LINEAR, + GL_NEAREST_MIPMAP_NEAREST, + GL_NEAREST_MIPMAP_LINEAR, + GL_LINEAR_MIPMAP_NEAREST, + GL_LINEAR_MIPMAP_LINEAR, +}; + +static GLenum min_filter = GL_LINEAR_MIPMAP_LINEAR; +static GLenum mag_filter = GL_LINEAR; + +static unsigned segments = 64; +static GLfloat * position_data = NULL; +static GLfloat * texcoord_data = NULL; +static GLfloat max_anisotropy = 0.0; +static GLfloat anisotropy = 1.0; + +static void generate_tunnel( unsigned num_segs, GLfloat ** pos_data, + GLfloat ** tex_data ); +static void generate_textures( unsigned mode ); + +#define min(a,b) ( (a) < (b) ) ? (a) : (b) +#define max(a,b) ( (a) > (b) ) ? (a) : (b) + + +static void Display( void ) +{ + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, min_filter ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, mag_filter ); + + if ( max_anisotropy > 0.0 ) { + glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, + anisotropy ); + } + + glClear( GL_COLOR_BUFFER_BIT ); + glLoadIdentity(); + glTranslatef( 0.0f, 0.0f, -19.0f ); + + glVertexPointer( 4, GL_FLOAT, 0, position_data ); + glTexCoordPointer( 2, GL_FLOAT, 0, texcoord_data ); + glEnableClientState( GL_VERTEX_ARRAY ); + glEnableClientState( GL_TEXTURE_COORD_ARRAY ); + glDrawArrays( GL_QUADS, 0, 4 * segments ); + glutSwapBuffers(); +} + + +static void Reshape( int width, int height ) +{ + glViewport(0, 0, width, height); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluPerspective(45.0f, (GLfloat)(width)/(GLfloat)(height), 0.1f, 100.0f); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); +} + + +static void Key( unsigned char key, int x, int y ) +{ + GLfloat new_anisotropy = anisotropy; + + (void) x; + (void) y; + + + switch( key ) { + case 'a': { + new_anisotropy = anisotropy - 1.0; + break; + } + + case 'A': { + new_anisotropy = anisotropy + 1.0; + break; + } + + case 's': { + segments--; + if ( segments < 3 ) { + segments = 3; + } + generate_tunnel( segments, & position_data, & texcoord_data ); + break; + } + + case 'S': { + segments++; + if ( segments > 128 ) { + segments = 128; + } + generate_tunnel( segments, & position_data, & texcoord_data ); + break; + } + case 'q': + case 'Q': + case 27: + exit(0); + break; + } + + new_anisotropy = max( new_anisotropy, 1.0 ); + new_anisotropy = min( new_anisotropy, max_anisotropy ); + if ( new_anisotropy != anisotropy ) { + anisotropy = new_anisotropy; + printf( "Texture anisotropy: %f%s\n", anisotropy, + (anisotropy == 1.0) ? " (disabled)" : "" ); + } + + glutPostRedisplay(); +} + + +static void SpecialKey( int key, int x, int y ) +{ + (void) x; + (void) y; + (void) key; + glutPostRedisplay(); +} + + +static void menu_handler( int selection ) +{ + switch( selection >> 3 ) { + case 0: + glBindTexture( GL_TEXTURE_2D, selection ); + break; + + case 1: + min_filter = filter_modes[ selection & 7 ]; + break; + + case 2: + mag_filter = filter_modes[ selection & 7 ]; + break; + } + + glutPostRedisplay(); +} + + +static void Init( void ) +{ + glDisable(GL_CULL_FACE); + glEnable(GL_TEXTURE_2D); + glClearColor(0.0f, 0.0f, 0.4f, 0.0f); + glShadeModel(GL_SMOOTH); + glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); + + generate_tunnel( segments, & position_data, & texcoord_data ); + + glBindTexture( GL_TEXTURE_2D, 1 ); + generate_textures(1); + + glBindTexture( GL_TEXTURE_2D, 2 ); + generate_textures(2); + + glBindTexture( GL_TEXTURE_2D, 3 ); + generate_textures(3); + + if ( glutExtensionSupported( "GL_EXT_texture_filter_anisotropic" ) ) { + glGetFloatv( GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, & max_anisotropy ); + } + + printf("Maximum texture anisotropy: %f\n", max_anisotropy ); + + /* Create the menus. */ + + glutCreateMenu( menu_handler ); + glutAddMenuEntry( "Min filter: GL_NEAREST", 8 + 0 ); + glutAddMenuEntry( "Min filter: GL_LINEAR", 8 + 1 ); + glutAddMenuEntry( "Min filter: GL_NEAREST_MIMMAP_NEAREST", 8 + 2 ); + glutAddMenuEntry( "Min filter: GL_NEAREST_MIMMAP_LINEAR", 8 + 3 ); + glutAddMenuEntry( "Min filter: GL_LINEAR_MIMMAP_NEAREST", 8 + 4 ); + glutAddMenuEntry( "Min filter: GL_LINEAR_MIMMAP_LINEAR", 8 + 5 ); + glutAddMenuEntry( "Mag filter: GL_NEAREST", 16 + 0 ); + glutAddMenuEntry( "Mag filter: GL_LINEAR", 16 + 1 ); + glutAddMenuEntry( "Texture: regular mipmaps", 1 ); + glutAddMenuEntry( "Texture: blended mipmaps", 2 ); + glutAddMenuEntry( "Texture: color mipmaps", 3 ); + glutAttachMenu( GLUT_RIGHT_BUTTON ); +} + + +static void generate_tunnel( unsigned num_segs, GLfloat ** pos_data, + GLfloat ** tex_data ) +{ + const GLfloat far = 20.0f; + const GLfloat near = -90.0f; + const GLfloat far_tex = 30.0f; + const GLfloat near_tex = 0.0f; + const GLfloat angle_step = (2 * M_PI) / num_segs; + const GLfloat tex_coord_step = 2.0 / num_segs; + GLfloat angle = 0.0f; + GLfloat tex_coord = 0.0f; + unsigned i; + GLfloat * position; + GLfloat * texture; + + + position = realloc( *pos_data, sizeof( GLfloat ) * num_segs * 4 * 4 ); + texture = realloc( *tex_data, sizeof( GLfloat ) * num_segs * 4 * 2 ); + + *pos_data = position; + *tex_data = texture; + + for ( i = 0 ; i < num_segs ; i++ ) { + position[0] = 2.5 * sinf( angle ); + position[1] = 2.5 * cosf( angle ); + position[2] = (i & 1) ? far : near; + position[3] = 1.0f; + + position[4] = position[0]; + position[5] = position[1]; + position[6] = (i & 1) ? near : far; + position[7] = 1.0f; + + position += 8; + + texture[0] = tex_coord; + texture[1] = (i & 1) ? far_tex : near_tex; + texture += 2; + + texture[0] = tex_coord; + texture[1] = (i & 1) ? near_tex : far_tex; + texture += 2; + + angle += angle_step; + tex_coord += tex_coord_step; + + position[0] = 2.5 * sinf( angle ); + position[1] = 2.5 * cosf( angle ); + position[2] = (i & 1) ? near : far; + position[3] = 1.0f; + + position[4] = position[0]; + position[5] = position[1]; + position[6] = (i & 1) ? far : near; + position[7] = 1.0f; + + position += 8; + + texture[0] = tex_coord; + texture[1] = (i & 1) ? near_tex : far_tex; + texture += 2; + + texture[0] = tex_coord; + texture[1] = (i & 1) ? far_tex : near_tex; + texture += 2; + } +} + + +static void generate_textures( unsigned mode ) +{ +#define LEVEL_COLORS 6 + const GLfloat colors[LEVEL_COLORS][3] = { + { 1.0, 0.0, 0.0 }, /* 32 x 32 */ + { 0.0, 1.0, 0.0 }, /* 16 x 16 */ + { 0.0, 0.0, 1.0 }, /* 8 x 8 */ + { 1.0, 0.0, 1.0 }, /* 4 x 4 */ + { 1.0, 1.0, 1.0 }, /* 2 x 2 */ + { 1.0, 1.0, 0.0 } /* 1 x 1 */ + }; + const unsigned checkers_per_level = 2; + GLfloat * tex; + unsigned level; + unsigned size; + GLint max_size; + + + glGetIntegerv( GL_MAX_TEXTURE_SIZE, & max_size ); + if ( max_size > 512 ) { + max_size = 512; + } + + tex = malloc( sizeof( GLfloat ) * 3 * max_size * max_size ); + + level = 0; + for ( size = max_size ; size > 0 ; size >>= 1 ) { + unsigned divisor = size / checkers_per_level; + unsigned i; + unsigned j; + GLfloat checkers[2][3]; + + + if ((level == 0) || (mode == 1)) { + checkers[0][0] = 1.0; + checkers[0][1] = 1.0; + checkers[0][2] = 1.0; + checkers[1][0] = 0.0; + checkers[1][1] = 0.0; + checkers[1][2] = 0.0; + } + else if (mode == 2) { + checkers[0][0] = colors[level % LEVEL_COLORS][0]; + checkers[0][1] = colors[level % LEVEL_COLORS][1]; + checkers[0][2] = colors[level % LEVEL_COLORS][2]; + checkers[1][0] = colors[level % LEVEL_COLORS][0] * 0.5; + checkers[1][1] = colors[level % LEVEL_COLORS][1] * 0.5; + checkers[1][2] = colors[level % LEVEL_COLORS][2] * 0.5; + } + else { + checkers[0][0] = colors[level % LEVEL_COLORS][0]; + checkers[0][1] = colors[level % LEVEL_COLORS][1]; + checkers[0][2] = colors[level % LEVEL_COLORS][2]; + checkers[1][0] = colors[level % LEVEL_COLORS][0]; + checkers[1][1] = colors[level % LEVEL_COLORS][1]; + checkers[1][2] = colors[level % LEVEL_COLORS][2]; + } + + if ( divisor == 0 ) { + divisor = 1; + + checkers[0][0] = (checkers[0][0] + checkers[1][0]) / 2; + checkers[0][1] = (checkers[0][0] + checkers[1][0]) / 2; + checkers[0][2] = (checkers[0][0] + checkers[1][0]) / 2; + checkers[1][0] = checkers[0][0]; + checkers[1][1] = checkers[0][1]; + checkers[1][2] = checkers[0][2]; + } + + + for ( i = 0 ; i < size ; i++ ) { + for ( j = 0 ; j < size ; j++ ) { + const unsigned idx = ((i ^ j) / divisor) & 1; + + tex[ ((i * size) + j) * 3 + 0] = checkers[ idx ][0]; + tex[ ((i * size) + j) * 3 + 1] = checkers[ idx ][1]; + tex[ ((i * size) + j) * 3 + 2] = checkers[ idx ][2]; + } + } + + glTexImage2D( GL_TEXTURE_2D, level, GL_RGB, size, size, 0, + GL_RGB, GL_FLOAT, tex ); + level++; + } + + free( tex ); +} + + +int main( int argc, char ** argv ) +{ + glutInit( &argc, argv ); + glutInitWindowPosition( 0, 0 ); + glutInitWindowSize( 800, 600 ); + glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE ); + glutCreateWindow( "Texture Filter Test" ); + glutReshapeFunc( Reshape ); + glutKeyboardFunc( Key ); + glutSpecialFunc( SpecialKey ); + glutDisplayFunc( Display ); + + Init(); + + printf("\nUse the right-button menu to select the texture and filter mode.\n"); + printf("Use 'A' and 'a' to increase and decrease the aniotropy.\n"); + printf("Use 'S' and 's' to increase and decrease the number of cylinder segments.\n"); + printf("Use 'q' to exit.\n\n"); + + glutMainLoop(); + return 0; +} diff --git a/progs/tests/texgenmix.c b/progs/tests/texgenmix.c new file mode 100644 index 00000000000..be8f6775c70 --- /dev/null +++ b/progs/tests/texgenmix.c @@ -0,0 +1,640 @@ + +/* + * Demonstrates mixed texgen/non-texgen texture coordinates. + */ + +#include +#include +#include +#include + +#undef max +#undef min +#define max( a, b ) ((a) >= (b) ? (a) : (b)) +#define min( a, b ) ((a) <= (b) ? (a) : (b)) + +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; + +GLboolean doubleBuffered = GL_TRUE; +GLboolean drawTextured = GL_TRUE; + +int textureWidth = 64; +int textureHeight = 64; + +int winWidth = 580, winHeight = 720; + +const GLfloat texmat_swap_rq[16] = { 1.0, 0.0, 0.0, 0.0, + 0.0, 1.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 1.0, + 0.0, 0.0, 1.0, 0.0}; + +const GLfloat nullPlane[4] = { 0.0, 0.0, 0.0, 0.0 }; +const GLfloat ObjPlaneS1[4] = { 1.0, 0.0, 1.0, 0.0 }; +const GLfloat ObjPlaneS2[4] = { 0.5, 0.0, 0.0, 0.0 }; +const GLfloat ObjPlaneS3[4] = { 1.0, 0.0, 0.0, 0.0 }; +const GLfloat ObjPlaneT[4] = { 0.0, 1.0, 0.0, 0.0 }; +const GLfloat ObjPlaneT2[4] = { 0.0, 0.5, 0.0, 0.0 }; +const GLfloat ObjPlaneT3[4] = { 0.0, 1.0, 0.0, 0.0 }; +const GLfloat ObjPlaneR[4] = { 0.0, 0.0, 1.0, 0.0 }; +const GLfloat ObjPlaneQ[4] = { 0.0, 0.0, 0.0, 0.5 }; + + +static void checkErrors( void ) +{ + GLenum error; + + while ( (error = glGetError()) != GL_NO_ERROR ) { + fprintf( stderr, "Error: %s\n", (char *) gluErrorString( error ) ); + } +} + +static void drawString( const char *string, GLfloat x, GLfloat y, + const GLfloat color[4] ) +{ + glColor4fv( color ); + glRasterPos2f( x, y ); + + while ( *string ) { + glutBitmapCharacter( GLUT_BITMAP_TIMES_ROMAN_10, *string ); + string++; + } +} + +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 't': + drawTextured = !drawTextured; + 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: + break; + case GLUT_KEY_UP: + break; + case GLUT_KEY_LEFT: + break; + case GLUT_KEY_RIGHT: + 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 ) +{ + int alphaSize = 1; + int rgbSize = 3; + GLubyte *texImage, *p; + int elementsPerGroup, elementSize, groupSize, rowSize; + int i, j; + + + elementsPerGroup = 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 ( 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, + GL_RGBA, width, height, 0, + GL_RGBA, GL_UNSIGNED_BYTE, texImage ); + + free( texImage ); +} + + +static void drawSample( int x, int y, int w, int h, + int texgenenabled, int coordnr ) +{ + char buf[255]; + + 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 ); + if (texgenenabled == 2) { + sprintf( buf, "TexCoord%df", coordnr); + drawString( buf, 10, h - 15, labelInfoColor ); + sprintf( buf, "texgen enabled for %s coordinate(s)", coordnr == 2 ? "S" : "S/T"); + drawString( buf, 10, 5, labelInfoColor ); + } + else if (texgenenabled == 0) { + sprintf( buf, "TexCoord%df", coordnr); + drawString( buf, 10, h - 15, labelInfoColor ); + drawString( "no texgen", 10, 5, labelInfoColor ); + } + else if (texgenenabled == 1) { + drawString( "no TexCoord", 10, h - 15, labelInfoColor ); + sprintf( buf, "texgen enabled for %s coordinate(s)", + coordnr == 2 ? "S/T" : (coordnr == 3 ? "S/T/R" : "S/T/R/Q")); + drawString( buf, 10, 5, labelInfoColor ); + } + + end2D(); + + glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE ); + + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST ); + + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP ); + + loadTexture( textureWidth, textureHeight ); + + if ( drawTextured ) { + glEnable( GL_TEXTURE_2D ); + } + + glDisable( GL_TEXTURE_GEN_S ); + glDisable( GL_TEXTURE_GEN_T ); + glDisable( GL_TEXTURE_GEN_R ); + glDisable( GL_TEXTURE_GEN_Q ); + + glMatrixMode( GL_TEXTURE ); + glLoadIdentity(); + glMatrixMode( GL_MODELVIEW ); + glPushMatrix(); + + switch (coordnr) { + case 2: + switch (texgenenabled) { + case 0: + glBegin( GL_QUADS ); + glTexCoord2f( 0.0, 0.0 ); + glVertex2f( -0.8, -0.8 ); + + glTexCoord2f( 1.0, 0.0 ); + glVertex2f( 0.8, -0.8 ); + + glTexCoord2f( 1.0, 1.0 ); + glVertex2f( 0.8, 0.8 ); + + glTexCoord2f( 0.0, 1.0 ); + glVertex2f( -0.8, 0.8 ); + glEnd(); + break; + case 1: + glTranslatef( -0.8, -0.8, 0.0 ); + glScalef( 1.6, 1.6, 1.0 ); + glTexGeni( GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR ); + glTexGeni( GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR ); + glTexGeni( GL_R, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR ); + glTexGeni( GL_Q, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR ); + glTexGenfv(GL_S, GL_OBJECT_PLANE, ObjPlaneS3); + glTexGenfv(GL_T, GL_OBJECT_PLANE, ObjPlaneT3); + glTexGenfv(GL_R, GL_OBJECT_PLANE, nullPlane); + glTexGenfv(GL_Q, GL_OBJECT_PLANE, nullPlane); + + glEnable( GL_TEXTURE_GEN_S ); + glEnable( GL_TEXTURE_GEN_T ); + + /* Issue a texcoord here to be sure Q isn't left over from a + * previous sample. + */ + glTexCoord1f( 0.0 ); + glBegin( GL_QUADS ); + glVertex2f( 0.0, 0.0 ); + glVertex2f( 1.0, 0.0 ); + glVertex2f( 1.0, 1.0 ); + glVertex2f( 0.0, 1.0 ); + glEnd(); + break; + case 2: + /* make sure that texgen T and non-texgen S coordinate are wrong */ + glTexGeni( GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR ); + glTexGeni( GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR ); + glTexGeni( GL_R, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR ); + glTexGeni( GL_Q, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR ); + glTexGenfv(GL_S, GL_OBJECT_PLANE, ObjPlaneS1); + glTexGenfv(GL_T, GL_OBJECT_PLANE, nullPlane); + glTexGenfv(GL_R, GL_OBJECT_PLANE, nullPlane); + glTexGenfv(GL_Q, GL_OBJECT_PLANE, nullPlane); + + glEnable( GL_TEXTURE_GEN_S ); + + glBegin( GL_QUADS ); + /* use z coordinate to get correct texgen values... */ + glTexCoord2f( 0.0, 0.0 ); + glVertex3f( -0.8, -0.8, 0.8 ); + + glTexCoord2f( 0.0, 0.0 ); + glVertex3f( 0.8, -0.8, 0.2 ); + + glTexCoord2f( 0.0, 1.0 ); + glVertex3f( 0.8, 0.8, 0.2 ); + + glTexCoord2f( 0.0, 1.0 ); + glVertex3f( -0.8, 0.8, 0.8 ); + glEnd(); + break; + } + break; + case 3: + glMatrixMode( GL_TEXTURE ); + glLoadMatrixf( texmat_swap_rq ); + glMatrixMode( GL_MODELVIEW ); + glTranslatef( -0.8, -0.8, 0.0 ); + glScalef( 1.6, 1.6, 1.0 ); + switch (texgenenabled) { + case 0: + glBegin( GL_QUADS ); + glTexCoord3f( 0.0, 0.0, 0.5 ); + glVertex2f( 0.0, 0.0 ); + + glTexCoord3f( 0.5, 0.0, 0.5 ); + glVertex2f( 1.0, 0.0 ); + + glTexCoord3f( 0.5, 0.5, 0.5 ); + glVertex2f( 1.0, 1.0 ); + + glTexCoord3f( 0.0, 0.5, 0.5 ); + glVertex2f( 0.0, 1.0 ); + glEnd(); + break; + case 1: + glTexGeni( GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR ); + glTexGeni( GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR ); + glTexGeni( GL_R, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR ); + glTexGeni( GL_Q, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR ); + glTexGenfv(GL_S, GL_OBJECT_PLANE, ObjPlaneS2); + glTexGenfv(GL_T, GL_OBJECT_PLANE, ObjPlaneT2); + glTexGenfv(GL_R, GL_OBJECT_PLANE, ObjPlaneR); + glTexGenfv(GL_Q, GL_OBJECT_PLANE, nullPlane); + + glEnable( GL_TEXTURE_GEN_S ); + glEnable( GL_TEXTURE_GEN_T ); + glEnable( GL_TEXTURE_GEN_R ); + + glTexCoord1f( 0.0 ); /* to make sure Q is 1.0 */ + glBegin( GL_QUADS ); + glVertex3f( 0.0, 0.0, 0.5 ); + glVertex3f( 1.0, 0.0, 0.5 ); + glVertex3f( 1.0, 1.0, 0.5 ); + glVertex3f( 0.0, 1.0, 0.5 ); + glEnd(); + break; + case 2: + /* make sure that texgen R/Q and non-texgen S/T coordinates are wrong */ + glTexGeni( GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR ); + glTexGeni( GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR ); + glTexGeni( GL_R, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR ); + glTexGeni( GL_Q, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR ); + glTexGenfv(GL_S, GL_OBJECT_PLANE, ObjPlaneS2); + glTexGenfv(GL_T, GL_OBJECT_PLANE, ObjPlaneT2); + glTexGenfv(GL_R, GL_OBJECT_PLANE, nullPlane); + glTexGenfv(GL_Q, GL_OBJECT_PLANE, nullPlane); + + glEnable( GL_TEXTURE_GEN_S ); + glEnable( GL_TEXTURE_GEN_T ); + + glBegin( GL_QUADS ); + glTexCoord3f( 0.0, 0.0, 0.5 ); + glVertex2f( 0.0, 0.0); + + glTexCoord3f( 0.0, 0.0, 0.5 ); + glVertex2f( 1.0, 0.0); + + glTexCoord3f( 0.0, 0.0, 0.5 ); + glVertex2f( 1.0, 1.0); + + glTexCoord3f( 0.0, 0.0, 0.5 ); + glVertex2f( 0.0, 1.0); + glEnd(); + break; + } + break; + case 4: + switch (texgenenabled) { + case 0: + glBegin( GL_QUADS ); + /* don't need r coordinate but still setting it I'm mean */ + glTexCoord4f( 0.0, 0.0, 0.0, 0.5 ); + glVertex2f( -0.8, -0.8 ); + + glTexCoord4f( 0.5, 0.0, 0.2, 0.5 ); + glVertex2f( 0.8, -0.8 ); + + glTexCoord4f( 0.5, 0.5, 0.5, 0.5 ); + glVertex2f( 0.8, 0.8 ); + + glTexCoord4f( 0.0, 0.5, 0.5, 0.5 ); + glVertex2f( -0.8, 0.8 ); + glEnd(); + break; + case 1: + glTranslatef( -0.8, -0.8, 0.0 ); + glScalef( 1.6, 1.6, 1.0 ); + /* make sure that texgen R/Q and non-texgen S/T coordinates are wrong */ + glTexGeni( GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR ); + glTexGeni( GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR ); + glTexGeni( GL_R, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR ); + glTexGeni( GL_Q, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR ); + glTexGenfv(GL_S, GL_OBJECT_PLANE, ObjPlaneS2); + glTexGenfv(GL_T, GL_OBJECT_PLANE, ObjPlaneT2); + glTexGenfv(GL_R, GL_OBJECT_PLANE, ObjPlaneR); + glTexGenfv(GL_Q, GL_OBJECT_PLANE, ObjPlaneQ); + + glEnable( GL_TEXTURE_GEN_S ); + glEnable( GL_TEXTURE_GEN_T ); + glEnable( GL_TEXTURE_GEN_R ); + glEnable( GL_TEXTURE_GEN_Q ); + + glBegin( GL_QUADS ); + glVertex2f( 0.0, 0.0 ); + glVertex2f( 1.0, 0.0 ); + glVertex2f( 1.0, 1.0 ); + glVertex2f( 0.0, 1.0 ); + glEnd(); + break; + case 2: + glTranslatef( -0.8, -0.8, 0.0 ); + glScalef( 1.6, 1.6, 1.0 ); + /* make sure that texgen R/Q and non-texgen S/T coordinates are wrong */ + glTexGeni( GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR ); + glTexGeni( GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR ); + glTexGeni( GL_R, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR ); + glTexGeni( GL_Q, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR ); + glTexGenfv(GL_S, GL_OBJECT_PLANE, ObjPlaneS2); + glTexGenfv(GL_T, GL_OBJECT_PLANE, ObjPlaneT2); + glTexGenfv(GL_R, GL_OBJECT_PLANE, nullPlane); + glTexGenfv(GL_Q, GL_OBJECT_PLANE, nullPlane); + + glEnable( GL_TEXTURE_GEN_S ); + glEnable( GL_TEXTURE_GEN_T ); + + glBegin( GL_QUADS ); + glTexCoord4f( 0.0, 0.0, 0.0, 0.5 ); + glVertex2f( 0.0, 0.0 ); + + glTexCoord4f( 0.0, 0.0, 0.2, 0.5 ); + glVertex2f( 1.0, 0.0 ); + + glTexCoord4f( 0.0, 0.0, 0.5, 0.5 ); + glVertex2f( 1.0, 1.0 ); + + glTexCoord4f( 0.0, 0.0, 0.75, 0.5 ); + glVertex2f( 0.0, 1.0 ); + glEnd(); + break; + } + break; + } + + glPopMatrix(); + glDisable( GL_TEXTURE_2D ); + +} + +static void display( void ) +{ + int numX = 3, numY = 3; + 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 < numY ; i++ ) + { + + labelInfoColor = labelColor1; + + + for ( j = 0 ; j < numX ; j++ ) { + drawSample( x, y, xSize, ySize, i, j+2 ); + 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, "texgenmix - mixed texgen/non-texgen texture coordinate test\n" ); + fprintf( stderr, "all quads should look the same!\n" ); + fprintf( stderr, "\n" ); + fprintf( stderr, " [t] - toggle texturing\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 ); + glutInitWindowPosition( 0, 0 ); + glutCreateWindow( "Mixed texgen/non-texgen texture coordinate 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 ) ); + } + + glutDisplayFunc( display ); + glutReshapeFunc( reshape ); + glutKeyboardFunc( keyboard ); + glutSpecialFunc( special ); + glutMainLoop(); + + return 0; +} diff --git a/progs/tests/texline.c b/progs/tests/texline.c new file mode 100644 index 00000000000..bf09b87284d --- /dev/null +++ b/progs/tests/texline.c @@ -0,0 +1,269 @@ +/* $Id: texline.c,v 1.5 2004-01-28 10:07:48 keithw Exp $ */ + +/* + * Test textured lines. + * + * Brian Paul + * September 2000 + */ + + +#include +#include +#include +#include +#include "../util/readtex.c" /* I know, this is a hack. */ + +#define TEXTURE_FILE "../images/girl.rgb" + +static GLboolean Antialias = GL_FALSE; +static GLboolean Animate = GL_FALSE; +static GLint Texture = 1; +static GLboolean Stipple = GL_FALSE; +static GLfloat LineWidth = 1.0; + +static GLfloat Xrot = -60.0, Yrot = 0.0, Zrot = 0.0; +static GLfloat DYrot = 1.0; +static GLboolean Points = GL_FALSE; +static GLfloat Scale = 1.0; + +static void Idle( void ) +{ + if (Animate) { + Zrot += DYrot; + glutPostRedisplay(); + } +} + + +static void Display( void ) +{ + GLfloat x, y, s, t; + + glClear( GL_COLOR_BUFFER_BIT ); + + glPushMatrix(); + glRotatef(Xrot, 1.0, 0.0, 0.0); + glRotatef(Yrot, 0.0, 1.0, 0.0); + glRotatef(Zrot, 0.0, 0.0, 1.0); + glScalef(Scale, Scale, Scale); + + if (Texture) + glColor3f(1, 1, 1); + + if (Points) { + glBegin(GL_POINTS); + for (t = 0.0; t <= 1.0; t += 0.025) { + for (s = 0.0; s <= 1.0; s += 0.025) { + x = s * 2.0 - 1.0; + y = t * 2.0 - 1.0; + if (!Texture) + glColor3f(1, 0, 1); + glMultiTexCoord2fARB(GL_TEXTURE1_ARB, t, s); + glTexCoord2f(s, t); + glVertex2f(x, y); + } + } + glEnd(); + } + else { + glBegin(GL_LINES); + for (t = 0.0; t <= 1.0; t += 0.025) { + x = t * 2.0 - 1.0; + if (!Texture) + glColor3f(1, 0, 1); + glTexCoord2f(t, 0.0); + glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.0, t); + glVertex2f(x, -1.0); + if (!Texture) + glColor3f(0, 1, 0); + glTexCoord2f(t, 1.0); + glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 1.0, t); + glVertex2f(x, 1.0); + } + glEnd(); + } + + glPopMatrix(); + + glutSwapBuffers(); +} + + +static void Reshape( int width, int height ) +{ + GLfloat ar = (float) width / height; + glViewport( 0, 0, width, height ); + glMatrixMode( GL_PROJECTION ); + glLoadIdentity(); + glFrustum( -ar, ar, -1.0, 1.0, 10.0, 100.0 ); + glMatrixMode( GL_MODELVIEW ); + glLoadIdentity(); + glTranslatef( 0.0, 0.0, -12.0 ); +} + + +static void Key( unsigned char key, int x, int y ) +{ + (void) x; + (void) y; + switch (key) { + case 'a': + Antialias = !Antialias; + if (Antialias) { + glEnable(GL_LINE_SMOOTH); + glEnable(GL_POINT_SMOOTH); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + } + else { + glDisable(GL_LINE_SMOOTH); + glDisable(GL_POINT_SMOOTH); + glDisable(GL_BLEND); + } + break; + case 't': + Texture++; + if (Texture > 2) + Texture = 0; + if (Texture == 0) { + glActiveTextureARB(GL_TEXTURE0_ARB); + glDisable(GL_TEXTURE_2D); + glActiveTextureARB(GL_TEXTURE1_ARB); + glDisable(GL_TEXTURE_2D); + } + else if (Texture == 1) { + glActiveTextureARB(GL_TEXTURE0_ARB); + glEnable(GL_TEXTURE_2D); + glActiveTextureARB(GL_TEXTURE1_ARB); + glDisable(GL_TEXTURE_2D); + } + else { + glActiveTextureARB(GL_TEXTURE0_ARB); + glEnable(GL_TEXTURE_2D); + glActiveTextureARB(GL_TEXTURE1_ARB); + glEnable(GL_TEXTURE_2D); + } + break; + case 'w': + LineWidth -= 0.25; + if (LineWidth < 0.25) + LineWidth = 0.25; + glLineWidth(LineWidth); + glPointSize(LineWidth); + break; + case 'W': + LineWidth += 0.25; + if (LineWidth > 8.0) + LineWidth = 8.0; + glLineWidth(LineWidth); + glPointSize(LineWidth); + break; + case 'p': + Points = !Points; + break; + case 's': + Stipple = !Stipple; + if (Stipple) + glEnable(GL_LINE_STIPPLE); + else + glDisable(GL_LINE_STIPPLE); + break; + case ' ': + Animate = !Animate; + if (Animate) + glutIdleFunc(Idle); + else + glutIdleFunc(NULL); + break; + case 27: + exit(0); + break; + } + printf("LineWidth, PointSize = %f\n", LineWidth); + glutPostRedisplay(); +} + + +static void SpecialKey( int key, int x, int y ) +{ + float 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( int argc, char *argv[] ) +{ + GLuint u; + for (u = 0; u < 2; u++) { + glActiveTextureARB(GL_TEXTURE0_ARB + u); + glBindTexture(GL_TEXTURE_2D, 10+u); + if (u == 0) + glEnable(GL_TEXTURE_2D); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + + if (u == 0) + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); + else + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_ADD); + + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + if (!LoadRGBMipmaps(TEXTURE_FILE, GL_RGB)) { + printf("Error: couldn't load texture image\n"); + exit(1); + } + } + + glLineStipple(1, 0xff); + + 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)); + } +} + + +int main( int argc, char *argv[] ) +{ + glutInit( &argc, argv ); + glutInitWindowPosition(0, 0); + glutInitWindowSize( 400, 300 ); + + glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE ); + + glutCreateWindow(argv[0] ); + + Init(argc, argv); + + glutReshapeFunc( Reshape ); + glutKeyboardFunc( Key ); + glutSpecialFunc( SpecialKey ); + glutDisplayFunc( Display ); + if (Animate) + glutIdleFunc( Idle ); + + glutMainLoop(); + return 0; +} diff --git a/progs/tests/texobjshare.c b/progs/tests/texobjshare.c new file mode 100644 index 00000000000..2b31cb6c4d3 --- /dev/null +++ b/progs/tests/texobjshare.c @@ -0,0 +1,219 @@ +/* + * Create several OpenGL rendering contexts, sharing textures, display + * lists, etc. Exercise binding, deleting, etc. + * + * Brian Paul + * 21 December 2004 + */ + + +#include +#include +#include +#include +#include +#include +#include +#include + + +/* + * Each display/window/context: + */ +struct context { + char DisplayName[1000]; + Display *Dpy; + Window Win; + GLXContext Context; +}; + + +#define MAX_CONTEXTS 200 +static struct context Contexts[MAX_CONTEXTS]; +static int NumContexts = 0; + + +static void +Error(const char *display, const char *msg) +{ + fprintf(stderr, "Error on display %s - %s\n", display, msg); + exit(1); +} + + +static struct context * +CreateContext(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 (NumContexts >= MAX_CONTEXTS) + 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 = (NumContexts % 10) * 100; + ypos = (NumContexts / 10) * 100; + 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); + } + + if (NumContexts == 0) { + ctx = glXCreateContext(dpy, visinfo, NULL, True); + } + else { + /* share textures & dlists with 0th context */ + ctx = glXCreateContext(dpy, visinfo, Contexts[0].Context, True); + } + if (!ctx) { + Error(displayName, "Couldn't create GLX context"); + return NULL; + } + + XMapWindow(dpy, win); + + if (!glXMakeCurrent(dpy, win, ctx)) { + Error(displayName, "glXMakeCurrent failed"); + return NULL; + } + + if (NumContexts == 0) { + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + } + + /* save the info for this context */ + { + struct context *h = &Contexts[NumContexts]; + strcpy(h->DisplayName, name); + h->Dpy = dpy; + h->Win = win; + h->Context = ctx; + NumContexts++; + return &Contexts[NumContexts-1]; + } +} + + +static void +MakeCurrent(int i) +{ + if (!glXMakeCurrent(Contexts[i].Dpy, Contexts[i].Win, Contexts[i].Context)) { + fprintf(stderr, "glXMakeCurrent failed!\n"); + } +} + + + +static void +DestroyContext(int i) +{ + XDestroyWindow(Contexts[i].Dpy, Contexts[i].Win); + glXDestroyContext(Contexts[i].Dpy, Contexts[i].Context); + XCloseDisplay(Contexts[i].Dpy); +} + + +int +main(int argc, char *argv[]) +{ + char *dpyName = NULL; + int i; + GLuint t; + GLint tb; + + for (i = 0; i < 2; i++) { + CreateContext(dpyName, "context"); + } + + /* Create texture and bind it in context 0 */ + MakeCurrent(0); + glGenTextures(1, &t); + printf("Generated texture ID %u\n", t); + assert(!glIsTexture(t)); + glBindTexture(GL_TEXTURE_2D, t); + assert(glIsTexture(t)); + glGetIntegerv(GL_TEXTURE_BINDING_2D, &tb); + assert(tb == t); + + /* Bind texture in context 1 */ + MakeCurrent(1); + assert(glIsTexture(t)); + glBindTexture(GL_TEXTURE_2D, t); + glGetIntegerv(GL_TEXTURE_BINDING_2D, &tb); + assert(tb == t); + + /* Delete texture from context 0 */ + MakeCurrent(0); + glDeleteTextures(1, &t); + assert(!glIsTexture(t)); + glGetIntegerv(GL_TEXTURE_BINDING_2D, &tb); + printf("After delete, binding = %d\n", tb); + + /* Check texture state from context 1 */ + MakeCurrent(1); + assert(!glIsTexture(t)); + glGetIntegerv(GL_TEXTURE_BINDING_2D, &tb); + printf("In second context, binding = %d\n", tb); + glBindTexture(GL_TEXTURE_2D, 0); + glGetIntegerv(GL_TEXTURE_BINDING_2D, &tb); + assert(tb == 0); + + + for (i = 0; i < NumContexts; i++) { + DestroyContext(i); + } + + printf("Success!\n"); + + return 0; +} diff --git a/progs/tests/texrect.c b/progs/tests/texrect.c new file mode 100644 index 00000000000..3035224816f --- /dev/null +++ b/progs/tests/texrect.c @@ -0,0 +1,360 @@ +/* $Id: texrect.c,v 1.5 2004-05-06 20:27:32 brianp Exp $ */ + +/* GL_NV_texture_rectangle test + * + * Brian Paul + * 14 June 2002 + */ + + +#define GL_GLEXT_PROTOTYPES +#include +#include +#include +#include +#include +#include "readtex.h" + +#define TEXTURE_0_FILE "../images/girl.rgb" +#define TEXTURE_1_FILE "../images/reflect.rgb" + +#define TEX0 1 +#define TEX7 8 +#define ANIMATE 10 +#define CLAMP 20 +#define CLAMP_TO_EDGE 21 +#define CLAMP_TO_BORDER 22 +#define LINEAR_FILTER 30 +#define NEAREST_FILTER 31 +#define QUIT 100 + +static GLboolean Animate = GL_FALSE; +static GLint NumUnits = 2; +static GLboolean TexEnabled[8]; +static GLint Width[8], Height[8]; /* image sizes */ +static GLenum Format[8]; + +static GLfloat Xrot = 00.0, Yrot = 00.0, Zrot = 0.0; + + +static void Idle( void ) +{ + Zrot = glutGet(GLUT_ELAPSED_TIME) * 0.01; + glutPostRedisplay(); +} + + +static void DrawObject(void) +{ + GLint i; + GLfloat d = 10; /* so we can see how borders are handled */ + + glColor3f(.1, .1, .1); /* modulate this */ + + glPushMatrix(); + + glRotatef(Zrot, 0, 0, 1); + + glBegin(GL_QUADS); + + for (i = 0; i < NumUnits; i++) + glMultiTexCoord2fARB(GL_TEXTURE0_ARB + i, -d, -d); + glVertex2f(-1.0, -1.0); + + for (i = 0; i < NumUnits; i++) + glMultiTexCoord2fARB(GL_TEXTURE0_ARB + i, Width[i]+d, -d); + glVertex2f(1.0, -1.0); + + for (i = 0; i < NumUnits; i++) + glMultiTexCoord2fARB(GL_TEXTURE0_ARB + i, Width[i]+d, Height[i]+d); + glVertex2f(1.0, 1.0); + + for (i = 0; i < NumUnits; i++) + glMultiTexCoord2fARB(GL_TEXTURE0_ARB + i, -d, Height[i]+d); + glVertex2f(-1.0, 1.0); + + glEnd(); + glPopMatrix(); +} + + +static void Display( void ) +{ + glClear( GL_COLOR_BUFFER_BIT ); + + glPushMatrix(); + glRotatef(Xrot, 1.0, 0.0, 0.0); + glRotatef(Yrot, 0.0, 1.0, 0.0); + glRotatef(Zrot, 0.0, 0.0, 1.0); + glScalef(5.0, 5.0, 5.0); + DrawObject(); + glPopMatrix(); + + glutSwapBuffers(); +} + + +static void Reshape( int width, int height ) +{ + glViewport( 0, 0, width, height ); + glMatrixMode( GL_PROJECTION ); + glLoadIdentity(); + glFrustum( -1.0, 1.0, -1.0, 1.0, 5.0, 100.0 ); + glMatrixMode( GL_MODELVIEW ); + glLoadIdentity(); + glTranslatef( 0.0, 0.0, -35.0 ); +} + + +static void ModeMenu(int entry) +{ + GLint i; + if (entry >= TEX0 && entry < TEX0 + NumUnits) { + /* toggle */ + i = entry - TEX0; + TexEnabled[i] = !TexEnabled[i]; + glActiveTextureARB(GL_TEXTURE0_ARB + i); + if (TexEnabled[i]) { + glEnable(GL_TEXTURE_RECTANGLE_NV); + } + else { + glDisable(GL_TEXTURE_RECTANGLE_NV); + } + printf("Enabled: "); + for (i = 0; i < NumUnits; i++) + printf("%d ", (int) TexEnabled[i]); + printf("\n"); + } + else if (entry==ANIMATE) { + Animate = !Animate; + if (Animate) + glutIdleFunc(Idle); + else + glutIdleFunc(NULL); + } + else if (entry==CLAMP) { + for (i = 0; i < NumUnits; i++) { + glActiveTextureARB(GL_TEXTURE0_ARB + i); + glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_WRAP_S, GL_CLAMP); + glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_WRAP_T, GL_CLAMP); + } + } + else if (entry==CLAMP_TO_EDGE) { + for (i = 0; i < NumUnits; i++) { + glActiveTextureARB(GL_TEXTURE0_ARB + i); + glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + } + } + else if (entry==CLAMP_TO_BORDER) { + for (i = 0; i < NumUnits; i++) { + glActiveTextureARB(GL_TEXTURE0_ARB + i); + glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER); + glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER); + } + } + else if (entry==NEAREST_FILTER) { + for (i = 0; i < NumUnits; i++) { + glActiveTextureARB(GL_TEXTURE0_ARB + i); + glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + } + } + else if (entry==LINEAR_FILTER) { + for (i = 0; i < NumUnits; i++) { + glActiveTextureARB(GL_TEXTURE0_ARB + i); + glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + } + } + + else if (entry==QUIT) { + exit(0); + } + + glutPostRedisplay(); +} + + +static void Key( unsigned char key, int x, int y ) +{ + (void) x; + (void) y; + switch (key) { + case 'z': + Zrot -= 1.0; + break; + case 'Z': + Zrot += 1.0; + break; + case 'a': + Animate = !Animate; + if (Animate) + glutIdleFunc(Idle); + else + glutIdleFunc(NULL); + break; + case 27: + exit(0); + break; + } + glutPostRedisplay(); +} + + +static void SpecialKey( int key, int x, int y ) +{ + float 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( int argc, char *argv[] ) +{ + const GLenum wrap = GL_CLAMP; + GLuint texObj[8]; + GLint size, i; + + if (!glutExtensionSupported("GL_ARB_multitexture")) { + printf("Sorry, GL_ARB_multitexture needed by this program\n"); + exit(1); + } + + if (!glutExtensionSupported("GL_NV_texture_rectangle")) { + printf("Sorry, GL_NV_texture_rectangle needed by this program\n"); + exit(1); + } + + glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &NumUnits); + printf("%d texture units supported, using 2.\n", NumUnits); + if (NumUnits > 2) + NumUnits = 2; + + glGetIntegerv(GL_MAX_RECTANGLE_TEXTURE_SIZE_NV, &size); + printf("%d x %d max texture rectangle size\n", size, size); + + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + + for (i = 0; i < NumUnits; i++) { + TexEnabled[i] = GL_TRUE; + } + + /* allocate two texture objects */ + glGenTextures(NumUnits, texObj); + + /* setup the texture objects */ + for (i = 0; i < NumUnits; i++) { + + glActiveTextureARB(GL_TEXTURE0_ARB + i); + + glBindTexture(GL_TEXTURE_RECTANGLE_NV, texObj[i]); + glTexParameteri(GL_TEXTURE_RECTANGLE_NV, + GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_RECTANGLE_NV, + GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_WRAP_S, wrap); + glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_WRAP_T, wrap); + + if (i == 0) { + GLubyte *img = LoadRGBImage(TEXTURE_0_FILE, &Width[0], &Height[0], + &Format[0]); + if (!img) { + printf("Error: couldn't load texture image\n"); + exit(1); + } + printf("Texture %d: %s (%d x %d)\n", i, + TEXTURE_0_FILE, Width[0], Height[0]); + glTexImage2D(GL_TEXTURE_RECTANGLE_NV, 0, GL_RGB, + Width[0], Height[0], 0, + Format[0], GL_UNSIGNED_BYTE, img); + } + else { + GLubyte *img = LoadRGBImage(TEXTURE_1_FILE, &Width[1], &Height[1], + &Format[1]); + if (!img) { + printf("Error: couldn't load texture image\n"); + exit(1); + } + printf("Texture %d: %s (%d x %d)\n", i, + TEXTURE_1_FILE, Width[1], Height[1]); + glTexImage2D(GL_TEXTURE_RECTANGLE_NV, 0, GL_RGB, + Width[1], Height[1], 0, + Format[1], GL_UNSIGNED_BYTE, img); + } + + if (i < 1) + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_ADD); + else + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_ADD); + + if (TexEnabled[i]) + glEnable(GL_TEXTURE_RECTANGLE_NV); + } + + glShadeModel(GL_FLAT); + glClearColor(0.3, 0.3, 0.4, 1.0); + + 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)); + } +} + + +int main( int argc, char *argv[] ) +{ + GLint i; + + glutInit( &argc, argv ); + glutInitWindowSize( 300, 300 ); + glutInitWindowPosition( 0, 0 ); + glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE ); + glutCreateWindow(argv[0] ); + + Init( argc, argv ); + + glutReshapeFunc( Reshape ); + glutKeyboardFunc( Key ); + glutSpecialFunc( SpecialKey ); + glutDisplayFunc( Display ); + if (Animate) + glutIdleFunc( Idle ); + + glutCreateMenu(ModeMenu); + + for (i = 0; i < NumUnits; i++) { + char s[100]; + sprintf(s, "Toggle Texture %d", i); + glutAddMenuEntry(s, TEX0 + i); + } + glutAddMenuEntry("Toggle Animation", ANIMATE); + glutAddMenuEntry("GL_CLAMP", CLAMP); + glutAddMenuEntry("GL_CLAMP_TO_EDGE", CLAMP_TO_EDGE); + glutAddMenuEntry("GL_CLAMP_TO_BORDER", CLAMP_TO_BORDER); + glutAddMenuEntry("GL_NEAREST", NEAREST_FILTER); + glutAddMenuEntry("GL_LINEAR", LINEAR_FILTER); + glutAddMenuEntry("Quit", QUIT); + glutAttachMenu(GLUT_RIGHT_BUTTON); + + glutMainLoop(); + return 0; +} diff --git a/progs/tests/texwrap.c b/progs/tests/texwrap.c new file mode 100644 index 00000000000..b888dcd100c --- /dev/null +++ b/progs/tests/texwrap.c @@ -0,0 +1,304 @@ +/* $Id: texwrap.c,v 1.8 2005-08-25 03:09:12 brianp Exp $ */ + +/* + * Test texture wrap modes. + * Press 'b' to toggle texture image borders. You should see the same + * rendering whether or not you're using borders. + * + * Brian Paul March 2001 + */ + + +#define GL_GLEXT_PROTOTYPES +#include +#include +#include +#include + + +#ifndef GL_CLAMP_TO_BORDER +#define GL_CLAMP_TO_BORDER 0x812D +#endif + +#ifndef GL_MIRRORED_REPEAT +#define GL_MIRRORED_REPEAT 0x8370 +#endif + +#ifndef GL_EXT_texture_mirror_clamp +#define GL_MIRROR_CLAMP_EXT 0x8742 +#define GL_MIRROR_CLAMP_TO_EDGE_EXT 0x8743 +#define GL_MIRROR_CLAMP_TO_BORDER_EXT 0x8912 +#endif + +#define BORDER_TEXTURE 1 +#define NO_BORDER_TEXTURE 2 + +#define SIZE 8 +static GLubyte BorderImage[SIZE+2][SIZE+2][4]; +static GLubyte NoBorderImage[SIZE][SIZE][4]; +static GLuint Border = 0; + +#define TILE_SIZE 110 + +#define WRAP_MODE(m) { m , # m, GL_TRUE, 1.0, { NULL, NULL } } +#define WRAP_EXT(m,e1,e2,v) { m , # m, GL_FALSE, v, { e1, e2 } } + +struct wrap_mode { + GLenum mode; + const char * name; + GLboolean supported; + GLfloat version; + const char * extension_names[2]; +}; + +static struct wrap_mode modes[] = { + WRAP_MODE( GL_REPEAT ), + WRAP_MODE( GL_CLAMP ), + WRAP_EXT ( GL_CLAMP_TO_EDGE, "GL_EXT_texture_edge_clamp", + "GL_SGIS_texture_edge_clamp", + 1.2 ), + WRAP_EXT ( GL_CLAMP_TO_BORDER, "GL_ARB_texture_border_clamp", + "GL_SGIS_texture_border_clamp", + 1.3 ), + WRAP_EXT ( GL_MIRRORED_REPEAT, "GL_ARB_texture_mirrored_repeat", + "GL_IBM_texture_mirrored_repeat", + 1.4 ), + WRAP_EXT ( GL_MIRROR_CLAMP_EXT, "GL_ATI_texture_mirror_once", + "GL_EXT_texture_mirror_clamp", + 999.0 ), + WRAP_EXT ( GL_MIRROR_CLAMP_TO_BORDER_EXT, "GL_EXT_texture_mirror_clamp", + NULL, + 999.0 ), + WRAP_EXT ( GL_MIRROR_CLAMP_TO_EDGE_EXT, "GL_ATI_texture_mirror_once", + "GL_EXT_texture_mirror_clamp", + 999.0 ), + { 0 } +}; + +static void +PrintString(const char *s) +{ + while (*s) { + glutBitmapCharacter(GLUT_BITMAP_8_BY_13, (int) *s); + s++; + } +} + + +static void Display( void ) +{ + GLenum i, j; + GLint offset; + GLfloat version; + + /* Fill in the extensions that are supported. + */ + + version = atof( (char *) glGetString( GL_VERSION ) ); + for ( i = 0 ; modes[i].mode != 0 ; i++ ) { + if ( ((modes[i].extension_names[0] != NULL) + && glutExtensionSupported(modes[i].extension_names[0])) + || ((modes[i].extension_names[1] != NULL) + && glutExtensionSupported(modes[i].extension_names[1])) ) { + modes[i].supported = GL_TRUE; + } + else if ( !modes[i].supported && (modes[i].version <= version) ) { + fprintf( stderr, "WARNING: OpenGL library meets minimum version\n" + " requirement for %s, but the\n" + " extension string is not advertised.\n" + " (%s%s%s)\n", + modes[i].name, + modes[i].extension_names[0], + (modes[i].extension_names[1] != NULL) + ? " or " : "", + (modes[i].extension_names[1] != NULL) + ? modes[i].extension_names[1] : "" ); + modes[i].supported = GL_TRUE; + } + } + + + glClearColor(0.5, 0.5, 0.5, 1.0); + glClear( GL_COLOR_BUFFER_BIT ); + +#if 0 + /* draw texture as image */ + glDisable(GL_TEXTURE_2D); + glWindowPos2iARB(1, 1); + glDrawPixels(6, 6, GL_RGBA, GL_UNSIGNED_BYTE, (void *) TexImage); +#endif + + glBindTexture(GL_TEXTURE_2D, Border ? BORDER_TEXTURE : NO_BORDER_TEXTURE); + + + /* loop over min/mag filters */ + for (i = 0; i < 2; i++) { + offset = 0; + + if (i) { + 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); + } + + /* loop over border modes */ + for (j = 0; modes[j].mode != 0; j++) { + const GLfloat x0 = 0, y0 = 0, x1 = (TILE_SIZE - 10), y1 = (TILE_SIZE - 10); + const GLfloat b = 1.2; + const GLfloat s0 = -b, t0 = -b, s1 = 1.0+b, t1 = 1.0+b; + + if ( modes[j].supported != GL_TRUE ) + continue; + + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, modes[j].mode); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, modes[j].mode); + + glPushMatrix(); + glTranslatef(offset * TILE_SIZE + 10, i * TILE_SIZE + 40, 0); + offset++; + + glEnable(GL_TEXTURE_2D); + glColor3f(1, 1, 1); + glBegin(GL_POLYGON); + glTexCoord2f(s0, t0); glVertex2f(x0, y0); + glTexCoord2f(s1, t0); glVertex2f(x1, y0); + glTexCoord2f(s1, t1); glVertex2f(x1, y1); + glTexCoord2f(s0, t1); glVertex2f(x0, y1); + glEnd(); + + /* draw red outline showing bounds of texture at s=0,1 and t=0,1 */ + glDisable(GL_TEXTURE_2D); + glColor3f(1, 0, 0); + glBegin(GL_LINE_LOOP); + glVertex2f(x0 + b * (x1-x0) / (s1-s0), y0 + b * (y1-y0) / (t1-t0)); + glVertex2f(x1 - b * (x1-x0) / (s1-s0), y0 + b * (y1-y0) / (t1-t0)); + glVertex2f(x1 - b * (x1-x0) / (s1-s0), y1 - b * (y1-y0) / (t1-t0)); + glVertex2f(x0 + b * (x1-x0) / (s1-s0), y1 - b * (y1-y0) / (t1-t0)); + glEnd(); + + glPopMatrix(); + } + } + + glDisable(GL_TEXTURE_2D); + glColor3f(1, 1, 1); + offset = 0; + for (i = 0; modes[i].mode != 0; i++) { + if ( modes[i].supported ) { + glWindowPos2iARB( offset * TILE_SIZE + 10, 5 + ((offset & 1) * 15) ); + PrintString(modes[i].name); + offset++; + } + } + + 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 'b': + Border = !Border; + printf("Texture Border Size = %d\n", Border); + break; + case 27: + exit(0); + break; + } + glutPostRedisplay(); +} + + +static void Init( void ) +{ + static const GLubyte border[4] = { 0, 255, 0, 255 }; + static const GLfloat borderf[4] = { 0, 1.0, 0, 1.0 }; + GLint i, j; + + for (i = 0; i < SIZE+2; i++) { + for (j = 0; j < SIZE+2; j++) { + if (i == 0 || j == 0 || i == SIZE+1 || j == SIZE+1) { + /* border color */ + BorderImage[i][j][0] = border[0]; + BorderImage[i][j][1] = border[1]; + BorderImage[i][j][2] = border[2]; + BorderImage[i][j][3] = border[3]; + } + else if ((i + j) & 1) { + /* white */ + BorderImage[i][j][0] = 255; + BorderImage[i][j][1] = 255; + BorderImage[i][j][2] = 255; + BorderImage[i][j][3] = 255; + } + else { + /* black */ + BorderImage[i][j][0] = 0; + BorderImage[i][j][1] = 0; + BorderImage[i][j][2] = 0; + BorderImage[i][j][3] = 0; + } + } + } + + glBindTexture(GL_TEXTURE_2D, BORDER_TEXTURE); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, SIZE+2, SIZE+2, 1, + GL_RGBA, GL_UNSIGNED_BYTE, (void *) BorderImage); + + for (i = 0; i < SIZE; i++) { + for (j = 0; j < SIZE; j++) { + if ((i + j) & 1) { + /* white */ + NoBorderImage[i][j][0] = 255; + NoBorderImage[i][j][1] = 255; + NoBorderImage[i][j][2] = 255; + NoBorderImage[i][j][3] = 255; + } + else { + /* black */ + NoBorderImage[i][j][0] = 0; + NoBorderImage[i][j][1] = 0; + NoBorderImage[i][j][2] = 0; + NoBorderImage[i][j][3] = 0; + } + } + } + + glBindTexture(GL_TEXTURE_2D, NO_BORDER_TEXTURE); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, SIZE, SIZE, 0, + GL_RGBA, GL_UNSIGNED_BYTE, (void *) NoBorderImage); + glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, borderf); +} + + +int main( int argc, char *argv[] ) +{ + glutInit( &argc, argv ); + glutInitWindowPosition( 0, 0 ); + glutInitWindowSize( 1000, 270 ); + glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE ); + glutCreateWindow(argv[0]); + glutReshapeFunc( Reshape ); + glutKeyboardFunc( Key ); + glutDisplayFunc( Display ); + Init(); + glutMainLoop(); + return 0; +} diff --git a/progs/tests/vparray.c b/progs/tests/vparray.c new file mode 100644 index 00000000000..580a670f8e1 --- /dev/null +++ b/progs/tests/vparray.c @@ -0,0 +1,294 @@ +/* + * Test vertex arrays with GL_NV_vertex_program + * + * Based on a stripped-down version of the isosurf demo. + * The vertex program is trivial: compute the resulting + * RGB color as a linear function of vertex XYZ. + */ + +#include +#include +#include +#include +#include +#include +#define GL_GLEXT_PROTOTYPES +#include "GL/glut.h" + +#define MAXVERTS 10000 +static float data[MAXVERTS][6]; +static GLint numverts; + +static GLfloat xrot; +static GLfloat yrot; +static GLboolean useArrays = GL_TRUE; +static GLboolean useProgram = GL_TRUE; +static GLboolean useList = GL_FALSE; + + +static void read_surface( char *filename ) +{ + FILE *f; + + f = fopen(filename,"r"); + if (!f) { + printf("couldn't read %s\n", filename); + exit(1); + } + + numverts = 0; + while (!feof(f) && numverts < MAXVERTS) { + fscanf( f, "%f %f %f %f %f %f", + &data[numverts][0], &data[numverts][1], &data[numverts][2], + &data[numverts][3], &data[numverts][4], &data[numverts][5] ); + numverts++; + } + numverts--; + + printf("%d vertices, %d triangles\n", numverts, numverts-2); + printf("data = %p\n", (void *) data); + fclose(f); +} + + + + +static void Display(void) +{ + if (useProgram) + glEnable(GL_VERTEX_PROGRAM_NV); + else + glDisable(GL_VERTEX_PROGRAM_NV); + + glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); + + glPushMatrix(); + glRotatef(xrot, 1, 0, 0); + glRotatef(yrot, 0, 1, 0); + glScalef(2, 2, 2); + if (useArrays) { + if (useProgram) { + glVertexAttribPointerNV( 0, 3, GL_FLOAT, 6 * sizeof(GLfloat), data ); + glEnableClientState( GL_VERTEX_ATTRIB_ARRAY0_NV ); + glVertexAttribPointerNV( 2, 3, GL_FLOAT, 6 * sizeof(GLfloat), ((GLfloat *) data) + 3); + glEnableClientState( GL_VERTEX_ATTRIB_ARRAY2_NV); + } + else { + glVertexPointer( 3, GL_FLOAT, 6 * sizeof(GLfloat), data ); + glEnableClientState( GL_VERTEX_ARRAY ); + glNormalPointer( GL_FLOAT, 6 * sizeof(GLfloat), ((GLfloat *) data) + 3); + glEnableClientState( GL_NORMAL_ARRAY ); + } + + if (useList) { + /* dumb, but a good test */ + glNewList(1,GL_COMPILE); + glDrawArrays(GL_TRIANGLE_STRIP, 0, numverts); + glEndList(); + glCallList(1); + } + else { + glDrawArrays(GL_TRIANGLE_STRIP, 0, numverts); + } + + glDisableClientState( GL_VERTEX_ATTRIB_ARRAY0_NV ); + glDisableClientState( GL_VERTEX_ATTRIB_ARRAY2_NV); + glDisableClientState( GL_VERTEX_ARRAY ); + glDisableClientState( GL_NORMAL_ARRAY ); + } + else { + int i; + glBegin(GL_TRIANGLE_STRIP); + for (i = 0; i < numverts; i++) { + glNormal3fv( data[i] + 3 ); + glVertex3fv( data[i] + 0 ); + } + glEnd(); + } + glPopMatrix(); + + if (glGetError()) + printf("Error!\n"); + + glutSwapBuffers(); +} + + +static void InitMaterials(void) +{ + static float ambient[] = {0.1, 0.1, 0.1, 1.0}; + static float diffuse[] = {0.5, 1.0, 1.0, 1.0}; + static float position0[] = {0.0, 0.0, 20.0, 0.0}; + static float position1[] = {0.0, 0.0, -20.0, 0.0}; + static float front_mat_shininess[] = {60.0}; + static float front_mat_specular[] = {0.2, 0.2, 0.2, 1.0}; + static float front_mat_diffuse[] = {0.5, 0.28, 0.38, 1.0}; + /* + static float back_mat_shininess[] = {60.0}; + static float back_mat_specular[] = {0.5, 0.5, 0.2, 1.0}; + static float back_mat_diffuse[] = {1.0, 1.0, 0.2, 1.0}; + */ + static float lmodel_ambient[] = {1.0, 1.0, 1.0, 1.0}; + static float lmodel_twoside[] = {GL_FALSE}; + + glLightfv(GL_LIGHT0, GL_AMBIENT, ambient); + glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse); + glLightfv(GL_LIGHT0, GL_POSITION, position0); + glEnable(GL_LIGHT0); + + glLightfv(GL_LIGHT1, GL_AMBIENT, ambient); + glLightfv(GL_LIGHT1, GL_DIFFUSE, diffuse); + glLightfv(GL_LIGHT1, GL_POSITION, position1); + glEnable(GL_LIGHT1); + + glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient); + glLightModelfv(GL_LIGHT_MODEL_TWO_SIDE, lmodel_twoside); + + 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); + glEnable(GL_LIGHTING); +} + + +static void init_program(void) +{ + /* + * c[0..3] = modelview matrix + * c[4..7] = inverse modelview matrix + * c[30] = color scale + * c[31] = color bias + */ + static const char prog[] = + "!!VP1.0\n" + + "# RGB is proportional to XYZ \n" + + "MUL R0, v[OPOS], c[30]; \n" + "ADD o[COL0], R0, c[31]; \n" + + "# Continue with typical modelview/projection\n" + "MOV R3, v[OPOS]; \n" + "DP4 o[HPOS].x, c[0], R3 ; # object x MVP -> clip\n" + "DP4 o[HPOS].y, c[1], R3 ;\n" + "DP4 o[HPOS].z, c[2], R3 ;\n" + "DP4 o[HPOS].w, c[3], R3 ;\n" + + "END"; + + static const GLfloat scale[4] = {2.0, 2.0, 2.0, 0.0}; + static const GLfloat bias[4] = {1.0, 1.0, 1.0, 0.0}; + + if (!glutExtensionSupported("GL_NV_vertex_program")) { + printf("Sorry, this program requires GL_NV_vertex_program"); + exit(1); + } + + glLoadProgramNV(GL_VERTEX_PROGRAM_NV, 1, + strlen(prog), (const GLubyte *) prog); + assert(glIsProgramNV(1)); + glBindProgramNV(GL_VERTEX_PROGRAM_NV, 1); + + /* Load the program registers */ + glTrackMatrixNV(GL_VERTEX_PROGRAM_NV, 0, GL_MODELVIEW_PROJECTION_NV, GL_IDENTITY_NV); + glTrackMatrixNV(GL_VERTEX_PROGRAM_NV, 4, GL_MODELVIEW, GL_INVERSE_TRANSPOSE_NV); + + glProgramParameter4fvNV(GL_VERTEX_PROGRAM_NV, 30, scale); + glProgramParameter4fvNV(GL_VERTEX_PROGRAM_NV, 31, bias); +} + + +static void init(void) +{ + xrot = 0; + yrot = 0; + glClearColor(0.0, 0.0, 1.0, 0.0); + glEnable( GL_DEPTH_TEST ); + glEnable(GL_NORMALIZE); + InitMaterials(); + read_surface( "../demos/isosurf.dat" ); + init_program(); +} + + +static void Reshape(int width, int height) +{ + glViewport(0, 0, (GLint)width, (GLint)height); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glFrustum( -1.0, 1.0, -1.0, 1.0, 5, 25 ); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTranslatef(0, 0, -15); +} + + + +static void Key( unsigned char key, int x, int y ) +{ + (void) x; + (void) y; + switch (key) { + case 27: + exit(0); + case 'a': + useArrays = !useArrays; + printf("use arrays: %s\n", useArrays ? "yes" : "no"); + break; + case 'l': + useList = !useList; + printf("use list: %s\n", useList ? "yes" : "no"); + break; + case 'p': + useProgram = !useProgram; + printf("use program: %s\n", useProgram ? "yes" : "no"); + break; + } + glutPostRedisplay(); +} + + +static void SpecialKey( int key, int x, int y ) +{ + (void) x; + (void) y; + switch (key) { + case GLUT_KEY_LEFT: + yrot -= 15.0; + break; + case GLUT_KEY_RIGHT: + yrot += 15.0; + break; + case GLUT_KEY_UP: + xrot += 15.0; + break; + case GLUT_KEY_DOWN: + xrot -= 15.0; + break; + default: + return; + } + glutPostRedisplay(); +} + + + +int main(int argc, char **argv) +{ + glutInit(&argc, argv); + glutInitDisplayMode( GLUT_DEPTH | GLUT_RGB | GLUT_DOUBLE ); + glutInitWindowPosition(0, 0); + glutInitWindowSize(400, 400); + if (glutCreateWindow("Isosurface") <= 0) { + exit(0); + } + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutSpecialFunc(SpecialKey); + glutDisplayFunc(Display); + + init(); + + glutMainLoop(); + return 0; +} diff --git a/progs/tests/vpeval.c b/progs/tests/vpeval.c new file mode 100644 index 00000000000..8b6996d3b5c --- /dev/null +++ b/progs/tests/vpeval.c @@ -0,0 +1,231 @@ +/* + * Vertex program evaluators test. + * Based on book/bezmesh.c + * + * Brian Paul + * 22 June 2002 + */ + +#include +#include +#include +#include +#define GL_GLEXT_PROTOTYPES +#include + + +/* + * Transform position by modelview/projection. + * Square incoming color. + */ +static const char prog[] = +"!!VP1.0\n" + +"# Typical modelview/projection\n" +"DP4 o[HPOS].x, c[0], v[OPOS] ; # object x MVP -> clip\n" +"DP4 o[HPOS].y, c[1], v[OPOS] ;\n" +"DP4 o[HPOS].z, c[2], v[OPOS] ;\n" +"DP4 o[HPOS].w, c[3], v[OPOS] ;\n" + +"MOV R0, v[COL0];\n # square the color\n" +"MUL R0, R0, R0;\n" +"MOV o[COL0], R0;\n # store output color\n" + +"END"; + + +static int program = 1; + + +GLfloat ctrlpoints[4][4][4] = +{ + { + {-1.5, -1.5, 4.0, 1.0}, + {-0.5, -1.5, 2.0, 1.0}, + {0.5, -1.5, -1.0, 1.0}, + {1.5, -1.5, 2.0, 1.0}}, + { + {-1.5, -0.5, 1.0, 1.0}, + {-0.5, -0.5, 3.0, 1.0}, + {0.5, -0.5, 0.0, 1.0}, + {1.5, -0.5, -1.0, 1.0}}, + { + {-1.5, 0.5, 4.0, 1.0}, + {-0.5, 0.5, 0.0, 1.0}, + {0.5, 0.5, 3.0, 1.0}, + {1.5, 0.5, 4.0, 1.0}}, + { + {-1.5, 1.5, -2.0, 1.0}, + {-0.5, 1.5, -2.0, 1.0}, + {0.5, 1.5, 0.0, 1.0}, + {1.5, 1.5, -1.0, 1.0}} +}; + +/* + * +-------------+ + * |green |yellow + * | | + * | | + * |black |red + * +-------------+ + */ +GLfloat colorPoints[4][4][4] = +{ + { + {0.0, 0.0, 0.0, 1.0}, + {0.3, 0.0, 0.0, 1.0}, + {0.6, 0.0, 0.0, 1.0}, + {1.0, 0.0, 0.0, 1.0}}, + { + {0.0, 0.3, 0.0, 1.0}, + {0.3, 0.3, 0.0, 1.0}, + {0.6, 0.3, 0.0, 1.0}, + {1.0, 0.3, 0.0, 1.0}}, + { + {0.0, 0.6, 0.0, 1.0}, + {0.3, 0.6, 0.0, 1.0}, + {0.6, 0.6, 0.0, 1.0}, + {1.0, 0.6, 0.0, 1.0}}, + { + {0.0, 1.0, 0.0, 1.0}, + {0.3, 1.0, 0.0, 1.0}, + {0.6, 1.0, 0.0, 1.0}, + {1.0, 1.0, 0.0, 1.0}} +}; + + +void +initlights(void) +{ + GLfloat ambient[] = {0.2, 0.2, 0.2, 1.0}; + GLfloat position[] = {0.0, 0.0, 2.0, 1.0}; + GLfloat mat_diffuse[] = {0.6, 0.6, 0.6, 1.0}; + GLfloat mat_specular[] = {1.0, 1.0, 1.0, 1.0}; + GLfloat mat_shininess[] = {50.0}; + +#if 0 /* no lighting for now */ + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + + glLightfv(GL_LIGHT0, GL_AMBIENT, ambient); + glLightfv(GL_LIGHT0, GL_POSITION, position); + + glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); + glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); + glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess); +#endif +} + +void +display(void) +{ + glClearColor(.3, .3, .3, 0); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glPushMatrix(); +#if 1 + glRotatef(85.0, 1.0, 1.0, 1.0); +#endif + glEvalMesh2(GL_FILL, 0, 8, 0, 8); + glPopMatrix(); + glFlush(); +} + +void +myinit(int argc, char *argv[]) +{ + glClearColor(0.0, 0.0, 0.0, 1.0); + glEnable(GL_DEPTH_TEST); + + initlights(); /* for lighted version only */ + + glMapGrid2f(8, 0.0, 1.0, 8, 0.0, 1.0); + + if (argc > 1) + program = 0; + + printf("Using vertex program attribs? %s\n", program ? "yes" : "no"); + + if (!program) { + glMap2f(GL_MAP2_VERTEX_4, + 0.0, 1.0, 4, 4, + 0.0, 1.0, 16, 4, &ctrlpoints[0][0][0]); + glMap2f(GL_MAP2_COLOR_4, + 0.0, 1.0, 4, 4, + 0.0, 1.0, 16, 4, &colorPoints[0][0][0]); + glEnable(GL_MAP2_VERTEX_4); + glEnable(GL_MAP2_COLOR_4); + /* + glEnable(GL_AUTO_NORMAL); + glEnable(GL_NORMALIZE); + */ + } + else { + glMap2f(GL_MAP2_VERTEX_ATTRIB0_4_NV, + 0.0, 1.0, 4, 4, + 0.0, 1.0, 16, 4, &ctrlpoints[0][0][0]); + glMap2f(GL_MAP2_VERTEX_ATTRIB3_4_NV, + 0.0, 1.0, 4, 4, + 0.0, 1.0, 16, 4, &colorPoints[0][0][0]); + glEnable(GL_MAP2_VERTEX_ATTRIB0_4_NV); + glEnable(GL_MAP2_VERTEX_ATTRIB3_4_NV); + + /* + glEnable(GL_AUTO_NORMAL); + glEnable(GL_NORMALIZE); + */ + + /* vertex program init */ + glLoadProgramNV(GL_VERTEX_PROGRAM_NV, 1, + strlen(prog), (const GLubyte *) prog); + assert(glIsProgramNV(1)); + glBindProgramNV(GL_VERTEX_PROGRAM_NV, 1); + + /* track matrices */ + glTrackMatrixNV(GL_VERTEX_PROGRAM_NV, 0, GL_MODELVIEW_PROJECTION_NV, GL_IDENTITY_NV); + glEnable(GL_VERTEX_PROGRAM_NV); + } +} + +void +myReshape(int w, int h) +{ + glViewport(0, 0, w, h); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + if (w <= h) + glOrtho(-4.0, 4.0, -4.0 * (GLfloat) h / (GLfloat) w, + 4.0 * (GLfloat) h / (GLfloat) w, -4.0, 4.0); + else + glOrtho(-4.0 * (GLfloat) w / (GLfloat) h, + 4.0 * (GLfloat) w / (GLfloat) h, -4.0, 4.0, -4.0, 4.0); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); +} + +static void +key(unsigned char k, int x, int y) +{ + switch (k) { + case 27: /* Escape */ + exit(0); + break; + default: + return; + } + glutPostRedisplay(); +} + +int +main(int argc, char **argv) +{ + glutInit(&argc, argv); + glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH); + glutInitWindowPosition(0, 0); + glutCreateWindow(argv[0]); + myinit(argc, argv); + glutReshapeFunc(myReshape); + glutDisplayFunc(display); + glutKeyboardFunc(key); + glutMainLoop(); + return 0; /* ANSI C requires main to return int. */ +} diff --git a/progs/tests/vptest1.c b/progs/tests/vptest1.c new file mode 100644 index 00000000000..560df2c3fdc --- /dev/null +++ b/progs/tests/vptest1.c @@ -0,0 +1,170 @@ +/* Test glGenProgramsNV(), glIsProgramNV(), glLoadProgramNV() */ + +#include +#include +#include +#include +#include +#define GL_GLEXT_PROTOTYPES +#include + + + +static void Display( void ) +{ + glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); + + glPushMatrix(); + + glBegin(GL_POLYGON); + glVertexAttrib2fNV(0, -1, -1); + glVertexAttrib2fNV(0, 1, -1); + glVertexAttrib2fNV(0, 0, 1); + glEnd(); + + glPopMatrix(); + + glutSwapBuffers(); +} + + +static void Reshape( int width, int height ) +{ + glViewport( 0, 0, width, height ); + glMatrixMode( GL_PROJECTION ); + glLoadIdentity(); + glFrustum( -1.0, 1.0, -1.0, 1.0, 5.0, 25.0 ); + glMatrixMode( GL_MODELVIEW ); + glLoadIdentity(); + glTranslatef( 0.0, 0.0, -15.0 ); +} + + +static void Key( unsigned char key, int x, int y ) +{ + (void) x; + (void) y; + switch (key) { + case 27: + exit(0); + break; + } + glutPostRedisplay(); +} + + +static void Init( void ) +{ + static const char *prog1 = + "!!VP1.0\n" + "MUL o[COL0].xyz, R0, c[35]; \n" + "END\n"; + static const char *prog2 = + "!!VP1.0\n" + "#\n" + "# c[0-3] = modelview projection (composite) matrix\n" + "# c[32] = normalized light direction in object-space\n" + "# c[35] = yellow diffuse material, (1.0, 1.0, 0.0, 1.0)\n" + "# c[64].x = 0.0\n" + "# c[64].z = 0.125, a scaling factor\n" + "#\n" + "# outputs diffuse illumination for color and perturbed position\n" + "#\n" + "DP3 R0, c[32], v[NRML]; # light direction DOT normal\n" + "MUL o[COL0].xyz, R0, c[35]; \n" + "MAX R0, c[64].x, R0; \n" + "MUL R0, R0, v[NRML]; \n" + "MUL R0, R0, c[64].z; \n" + "ADD R1, v[OPOS], -R0; # perturb object space position\n" + "DP4 o[HPOS].x, c[0], R1; \n" + "DP4 o[HPOS].y, c[1], R1; \n" + "DP4 o[HPOS].z, c[2], R1; \n" + "DP4 o[HPOS].w, c[3], R1; \n" + "END\n"; + static const char *prog3 = + "!!VP1.0\n" + "DP4 o[HPOS].x, c[0], v[OPOS];\n" + "DP4 o[HPOS].y, c[1], v[OPOS];\n" + "DP4 o[HPOS].z, c[2], v[OPOS];\n" + "DP4 o[HPOS].w, c[3], v[OPOS];\n" + "DP3 R0.x, c[4], v[NRML];\n" + "DP3 R0.y, c[5], v[NRML]; \n" + "DP3 R0.z, c[6], v[NRML]; # R0 = n' = transformed normal\n" + "DP3 R1.x, c[32], R0; # R1.x = Lpos DOT n'\n" + "DP3 R1.y, c[33], R0; # R1.y = hHat DOT n'\n" + "MOV R1.w, c[38].x; # R1.w = specular power\n" + "LIT R2, R1; # Compute lighting values\n" + "MAD R3, c[35].x, R2.y, c[35].y; # diffuse + emissive\n" + "MAD o[COL0].xyz, c[36], R2.z, R3; # + specular\n" + "END\n"; + static const char *prog4 = + "!!VP1.0\n" + "DP4 R2, R3, c[A0.x];\n" + "DP4 R2, R3, c[A0.x + 5];\n" + "DP4 o[HPOS], R3, c[A0.x - 4];\n" + "END\n"; + static const char *prog5 = + "!!VSP1.0\n" + "DP4 R2, R3, c[A0.x];\n" + "DP4 R2, R3, v[0];\n" + "DP4 c[3], R3, R2;\n" + "END\n"; + + + GLuint progs[5]; + + glGenProgramsNV(2, progs); + assert(progs[0]); + assert(progs[1]); + assert(progs[0] != progs[1]); + + glGenProgramsNV(3, progs + 2); + assert(progs[2]); + assert(progs[3]); + assert(progs[2] != progs[3]); + assert(progs[0] != progs[2]); + + + glLoadProgramNV(GL_VERTEX_PROGRAM_NV, 1, + strlen(prog1), + (const GLubyte *) prog1); + assert(!glIsProgramNV(1)); + + glLoadProgramNV(GL_VERTEX_PROGRAM_NV, 2, + strlen(prog2), + (const GLubyte *) prog2); + assert(glIsProgramNV(2)); + + glLoadProgramNV(GL_VERTEX_PROGRAM_NV, 3, + strlen(prog3), + (const GLubyte *) prog3); + assert(glIsProgramNV(3)); + + glLoadProgramNV(GL_VERTEX_PROGRAM_NV, 4, + strlen(prog4), + (const GLubyte *) prog4); + assert(glIsProgramNV(4)); + + glLoadProgramNV(GL_VERTEX_STATE_PROGRAM_NV, 5, + strlen(prog5), + (const GLubyte *) prog5); + assert(glIsProgramNV(5)); + + printf("glGetError = %d\n", (int) glGetError()); +} + + +int main( int argc, char *argv[] ) +{ + glutInit( &argc, argv ); + glutInitWindowPosition( 0, 0 ); + glutInitWindowSize( 250, 250 ); + glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ); + glutCreateWindow(argv[0]); + glutReshapeFunc( Reshape ); + glutKeyboardFunc( Key ); + glutDisplayFunc( Display ); + Init(); + glutMainLoop(); + return 0; +} diff --git a/progs/tests/vptest2.c b/progs/tests/vptest2.c new file mode 100644 index 00000000000..2158e07f042 --- /dev/null +++ b/progs/tests/vptest2.c @@ -0,0 +1,151 @@ +/* Test vertex state program execution */ + +#include +#include +#include +#include +#include +#define GL_GLEXT_PROTOTYPES +#include + + + +static void Display( void ) +{ + glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); + glPushMatrix(); + glutSolidCube(2.0); + glPopMatrix(); + glutSwapBuffers(); +} + + +static void Reshape( int width, int height ) +{ + glViewport( 0, 0, width, height ); + glMatrixMode( GL_PROJECTION ); + glLoadIdentity(); + glFrustum( -1.0, 1.0, -1.0, 1.0, 5.0, 25.0 ); + glMatrixMode( GL_MODELVIEW ); + glLoadIdentity(); + glTranslatef( 0.0, 0.0, -15.0 ); +} + + +static void Key( unsigned char key, int x, int y ) +{ + (void) x; + (void) y; + switch (key) { + case 27: + exit(0); + break; + } + glutPostRedisplay(); +} + + +static void Test1( void ) +{ + static const GLfloat p[4] = {9, 8, 7, 6}; + GLfloat q[4]; + /* test addition */ + static const char *prog = + "!!VSP1.0\n" + "MOV R0, c[0];\n" + "MOV R1, c[1];\n" + "ADD c[2], R0, R1;\n" + "END\n"; + + glLoadProgramNV(GL_VERTEX_STATE_PROGRAM_NV, 1, + strlen(prog), + (const GLubyte *) prog); + assert(glIsProgramNV(1)); + + glProgramParameter4fNV(GL_VERTEX_PROGRAM_NV, 0, 1, 2, 3, 4); + glProgramParameter4fNV(GL_VERTEX_PROGRAM_NV, 1, 10, 20, 30, 40); + + glExecuteProgramNV(GL_VERTEX_STATE_PROGRAM_NV, 1, p); + + glGetProgramParameterfvNV(GL_VERTEX_PROGRAM_NV, 2, GL_PROGRAM_PARAMETER_NV, q); + printf("Result c[2] = %g %g %g %g (should be 11 22 33 44)\n", + q[0], q[1], q[2], q[3]); +} + + +static void Test2( void ) +{ + static const GLfloat p[4] = {9, 8, 7, 6}; + GLfloat q[4]; + /* test swizzling */ + static const char *prog = + "!!VSP1.0\n" + "MOV R0, c[0].wzyx;\n" + "MOV R1, c[1].wzyx;\n" + "ADD c[2], R0, R1;\n" + "END\n"; + + glLoadProgramNV(GL_VERTEX_STATE_PROGRAM_NV, 1, + strlen(prog), + (const GLubyte *) prog); + assert(glIsProgramNV(1)); + + glProgramParameter4fNV(GL_VERTEX_PROGRAM_NV, 0, 1, 2, 3, 4); + glProgramParameter4fNV(GL_VERTEX_PROGRAM_NV, 1, 10, 20, 30, 40); + + glExecuteProgramNV(GL_VERTEX_STATE_PROGRAM_NV, 1, p); + + glGetProgramParameterfvNV(GL_VERTEX_PROGRAM_NV, 2, GL_PROGRAM_PARAMETER_NV, q); + printf("Result c[2] = %g %g %g %g (should be 44 33 22 11)\n", + q[0], q[1], q[2], q[3]); +} + + +static void Test3( void ) +{ + static const GLfloat p[4] = {0, 0, 0, 0}; + GLfloat q[4]; + /* normalize vector */ + static const char *prog = + "!!VSP1.0\n" + "# c[0] = (nx,ny,nz)\n" + "# R0.xyz = normalize(R1)\n" + "# R0.w = 1/sqrt(nx*nx + ny*ny + nz*nz)\n" + "# c[2] = R0\n" + "DP3 R0.w, c[0], c[0];\n" + "RSQ R0.w, R0.w;\n" + "MUL R0.xyz, c[0], R0.w;\n" + "MOV c[2], R0;\n" + "END\n"; + + glLoadProgramNV(GL_VERTEX_STATE_PROGRAM_NV, 1, + strlen(prog), + (const GLubyte *) prog); + assert(glIsProgramNV(1)); + + glProgramParameter4fNV(GL_VERTEX_PROGRAM_NV, 0, 0, 10, 0, 0); + + glExecuteProgramNV(GL_VERTEX_STATE_PROGRAM_NV, 1, p); + + glGetProgramParameterfvNV(GL_VERTEX_PROGRAM_NV, 2, GL_PROGRAM_PARAMETER_NV, q); + printf("Result c[2] = %g %g %g %g (should be 0, 1, 0, 0.1)\n", + q[0], q[1], q[2], q[3]); +} + + +int main( int argc, char *argv[] ) +{ + glutInit( &argc, argv ); + glutInitWindowPosition( 0, 0 ); + glutInitWindowSize( 50, 50 ); + glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ); + glutCreateWindow(argv[0]); + glutReshapeFunc( Reshape ); + glutKeyboardFunc( Key ); + glutDisplayFunc( Display ); + Test1(); + Test2(); + Test3(); + glutMainLoop(); + return 0; +} diff --git a/progs/tests/vptest3.c b/progs/tests/vptest3.c new file mode 100644 index 00000000000..2c5c8000408 --- /dev/null +++ b/progs/tests/vptest3.c @@ -0,0 +1,120 @@ +/* Test glGenProgramsNV(), glIsProgramNV(), glLoadProgramNV() */ + +#include +#include +#include +#include +#include +#define GL_GLEXT_PROTOTYPES +#include + +static float Zrot = 0.0; + + +static void Display( void ) +{ + glClearColor(0.3, 0.3, 0.3, 1); + glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); + + glEnable(GL_VERTEX_PROGRAM_NV); + + glLoadIdentity(); + glRotatef(Zrot, 0, 0, 1); + + glTrackMatrixNV(GL_VERTEX_PROGRAM_NV, 0, GL_MODELVIEW, GL_IDENTITY_NV); + glPushMatrix(); + + glVertexAttrib3fNV(3, 1, 0.5, 0.25); + glBegin(GL_TRIANGLES); +#if 1 + glVertexAttrib3fNV(3, 1.0, 0.0, 0.0); + glVertexAttrib2fNV(0, -0.5, -0.5); + glVertexAttrib3fNV(3, 0.0, 1.0, 0.0); + glVertexAttrib2fNV(0, 0.5, -0.5); + glVertexAttrib3fNV(3, 0.0, 0.0, 1.0); + glVertexAttrib2fNV(0, 0, 0.5); +#else + glVertex2f( -1, -1); + glVertex2f( 1, -1); + glVertex2f( 0, 1); +#endif + glEnd(); + + glPopMatrix(); + + glutSwapBuffers(); +} + + +static void Reshape( int width, int height ) +{ + glViewport( 0, 0, width, height ); + glMatrixMode( GL_PROJECTION ); + glLoadIdentity(); + /* glFrustum( -2.0, 2.0, -2.0, 2.0, 5.0, 25.0 );*/ + glOrtho(-2.0, 2.0, -2.0, 2.0, -2.0, 2.0 ); + glMatrixMode( GL_MODELVIEW ); + glLoadIdentity(); + /*glTranslatef( 0.0, 0.0, -15.0 );*/ +} + + +static void Key( unsigned char key, int x, int y ) +{ + (void) x; + (void) y; + switch (key) { + case 'z': + Zrot -= 5.0; + break; + case 'Z': + Zrot += 5.0; + break; + case 27: + exit(0); + break; + } + glutPostRedisplay(); +} + + +static void Init( void ) +{ + static const char *prog1 = + "!!VP1.0\n" + "MOV o[COL0], v[COL0];\n" +#if 0 + "MOV o[HPOS], v[OPOS];\n" +#else + "DP4 o[HPOS].x, v[OPOS], c[0];\n" + "DP4 o[HPOS].y, v[OPOS], c[1];\n" + "DP4 o[HPOS].z, v[OPOS], c[2];\n" + "DP4 o[HPOS].w, v[OPOS], c[3];\n" +#endif + "END\n"; + + glLoadProgramNV(GL_VERTEX_PROGRAM_NV, 1, + strlen(prog1), + (const GLubyte *) prog1); + assert(glIsProgramNV(1)); + + glBindProgramNV(GL_VERTEX_PROGRAM_NV, 1); + + printf("glGetError = %d\n", (int) glGetError()); +} + + +int main( int argc, char *argv[] ) +{ + glutInit( &argc, argv ); + glutInitWindowPosition( 0, 0 ); + glutInitWindowSize( 250, 250 ); + glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ); + glutCreateWindow(argv[0]); + glutReshapeFunc( Reshape ); + glutKeyboardFunc( Key ); + glutDisplayFunc( Display ); + Init(); + glutMainLoop(); + return 0; +} diff --git a/progs/tests/vptorus.c b/progs/tests/vptorus.c new file mode 100644 index 00000000000..764dea4ec22 --- /dev/null +++ b/progs/tests/vptorus.c @@ -0,0 +1,174 @@ +/* + * A lit, rotating torus via vertex program + */ + +#include +#include +#include +#include +#include +#define GL_GLEXT_PROTOTYPES +#include + +static float Xrot = 0.0, Yrot = 0.0, Zrot = 0.0; +static GLboolean Anim = GL_TRUE; + + +static void Idle( void ) +{ + Xrot += .3; + Yrot += .4; + Zrot += .2; + glutPostRedisplay(); +} + + +static void Display( void ) +{ + glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); + + glPushMatrix(); + glRotatef(Xrot, 1, 0, 0); + glRotatef(Yrot, 0, 1, 0); + glRotatef(Zrot, 0, 0, 1); + glutSolidTorus(0.75, 2.0, 10, 20); + glPopMatrix(); + + glutSwapBuffers(); +} + + +static void Reshape( int width, int height ) +{ + glViewport( 0, 0, width, height ); + glMatrixMode( GL_PROJECTION ); + glLoadIdentity(); + glFrustum( -2.0, 2.0, -2.0, 2.0, 5.0, 25.0 ); + glMatrixMode( GL_MODELVIEW ); + glLoadIdentity(); + glTranslatef( 0.0, 0.0, -12.0 ); +} + + +static void Key( unsigned char key, int x, int y ) +{ + (void) x; + (void) y; + switch (key) { + case ' ': + Xrot = Yrot = Zrot = 0; + break; + case 'a': + Anim = !Anim; + if (Anim) + glutIdleFunc(Idle); + else + glutIdleFunc(NULL); + break; + case 'z': + Zrot -= 5.0; + break; + case 'Z': + Zrot += 5.0; + 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 ) +{ + /* borrowed from an nvidia demo: + * c[0..3] = modelview matrix + * c[4..7] = inverse modelview matrix + * c[32] = light pos + * c[35] = diffuse color + */ + static const char prog[] = + "!!VP1.0\n" + "#Simple transform and diffuse lighting\n" + "\n" + "DP4 o[HPOS].x, c[0], v[OPOS] ; # object x MVP -> clip\n" + "DP4 o[HPOS].y, c[1], v[OPOS] ;\n" + "DP4 o[HPOS].z, c[2], v[OPOS] ;\n" + "DP4 o[HPOS].w, c[3], v[OPOS] ;\n" + + "DP3 R1.x, c[4], v[NRML] ; # normal x MV-1T -> lighting normal\n" + "DP3 R1.y, c[5], v[NRML] ;\n" + "DP3 R1.z, c[6], v[NRML] ;\n" + + "DP3 R0, c[32], R1 ; # L.N\n" + "MUL o[COL0].xyz, R0, c[35] ; # col = L.N * diffuse\n" + "MOV o[TEX0], v[TEX0];\n" + "END"; + + if (!glutExtensionSupported("GL_NV_vertex_program")) { + printf("Sorry, this program requires GL_NV_vertex_program"); + exit(1); + } + + glLoadProgramNV(GL_VERTEX_PROGRAM_NV, 1, + strlen(prog), (const GLubyte *) prog); + assert(glIsProgramNV(1)); + glBindProgramNV(GL_VERTEX_PROGRAM_NV, 1); + + /* Load the program registers */ + glTrackMatrixNV(GL_VERTEX_PROGRAM_NV, 0, GL_MODELVIEW_PROJECTION_NV, GL_IDENTITY_NV); + glTrackMatrixNV(GL_VERTEX_PROGRAM_NV, 4, GL_MODELVIEW, GL_INVERSE_TRANSPOSE_NV); + + /* Light position */ + glProgramParameter4fNV(GL_VERTEX_PROGRAM_NV, 32, 2, 2, 4, 1); + /* Diffuse material color */ + glProgramParameter4fNV(GL_VERTEX_PROGRAM_NV, 35, 0.25, 0, 0.25, 1); + + glEnable(GL_VERTEX_PROGRAM_NV); + glEnable(GL_DEPTH_TEST); + glClearColor(0.3, 0.3, 0.3, 1); + + printf("glGetError = %d\n", (int) glGetError()); +} + + +int main( int argc, char *argv[] ) +{ + glutInit( &argc, argv ); + glutInitWindowPosition( 0, 0 ); + glutInitWindowSize( 250, 250 ); + glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ); + glutCreateWindow(argv[0]); + glutReshapeFunc( Reshape ); + glutKeyboardFunc( Key ); + glutSpecialFunc( SpecialKey ); + glutDisplayFunc( Display ); + if (Anim) + glutIdleFunc(Idle); + Init(); + glutMainLoop(); + return 0; +} diff --git a/progs/tests/vpwarpmesh.c b/progs/tests/vpwarpmesh.c new file mode 100644 index 00000000000..56aa8200ec8 --- /dev/null +++ b/progs/tests/vpwarpmesh.c @@ -0,0 +1,236 @@ +/* + * Warp a triangle mesh with a vertex program. + */ + +#include +#include +#include +#include +#include +#define GL_GLEXT_PROTOTYPES +#include + +static float Xrot = -60.0, Yrot = 0.0, Zrot = 0.0; +static GLboolean Anim = GL_TRUE; +static GLfloat Phi = 0.0; + + +static void Idle( void ) +{ + Phi += 0.01; + glutPostRedisplay(); +} + + +static void DrawMesh( int rows, int cols ) +{ + static const GLfloat colorA[3] = { 0, 1, 0 }; + static const GLfloat colorB[3] = { 0, 0, 1 }; + const float dx = 2.0 / (cols - 1); + const float dy = 2.0 / (rows - 1); + float x, y; + int i, j; + +#if 1 +#define COLOR3FV(c) glVertexAttrib3fvNV(3, c) +#define VERTEX2F(x, y) glVertexAttrib2fNV(0, x, y) +#else +#define COLOR3FV(c) glColor3fv(c) +#define VERTEX2F(x, y) glVertex2f(x, y) +#endif + + y = -1.0; + for (i = 0; i < rows - 1; i++) { + glBegin(GL_QUAD_STRIP); + x = -1.0; + for (j = 0; j < cols; j++) { + if ((i + j) & 1) + COLOR3FV(colorA); + else + COLOR3FV(colorB); + VERTEX2F(x, y); + VERTEX2F(x, y + dy); + x += dx; + } + glEnd(); + y += dy; + } +} + + +static void Display( void ) +{ + glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); + + glPushMatrix(); + glRotatef(Xrot, 1, 0, 0); + glRotatef(Yrot, 0, 1, 0); + glRotatef(Zrot, 0, 0, 1); + + /* Position the gravity source */ + { + GLfloat x, y, z, r = 0.5; + x = r * cos(Phi); + y = r * sin(Phi); + z = 1.0; + glProgramParameter4fNV(GL_VERTEX_PROGRAM_NV, 30, x, y, z, 1); + glDisable(GL_VERTEX_PROGRAM_NV); + glBegin(GL_POINTS); + glColor3f(1,1,1); + glVertex3f(x, y, z); + glEnd(); + } + + glEnable(GL_VERTEX_PROGRAM_NV); + DrawMesh(8, 8); + glPopMatrix(); + + glutSwapBuffers(); +} + + +static void Reshape( int width, int height ) +{ + float ar = (float) width / (float) height; + glViewport( 0, 0, width, height ); + glMatrixMode( GL_PROJECTION ); + glLoadIdentity(); + glFrustum( -1.0 * ar, 1.0 * ar, -1.0, 1.0, 5.0, 25.0 ); + glMatrixMode( GL_MODELVIEW ); + glLoadIdentity(); + glTranslatef( 0.0, 0.0, -12.0 ); + glScalef(2, 2, 2); +} + + +static void Key( unsigned char key, int x, int y ) +{ + (void) x; + (void) y; + switch (key) { + case 'a': + Anim = !Anim; + if (Anim) + glutIdleFunc(Idle); + else + glutIdleFunc(NULL); + break; + case 'p': + Phi += 0.2; + break; + case 'z': + Zrot -= 5.0; + break; + case 'Z': + Zrot += 5.0; + 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 ) +{ + /* + * c[0..3] = modelview matrix + * c[4..7] = inverse modelview matrix + * c[30] = gravity source location + * c[31] = gravity source strength + * c[32] = light pos + * c[35] = diffuse color + */ + static const char prog[] = + "!!VP1.0\n" + + "# Compute distance from vertex to gravity source\n" + "ADD R1, c[30], -v[OPOS]; # vector from vertex to gravity\n" + "DP3 R2, R1, R1; # dot product\n" + "RSQ R2, R2.x; # square root = distance\n" + "MUL R2, R2, c[31].xxxx; # scale by the gravity factor\n" + + "# Displace vertex by gravity factor along R1 vector\n" + "MAD R3, R1, R2, v[OPOS];\n" + + "# Continue with typical modelview/projection\n" + "DP4 o[HPOS].x, c[0], R3 ; # object x MVP -> clip\n" + "DP4 o[HPOS].y, c[1], R3 ;\n" + "DP4 o[HPOS].z, c[2], R3 ;\n" + "DP4 o[HPOS].w, c[3], R3 ;\n" + + "MOV o[COL0], v[COL0];\n # copy input color to output color\n" + + "END"; + + if (!glutExtensionSupported("GL_NV_vertex_program")) { + printf("Sorry, this program requires GL_NV_vertex_program\n"); + exit(1); + } + + glLoadProgramNV(GL_VERTEX_PROGRAM_NV, 1, + strlen(prog), (const GLubyte *) prog); + assert(glIsProgramNV(1)); + glBindProgramNV(GL_VERTEX_PROGRAM_NV, 1); + + /* Load the program registers */ + glTrackMatrixNV(GL_VERTEX_PROGRAM_NV, 0, GL_MODELVIEW_PROJECTION_NV, GL_IDENTITY_NV); + glTrackMatrixNV(GL_VERTEX_PROGRAM_NV, 4, GL_MODELVIEW, GL_INVERSE_TRANSPOSE_NV); + + /* Light position */ + glProgramParameter4fNV(GL_VERTEX_PROGRAM_NV, 32, 2, 2, 4, 1); + /* Diffuse material color */ + glProgramParameter4fNV(GL_VERTEX_PROGRAM_NV, 35, 0.25, 0, 0.25, 1); + + /* Gravity strength */ + glProgramParameter4fNV(GL_VERTEX_PROGRAM_NV, 31, .5, 0, 0, 0); + + glEnable(GL_DEPTH_TEST); + glClearColor(0.3, 0.3, 0.3, 1); + glShadeModel(GL_FLAT); + glPointSize(3); + printf("glGetError = %d\n", (int) glGetError()); +} + + +int main( int argc, char *argv[] ) +{ + glutInit( &argc, argv ); + glutInitWindowPosition( 0, 0 ); + glutInitWindowSize( 250, 250 ); + glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ); + glutCreateWindow(argv[0]); + glutReshapeFunc( Reshape ); + glutKeyboardFunc( Key ); + glutSpecialFunc( SpecialKey ); + glutDisplayFunc( Display ); + if (Anim) + glutIdleFunc(Idle); + Init(); + glutMainLoop(); + return 0; +} diff --git a/progs/tests/yuvrect.c b/progs/tests/yuvrect.c new file mode 100644 index 00000000000..acef4060970 --- /dev/null +++ b/progs/tests/yuvrect.c @@ -0,0 +1,193 @@ +/* + * Test the GL_NV_texture_rectangle and GL_MESA_ycrcb_texture extensions. + * + * Brian Paul 13 September 2002 + */ + +#include +#include +#include +#include +#include +#define GL_GLEXT_PROTOTYPES +#include + +#include "../util/readtex.c" /* I know, this is a hack. */ + +#define TEXTURE_FILE "../images/girl.rgb" + +static GLfloat Xrot = 0, Yrot = 0, Zrot = 0; +static GLint ImgWidth, ImgHeight; +static GLushort *ImageYUV = NULL; + + +static void DrawObject(void) +{ + glBegin(GL_QUADS); + + glTexCoord2f(0, 0); + glVertex2f(-1.0, -1.0); + + glTexCoord2f(ImgWidth, 0); + glVertex2f(1.0, -1.0); + + glTexCoord2f(ImgWidth, ImgHeight); + glVertex2f(1.0, 1.0); + + glTexCoord2f(0, ImgHeight); + glVertex2f(-1.0, 1.0); + + glEnd(); +} + + +static void Display( void ) +{ + glClear( GL_COLOR_BUFFER_BIT ); + + glPushMatrix(); + glRotatef(Xrot, 1.0, 0.0, 0.0); + glRotatef(Yrot, 0.0, 1.0, 0.0); + glRotatef(Zrot, 0.0, 0.0, 1.0); + DrawObject(); + glPopMatrix(); + + glutSwapBuffers(); +} + + +static void Reshape( int width, int height ) +{ + glViewport( 0, 0, width, height ); + glMatrixMode( GL_PROJECTION ); + glLoadIdentity(); + glFrustum( -1.0, 1.0, -1.0, 1.0, 10.0, 100.0 ); + glMatrixMode( GL_MODELVIEW ); + glLoadIdentity(); + glTranslatef( 0.0, 0.0, -15.0 ); +} + + +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 ) +{ + float 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( int argc, char *argv[] ) +{ + GLuint texObj = 100; + const char *file; + + if (!glutExtensionSupported("GL_NV_texture_rectangle")) { + printf("Sorry, GL_NV_texture_rectangle is required\n"); + exit(0); + } + + if (!glutExtensionSupported("GL_MESA_ycbcr_texture")) { + printf("Sorry, GL_MESA_ycbcr_texture is required\n"); + exit(0); + } + + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + + glBindTexture(GL_TEXTURE_RECTANGLE_NV, texObj); +#ifdef LINEAR_FILTER + /* linear filtering looks much nicer but is much slower for Mesa */ + glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_MAG_FILTER, GL_LINEAR); +#else + glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_MAG_FILTER, GL_NEAREST); +#endif + + if (argc > 1) + file = argv[1]; + else + file = TEXTURE_FILE; + + ImageYUV = LoadYUVImage(file, &ImgWidth, &ImgHeight); + if (!ImageYUV) { + printf("Couldn't read %s\n", TEXTURE_FILE); + exit(0); + } + + printf("Image: %dx%d\n", ImgWidth, ImgHeight); + + glTexImage2D(GL_TEXTURE_RECTANGLE_NV, 0, + GL_YCBCR_MESA, ImgWidth, ImgHeight, 0, + GL_YCBCR_MESA, GL_UNSIGNED_SHORT_8_8_MESA, ImageYUV); + + assert(glGetError() == GL_NO_ERROR); + glTexSubImage2D(GL_TEXTURE_RECTANGLE_NV, 0, + 0, 0, ImgWidth, ImgHeight, + GL_YCBCR_MESA, GL_UNSIGNED_SHORT_8_8_MESA, ImageYUV); + + assert(glGetError() == GL_NO_ERROR); + + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + + glEnable(GL_TEXTURE_RECTANGLE_NV); + + glShadeModel(GL_FLAT); + glClearColor(0.3, 0.3, 0.4, 1.0); + + 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)); + } +} + + +int main( int argc, char *argv[] ) +{ + glutInit( &argc, argv ); + glutInitWindowSize( 300, 300 ); + glutInitWindowPosition( 0, 0 ); + glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE ); + glutCreateWindow(argv[0] ); + + Init( argc, argv ); + + glutReshapeFunc( Reshape ); + glutKeyboardFunc( Key ); + glutSpecialFunc( SpecialKey ); + glutDisplayFunc( Display ); + + glutMainLoop(); + return 0; +} diff --git a/progs/tests/yuvsquare.c b/progs/tests/yuvsquare.c new file mode 100644 index 00000000000..3601e7a31c7 --- /dev/null +++ b/progs/tests/yuvsquare.c @@ -0,0 +1,232 @@ +/* + * Test the GL_NV_texture_rectangle and GL_MESA_ycrcb_texture extensions. + * + * Brian Paul 13 September 2002 + */ + + +#include +#include +#include +#include +#define GL_GLEXT_PROTOTYPES +#include + +#include "../util/readtex.c" /* I know, this is a hack. */ + +#define TEXTURE_FILE "../images/tile.rgb" + +static GLfloat Xrot = 0, Yrot = 0, Zrot = 0; +static GLint ImgWidth, ImgHeight; +static GLushort *ImageYUV = NULL; +static GLubyte *ImageRGB = NULL; +static const GLuint yuvObj = 100; +static const GLuint rgbObj = 101; + + +static void DrawObject(void) +{ + glBegin(GL_QUADS); + + glTexCoord2f(0, 0); + glVertex2f(-1.0, -1.0); + + glTexCoord2f(1, 0); + glVertex2f(1.0, -1.0); + + glTexCoord2f(1, 1); + glVertex2f(1.0, 1.0); + + glTexCoord2f(0, 1); + glVertex2f(-1.0, 1.0); + + glEnd(); +} + + +static void Display( void ) +{ + glClear( GL_COLOR_BUFFER_BIT ); + + glPushMatrix(); + glTranslatef( -1.1, 0.0, -15.0 ); + glRotatef(Xrot, 1.0, 0.0, 0.0); + glRotatef(Yrot, 0.0, 1.0, 0.0); + glRotatef(Zrot, 0.0, 0.0, 1.0); + glBindTexture(GL_TEXTURE_2D, yuvObj); + DrawObject(); + glPopMatrix(); + + glPushMatrix(); + glTranslatef( 1.1, 0.0, -15.0 ); + glRotatef(Xrot, 1.0, 0.0, 0.0); + glRotatef(Yrot, 0.0, 1.0, 0.0); + glRotatef(Zrot, 0.0, 0.0, 1.0); + glBindTexture(GL_TEXTURE_2D, rgbObj); + DrawObject(); + glPopMatrix(); + + glutSwapBuffers(); +} + + +static void Reshape( int width, int height ) +{ + glViewport( 0, 0, width, height ); + glMatrixMode( GL_PROJECTION ); + glLoadIdentity(); + glFrustum( -1.1, 1.1, -1.1, 1.1, 10.0, 100.0 ); + glMatrixMode( GL_MODELVIEW ); + glLoadIdentity(); + glTranslatef( 0.0, 0.0, -15.0 ); +} + + +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 ) +{ + float 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(); +} + + +#define CLAMP( X, MIN, MAX ) ( (X)<(MIN) ? (MIN) : ((X)>(MAX) ? (MAX) : (X)) ) + + + +/* #define LINEAR_FILTER */ + +static void Init( int argc, char *argv[] ) +{ + const char *file; + GLenum format; + + if (!glutExtensionSupported("GL_MESA_ycbcr_texture")) { + printf("Sorry, GL_MESA_ycbcr_texture is required\n"); + exit(0); + } + + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + + if (argc > 1) + file = argv[1]; + else + file = TEXTURE_FILE; + + /* First load the texture as YCbCr. + */ + + glBindTexture(GL_TEXTURE_2D, yuvObj); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + + ImageYUV = LoadYUVImage(file, &ImgWidth, &ImgHeight ); + if (!ImageYUV) { + printf("Couldn't read %s\n", TEXTURE_FILE); + exit(0); + } + + printf("Image: %dx%d\n", ImgWidth, ImgHeight); + + + glTexImage2D(GL_TEXTURE_2D, 0, + GL_YCBCR_MESA, + ImgWidth, ImgHeight, 0, + GL_YCBCR_MESA, + GL_UNSIGNED_SHORT_8_8_MESA, ImageYUV); + + glEnable(GL_TEXTURE_2D); + + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + + + + /* Now load the texture as RGB. + */ + + glBindTexture(GL_TEXTURE_2D, rgbObj); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + + ImageRGB = LoadRGBImage(file, &ImgWidth, &ImgHeight, &format ); + if (!ImageRGB) { + printf("Couldn't read %s\n", TEXTURE_FILE); + exit(0); + } + + printf("Image: %dx%d\n", ImgWidth, ImgHeight); + + + glTexImage2D(GL_TEXTURE_2D, 0, + format, + ImgWidth, ImgHeight, 0, + format, + GL_UNSIGNED_BYTE, ImageRGB); + + glEnable(GL_TEXTURE_2D); + + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + + + + glShadeModel(GL_FLAT); + glClearColor(0.3, 0.3, 0.4, 1.0); + + 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)); + } + + printf( "Both images should appear the same.\n" ); +} + + +int main( int argc, char *argv[] ) +{ + glutInit( &argc, argv ); + glutInitWindowSize( 300, 300 ); + glutInitWindowPosition( 0, 0 ); + glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE ); + glutCreateWindow(argv[0] ); + + Init( argc, argv ); + + glutReshapeFunc( Reshape ); + glutKeyboardFunc( Key ); + glutSpecialFunc( SpecialKey ); + glutDisplayFunc( Display ); + + glutMainLoop(); + return 0; +} diff --git a/progs/tests/zreaddraw.c b/progs/tests/zreaddraw.c new file mode 100644 index 00000000000..e2dacbf7f2f --- /dev/null +++ b/progs/tests/zreaddraw.c @@ -0,0 +1,116 @@ +/* + * Test glRead/DrawPixels for GL_DEPTH_COMPONENT, with pixelzoom. + * + * Brian Paul + * 23 August 2003 + */ + +#include +#include +#include +#define GL_GLEXT_PROTOTYPES +#include + +static GLint WinWidth = 500, WinHeight = 500; + + +static void Display(void) +{ + GLfloat depth[100 * 100]; + GLfloat depth2[400 * 400]; + GLfloat min, max; + int i; + + glClearColor(0.5, 0.5, 0.5, 0); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + /* draw a sphere */ + glViewport(0, 0, 100, 100); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-1, 1, -1, 1, -1, 0); /* clip away back half of sphere */ + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glutSolidSphere(1.0, 20, 10); + + /* read the depth image */ + glReadPixels(0, 0, 100, 100, GL_DEPTH_COMPONENT, GL_FLOAT, depth); + min = max = depth[0]; + for (i = 1; i < 100 * 100; i++) { + if (depth[i] < min) + min = depth[i]; + if (depth[i] > max) + max = depth[i]; + } + printf("Depth value range: [%f, %f]\n", min, max); + + /* draw depth image with scaling (into z buffer) */ + glPixelZoom(4.0, 4.0); + glWindowPos2i(100, 0); + glDrawPixels(100, 100, GL_DEPTH_COMPONENT, GL_FLOAT, depth); + + /* read back scaled depth image */ + glReadPixels(100, 0, 400, 400, GL_DEPTH_COMPONENT, GL_FLOAT, depth2); + /* draw as luminance */ + glPixelZoom(1.0, 1.0); + glDrawPixels(400, 400, GL_LUMINANCE, GL_FLOAT, depth2); + + glutSwapBuffers(); +} + + +static void Reshape(int width, int height) +{ + WinWidth = width; + WinHeight = 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 Init(void) +{ + const GLfloat blue[4] = {.1, .1, 1.0, 0.0}; + const GLfloat gray[4] = {0.2, 0.2, 0.2, 1.0}; + const GLfloat white[4] = {1.0, 1.0, 1.0, 1.0}; + const GLfloat pos[4] = {0, 0, 10, 0}; + + printf("GL_VERSION = %s\n", (char *) glGetString(GL_VERSION)); + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, blue); + glLightfv(GL_LIGHT0, GL_AMBIENT, gray); + glLightfv(GL_LIGHT0, GL_DIFFUSE, white); + glLightfv(GL_LIGHT0, GL_POSITION, pos); + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + glEnable(GL_DEPTH_TEST); +} + + +int main(int argc, char *argv[]) +{ + glutInit(&argc, argv); + glutInitWindowPosition(0, 0); + glutInitWindowSize(WinWidth, WinHeight); + glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE); + glutCreateWindow(argv[0]); + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Display); + Init(); + glutMainLoop(); + return 0; +} diff --git a/progs/util/README b/progs/util/README index 8c143142e41..351a8f0765e 100644 --- a/progs/util/README +++ b/progs/util/README @@ -19,4 +19,4 @@ imagesgi.cpp,.h - read SGI image files more to come... ---------------------------------------------------------------------- -$Id: README,v 1.1.1.1 1999/08/19 00:55:42 jtg Exp $ +$Id: README,v 1.1.1.1 1999-08-19 00:55:42 jtg Exp $ diff --git a/progs/util/descrip.mms b/progs/util/descrip.mms new file mode 100644 index 00000000000..21dec4b9be4 --- /dev/null +++ b/progs/util/descrip.mms @@ -0,0 +1,42 @@ +# Makefile for GLUT-based demo programs for VMS +# contributed by Jouk Jansen joukj@crys.chem.uva.nl + + +.first + define gl [--.include.gl] + +.include [--]mms-config. + +##### MACROS ##### + +INCDIR = ([--.include],[-.util]) +CFLAGS = /include=$(INCDIR)/prefix=all/name=(as_is,short)/float=ieee/ieee=denorm + +.ifdef SHARE +GL_LIBS = $(XLIBS) +LIB_DEP = [--.lib]$(GL_SHAR) [--.lib]$(GLU_SHAR) [--.lib]$(GLUT_SHAR) +.else +GL_LIBS = [--.lib]libGLUT/l,libMesaGLU/l,libMesaGL/l,$(XLIBS) +LIB_DEP = [--.lib]$(GL_LIB) [--.lib]$(GLU_LIB) [--.lib]$(GLUT_LIB) +.endif + + +OBJS =readtex.obj,showbuffer.obj + + +##### RULES ##### +.obj.exe : + cxxlink $(MMS$TARGET_NAME),$(GL_LIBS) + +##### TARGETS ##### +default : + $(MMS)$(MMSQUALIFIERS) $(OBJS) + +clean : + delete *.obj;* + +realclean : + delete *.obj;* + +readtex.obj : readtex.c +showbuffer.obj : showbuffer.c diff --git a/progs/util/glstate.c b/progs/util/glstate.c index fe35c3d3beb..d8c3ff8d682 100644 --- a/progs/util/glstate.c +++ b/progs/util/glstate.c @@ -1,4 +1,4 @@ -/* $Id: glstate.c,v 1.1.1.1 1999/08/19 00:55:42 jtg Exp $ */ +/* $Id: glstate.c,v 1.1.1.1 1999-08-19 00:55:42 jtg Exp $ */ /* * Print GL state information (for debugging) @@ -22,7 +22,7 @@ /* * $Log: glstate.c,v $ - * Revision 1.1.1.1 1999/08/19 00:55:42 jtg + * Revision 1.1.1.1 1999-08-19 00:55:42 jtg * Imported sources * * Revision 1.4 1999/06/19 01:36:43 brianp diff --git a/progs/util/glstate.h b/progs/util/glstate.h index 75f0238c591..6d9424014ce 100644 --- a/progs/util/glstate.h +++ b/progs/util/glstate.h @@ -1,4 +1,4 @@ -/* $Id: glstate.h,v 1.1.1.1 1999/08/19 00:55:42 jtg Exp $ */ +/* $Id: glstate.h,v 1.1.1.1 1999-08-19 00:55:42 jtg Exp $ */ /* * Print GL state information (for debugging) @@ -22,7 +22,7 @@ /* * $Log: glstate.h,v $ - * Revision 1.1.1.1 1999/08/19 00:55:42 jtg + * Revision 1.1.1.1 1999-08-19 00:55:42 jtg * Imported sources * * Revision 1.2 1999/06/19 01:36:43 brianp diff --git a/progs/util/glutskel.c b/progs/util/glutskel.c index b203a507a4c..381e12e5f88 100644 --- a/progs/util/glutskel.c +++ b/progs/util/glutskel.c @@ -1,4 +1,4 @@ -/* $Id: glutskel.c,v 1.2 2004/04/22 00:47:28 brianp Exp $ */ +/* $Id: glutskel.c,v 1.2 2004-04-22 00:47:28 brianp Exp $ */ /* * A skeleton/template GLUT program @@ -9,7 +9,7 @@ /* * $Log: glutskel.c,v $ - * Revision 1.2 2004/04/22 00:47:28 brianp + * Revision 1.2 2004-04-22 00:47:28 brianp * minor clean-ups * * Revision 1.1.1.1 1999/08/19 00:55:42 jtg diff --git a/progs/util/imagesgi.cpp b/progs/util/imagesgi.cpp new file mode 100644 index 00000000000..f5128aabec0 --- /dev/null +++ b/progs/util/imagesgi.cpp @@ -0,0 +1,369 @@ +/****************************************************************************** +** Filename : imageSgi.cpp +** UNCLASSIFIED +** +** Description : Utility to read SGI image format files. This code was +** originally a SGI image loading utility provided with the +** Mesa 3D library @ http://www.mesa3d.org by Brain Paul. +** This has been extended to read all SGI image formats +** (e.g. INT, INTA, RGB, RGBA). +** +** Revision History: +** Date Name Description +** 06/07/99 BRC Initial Release +** +** Note: +** +** The SGI Image Data (if not RLE) +** +** If the image is stored verbatim (without RLE), then image data directly +** follows the 512 byte header. The data for each scanline of the first +** channel is written first. If the image has more than 1 channel, all +** the data for the first channel is written, followed by the remaining +** channels. If the BPC value is 1, then each scanline is written as XSIZE +** bytes. If the BPC value is 2, then each scanline is written as XSIZE +** shorts. These shorts are stored in the byte order described above. +** +******************************************************************************/ +#define __IMAGESGI_CPP + +#include "imagesgi.h" + +#include +#include +#include +#include +#include + +struct sImageSgiRaw +{ + struct sImageSgiHeader header; + unsigned char *chan0; + unsigned char *chan1; + unsigned char *chan2; + unsigned char *chan3; + unsigned int *rowStart; + int *rowSize; +}; + +// Static routines +static struct sImageSgiRaw *ImageSgiRawOpen(char const * const fileName); +static void ImageSgiRawClose(struct sImageSgiRaw *raw); +static void ImageSgiRawGetRow(struct sImageSgiRaw *raw, unsigned char *buf, + int y, int z); +static void ImageSgiRawGetData(struct sImageSgiRaw *raw, struct sImageSgi +*final); +static void *SwitchEndian16(void *value); +static void *SwitchEndian32(void *value); + +// Static variables +FILE *mFp = NULL; +unsigned char *mChanTmp = NULL; + + +/*****************************************************************************/ +struct sImageSgi *ImageSgiOpen(char const * const fileName) +{ + struct sImageSgiRaw *raw = NULL; + struct sImageSgi *final = NULL; + + raw = ImageSgiRawOpen(fileName); + final = new struct sImageSgi; + + assert(final); + if(final) + { + final->header = raw->header; + final->data = NULL; + ImageSgiRawGetData(raw, final); + ImageSgiRawClose(raw); + } + + return final; +} // ImageSgiRawOpen + + +/*****************************************************************************/ +void ImageSgiClose(struct sImageSgi *image) +{ + + if(image) + { + if(image->data) + delete[] image->data; + image->data = NULL; + delete image; + } + image = NULL; + + return; +} // ImageSgiClose + + +/*****************************************************************************/ +static struct sImageSgiRaw *ImageSgiRawOpen(char const * const fileName) +{ + struct sImageSgiRaw *raw = NULL; + int x; + int i; + bool swapFlag = false; + union + { + int testWord; + char testByte[4]; + } endianTest; + endianTest.testWord = 1; + + // Determine endianess of platform. + if(endianTest.testByte[0] == 1) + swapFlag = true; + else + swapFlag = false; + + raw = new struct sImageSgiRaw; + + assert(raw); + if(raw) + { + raw->chan0 = NULL; + raw->chan1 = NULL; + raw->chan2 = NULL; + raw->chan3 = NULL; + raw->rowStart = NULL; + raw->rowSize = NULL; + mFp = fopen(fileName, "rb"); + assert(mFp); + + fread(&raw->header, sizeof(struct sImageSgiHeader), 1, mFp); + if(swapFlag == true) + { + SwitchEndian16(&raw->header.magic); + SwitchEndian16(&raw->header.type); + SwitchEndian16(&raw->header.dim); + SwitchEndian16(&raw->header.xsize); + SwitchEndian16(&raw->header.ysize); + SwitchEndian16(&raw->header.zsize); + } + + mChanTmp = new unsigned char[raw->header.xsize * raw->header.ysize]; + assert(mChanTmp); + switch(raw->header.zsize) + { + case 4: + raw->chan3 = new unsigned char[raw->header.xsize * +raw->header.ysize]; + assert(raw->chan3); + case 3: + raw->chan2 = new unsigned char[raw->header.xsize * +raw->header.ysize]; + assert(raw->chan2); + case 2: + raw->chan1 = new unsigned char[raw->header.xsize * +raw->header.ysize]; + assert(raw->chan1); + case 1: + raw->chan0 = new unsigned char[raw->header.xsize * +raw->header.ysize]; + assert(raw->chan0); + } + + if(raw->header.type == IMAGE_SGI_TYPE_RLE) + { + x = raw->header.ysize * raw->header.zsize * sizeof(unsigned int); + raw->rowStart = new unsigned int[x]; + raw->rowSize = new int[x]; + + fseek(mFp, sizeof(struct sImageSgiHeader), SEEK_SET); + fread(raw->rowStart, 1, x, mFp); + fread(raw->rowSize, 1, x, mFp); + + if(swapFlag == true) + { + for(i=0; irowStart[i]); + for(i=0; irowSize[i]); + } + + } + + } + + return raw; +} // ImageSgiRawOpen + + +/*****************************************************************************/ +static void ImageSgiRawClose(struct sImageSgiRaw *raw) +{ + + fclose(mFp); + mFp = NULL; + + if(mChanTmp) + delete[] mChanTmp; + mChanTmp = NULL; + + if(raw->chan0) + delete[] raw->chan0; + raw->chan0 = NULL; + + if(raw->chan1) + delete[] raw->chan1; + raw->chan1 = NULL; + + if(raw->chan2) + delete[] raw->chan2; + raw->chan2 = NULL; + + if(raw->chan3) + delete[] raw->chan3; + raw->chan3 = NULL; + + if(raw) + delete raw; + raw = NULL; + + return; +} // ImageSgiRawClose + + +/*****************************************************************************/ +static void ImageSgiRawGetRow(struct sImageSgiRaw *raw, unsigned char *buf, + int y, int z) +{ + unsigned char *iPtr = NULL; + unsigned char *oPtr = NULL; + unsigned char pixel; + int count; + + if((raw->header.type & 0xFF00) == 0x0100) + { + fseek(mFp, raw->rowStart[y+z*raw->header.ysize], SEEK_SET); + fread(mChanTmp, 1, (unsigned int)raw->rowSize[y+z*raw->header.ysize], +mFp); + iPtr = mChanTmp; + oPtr = buf; + while(1) + { + pixel = *iPtr++; + count = (int)(pixel & 0x7F); + if(!count) + { + return; + } + if (pixel & 0x80) + { + while (count--) + { + *oPtr++ = *iPtr++; + } + } + else + { + pixel = *iPtr++; + while (count--) + { + *oPtr++ = pixel; + } + } + } + } + else + { + fseek(mFp, + sizeof(struct sImageSgiHeader)+(y*raw->header.xsize) + + (z*raw->header.xsize*raw->header.ysize), + SEEK_SET); + fread(buf, 1, raw->header.xsize, mFp); + } + + return; +} // ImageSgiRawGetRow + + +/*****************************************************************************/ +static void ImageSgiRawGetData(struct sImageSgiRaw *raw, struct sImageSgi +*final) +{ + unsigned char *ptr = NULL; + int i, j; + + final->data = + new unsigned +char[raw->header.xsize*raw->header.ysize*raw->header.zsize]; + assert(final->data); + + ptr = final->data; + for(i=0; iheader.ysize; i++) + { + switch(raw->header.zsize) + { + case 1: + ImageSgiRawGetRow(raw, raw->chan0, i, 0); + for(j=0; jheader.xsize; j++) + *(ptr++) = raw->chan0[j]; + break; + case 2: + ImageSgiRawGetRow(raw, raw->chan0, i, 0); + ImageSgiRawGetRow(raw, raw->chan1, i, 1); + for(j=0; jheader.xsize; j++) + { + *(ptr++) = raw->chan0[j]; + *(ptr++) = raw->chan1[j]; + } + break; + case 3: + ImageSgiRawGetRow(raw, raw->chan0, i, 0); + ImageSgiRawGetRow(raw, raw->chan1, i, 1); + ImageSgiRawGetRow(raw, raw->chan2, i, 2); + for(j=0; jheader.xsize; j++) + { + *(ptr++) = raw->chan0[j]; + *(ptr++) = raw->chan1[j]; + *(ptr++) = raw->chan2[j]; + } + break; + case 4: + ImageSgiRawGetRow(raw, raw->chan0, i, 0); + ImageSgiRawGetRow(raw, raw->chan1, i, 1); + ImageSgiRawGetRow(raw, raw->chan2, i, 2); + ImageSgiRawGetRow(raw, raw->chan3, i, 3); + for(j=0; jheader.xsize; j++) + { + *(ptr++) = raw->chan0[j]; + *(ptr++) = raw->chan1[j]; + *(ptr++) = raw->chan2[j]; + *(ptr++) = raw->chan3[j]; + } + break; + } + } + + return; +} // ImageSgiRawGetData + + +/*****************************************************************************/ +static void *SwitchEndian16(void *value) +{ + short value16 = *(short *) value; + value16 = ((value16 & 0xff00) >> 8L) + + ((value16 & 0x00ff) << 8L); + *(short *)value = value16; + return value; +} // SwitchEndian16 + + +/*****************************************************************************/ +static void *SwitchEndian32(void *value) +{ + int value32 = *(int *) value; + value32 = ((value32 & 0xff000000) >> 24L) + + ((value32 & 0x00ff0000) >> 8) + + ((value32 & 0x0000ff00) << 8) + + ((value32 & 0x000000ff) << 24L); + *(int *)value = value32; + return value; +} // SwitchEndian32 + diff --git a/progs/util/sampleMakefile b/progs/util/sampleMakefile index a7e510f66de..c2569e6041f 100644 --- a/progs/util/sampleMakefile +++ b/progs/util/sampleMakefile @@ -1,4 +1,4 @@ -# $Id: sampleMakefile,v 1.1.1.1 1999/08/19 00:55:42 jtg Exp $ +# $Id: sampleMakefile,v 1.1.1.1 1999-08-19 00:55:42 jtg Exp $ # Sample makefile for compiling OpenGL/Mesa applications on Unix. # This example assumes Linux with gcc. @@ -6,7 +6,7 @@ # This makefile is in the public domain # $Log: sampleMakefile,v $ -# Revision 1.1.1.1 1999/08/19 00:55:42 jtg +# Revision 1.1.1.1 1999-08-19 00:55:42 jtg # Imported sources # # Revision 1.1 1999/02/24 05:20:45 brianp diff --git a/progs/vp/Makefile b/progs/vp/Makefile new file mode 100644 index 00000000000..c3faeb5b602 --- /dev/null +++ b/progs/vp/Makefile @@ -0,0 +1,53 @@ +# progs/tests/Makefile + + +# These programs aren't intended to be included with the normal distro. +# They're not too interesting but they're good for testing. + +TOP = ../.. +include $(TOP)/configs/current + + +LIBS = $(APP_LIB_DEPS) + +SOURCES = \ + vp-tris.c + + + +PROGS = $(SOURCES:%.c=%) + +INCLUDES = -I. -I$(TOP)/include -I../samples + + +##### RULES ##### + +.SUFFIXES: +.SUFFIXES: .c + +.c: + $(CC) $(INCLUDES) $(CFLAGS) $< $(LIBS) -o $@ + +.c.o: + $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ + +.S.o: + $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ + + +##### TARGETS ##### + +default: $(PROGS) + +clean: + rm -f $(PROGS) + rm -f *.o + rm -f getproclist.h + + + + + +# Emacs tags +tags: + etags `find . -name \*.[ch]` `find ../include` diff --git a/progs/vp/abs.txt b/progs/vp/abs.txt new file mode 100644 index 00000000000..cd00952e349 --- /dev/null +++ b/progs/vp/abs.txt @@ -0,0 +1,7 @@ +!!ARBvp1.0 +TEMP R0; +SUB R0, {0.5}.x, vertex.color; +ABS result.color, R0; +MOV result.position, vertex.position; +END + diff --git a/progs/vp/add.txt b/progs/vp/add.txt new file mode 100644 index 00000000000..4094cd448dc --- /dev/null +++ b/progs/vp/add.txt @@ -0,0 +1,6 @@ +!!ARBvp1.0 +TEMP R0; +ADD R0, vertex.color, vertex.color; +ADD result.color, R0, R0; +MOV result.position, vertex.position; +END diff --git a/progs/vp/arl.txt b/progs/vp/arl.txt new file mode 100644 index 00000000000..a262b0149c6 --- /dev/null +++ b/progs/vp/arl.txt @@ -0,0 +1,9 @@ +!!ARBvp1.0 +PARAM arr[5] = { {0,1,2,3}, {4,5,6,7}, {8,9,10,11}, {12,13,14,14}, {16,17,18,19} }; +ADDRESS addr; +TEMP R0; +MAD R0, {5.0}.x, vertex.color, {2.0}.x; +ARL addr.x, R0.x; +MUL result.color, arr[addr.x-2], {.07}.x; +MOV result.position, vertex.position; +END diff --git a/progs/vp/dp3.txt b/progs/vp/dp3.txt new file mode 100644 index 00000000000..8336bd3dd8e --- /dev/null +++ b/progs/vp/dp3.txt @@ -0,0 +1,5 @@ +!!ARBvp1.0 +DP3 result.color, vertex.color, vertex.color; +MOV result.position, vertex.position; +END + diff --git a/progs/vp/dp4.txt b/progs/vp/dp4.txt new file mode 100644 index 00000000000..70505a494c5 --- /dev/null +++ b/progs/vp/dp4.txt @@ -0,0 +1,5 @@ +!!ARBvp1.0 +DP4 result.color, vertex.color.xxxx, vertex.color; +MOV result.position, vertex.position; +END + diff --git a/progs/vp/dph.txt b/progs/vp/dph.txt new file mode 100644 index 00000000000..c7cab1384dd --- /dev/null +++ b/progs/vp/dph.txt @@ -0,0 +1,5 @@ +!!ARBvp1.0 +DPH result.color, vertex.color, vertex.color; +MOV result.position, vertex.position; +END + diff --git a/progs/vp/dst.txt b/progs/vp/dst.txt new file mode 100644 index 00000000000..03613c0eece --- /dev/null +++ b/progs/vp/dst.txt @@ -0,0 +1,5 @@ +!!ARBvp1.0 +DST result.color, vertex.color, vertex.color; +MOV result.position, vertex.position; +END + diff --git a/progs/vp/ex2.txt b/progs/vp/ex2.txt new file mode 100644 index 00000000000..bbef67bbb8a --- /dev/null +++ b/progs/vp/ex2.txt @@ -0,0 +1,6 @@ +!!ARBvp1.0 +TEMP R0; +EX2 R0, vertex.color.x; +SUB result.color, R0, {1.0}.x; +MOV result.position, vertex.position; +END diff --git a/progs/vp/flr.txt b/progs/vp/flr.txt new file mode 100644 index 00000000000..c33280da978 --- /dev/null +++ b/progs/vp/flr.txt @@ -0,0 +1,6 @@ +!!ARBvp1.0 +TEMP R0; +ADD R0, vertex.color, {0.5}.x; +FLR result.color, R0; +MOV result.position, vertex.position; +END diff --git a/progs/vp/frc.txt b/progs/vp/frc.txt new file mode 100644 index 00000000000..d8e72b60cc7 --- /dev/null +++ b/progs/vp/frc.txt @@ -0,0 +1,6 @@ +!!ARBvp1.0 +TEMP R0; +MUL R0, vertex.color, {3.0}.x; +FRC result.color, R0; +MOV result.position, vertex.position; +END diff --git a/progs/vp/lg2.txt b/progs/vp/lg2.txt new file mode 100644 index 00000000000..2f59b993a41 --- /dev/null +++ b/progs/vp/lg2.txt @@ -0,0 +1,6 @@ +!!ARBvp1.0 +TEMP R0; +MUL R0, vertex.color, {4.0}.x; +LG2 result.color, R0.x; +MOV result.position, vertex.position; +END diff --git a/progs/vp/lit.txt b/progs/vp/lit.txt new file mode 100644 index 00000000000..65705b41705 --- /dev/null +++ b/progs/vp/lit.txt @@ -0,0 +1,6 @@ +!!ARBvp1.0 +TEMP R0; +SUB R0, {0.5}.x, vertex.color; +LIT result.color, R0; +MOV result.position, vertex.position; +END diff --git a/progs/vp/mad.txt b/progs/vp/mad.txt new file mode 100644 index 00000000000..0c9ed6c8b7f --- /dev/null +++ b/progs/vp/mad.txt @@ -0,0 +1,5 @@ +!!ARBvp1.0 +MAD result.color, vertex.color.z, {1,0,0,1}, vertex.color; +MOV result.position, vertex.position; +END + diff --git a/progs/vp/max.txt b/progs/vp/max.txt new file mode 100644 index 00000000000..6747ca57277 --- /dev/null +++ b/progs/vp/max.txt @@ -0,0 +1,5 @@ +!!ARBvp1.0 +MAX result.color, {0.5}.x, vertex.color; +MOV result.position, vertex.position; +END + diff --git a/progs/vp/min.txt b/progs/vp/min.txt new file mode 100644 index 00000000000..2adc872ed9c --- /dev/null +++ b/progs/vp/min.txt @@ -0,0 +1,5 @@ +!!ARBvp1.0 +MIN result.color, {0.5}.x, vertex.color; +MOV result.position, vertex.position; +END + diff --git a/progs/vp/mov.txt b/progs/vp/mov.txt new file mode 100644 index 00000000000..9ce1a453067 --- /dev/null +++ b/progs/vp/mov.txt @@ -0,0 +1,5 @@ +!!ARBvp1.0 +MOV result.color, vertex.color; +MOV result.position, vertex.position; +END + diff --git a/progs/vp/mul.txt b/progs/vp/mul.txt new file mode 100644 index 00000000000..e479cdb8543 --- /dev/null +++ b/progs/vp/mul.txt @@ -0,0 +1,5 @@ +!!ARBvp1.0 +MUL result.color, vertex.color, vertex.color; +MOV result.position, vertex.position; +END + diff --git a/progs/vp/pow.txt b/progs/vp/pow.txt new file mode 100644 index 00000000000..512412997de --- /dev/null +++ b/progs/vp/pow.txt @@ -0,0 +1,5 @@ +!!ARBvp1.0 +POW result.color, vertex.color.x, vertex.color.y; +MOV result.position, vertex.position; +END + diff --git a/progs/vp/rcp.txt b/progs/vp/rcp.txt new file mode 100644 index 00000000000..e16292bd00a --- /dev/null +++ b/progs/vp/rcp.txt @@ -0,0 +1,7 @@ +!!ARBvp1.0 +TEMP R0; +ADD R0, vertex.color.x, vertex.color.x; +RCP result.color, R0.x; +MOV result.position, vertex.position; +END + diff --git a/progs/vp/rsq.txt b/progs/vp/rsq.txt new file mode 100644 index 00000000000..3e3f3251ee0 --- /dev/null +++ b/progs/vp/rsq.txt @@ -0,0 +1,7 @@ +!!ARBvp1.0 +TEMP R0; +MUL R0, vertex.color, {3.0}.x; +RSQ result.color, R0.x; +MOV result.position, vertex.position; +END + diff --git a/progs/vp/sge.txt b/progs/vp/sge.txt new file mode 100644 index 00000000000..3fa82e5d5ea --- /dev/null +++ b/progs/vp/sge.txt @@ -0,0 +1,5 @@ +!!ARBvp1.0 +SGE result.color, {0.5}.x, vertex.color; +MOV result.position, vertex.position; +END + diff --git a/progs/vp/slt.txt b/progs/vp/slt.txt new file mode 100644 index 00000000000..6bf8ffa775d --- /dev/null +++ b/progs/vp/slt.txt @@ -0,0 +1,5 @@ +!!ARBvp1.0 +SLT result.color, {0.5}.x, vertex.color; +MOV result.position, vertex.position; +END + diff --git a/progs/vp/sub.txt b/progs/vp/sub.txt new file mode 100644 index 00000000000..a58ab101bcd --- /dev/null +++ b/progs/vp/sub.txt @@ -0,0 +1,5 @@ +!!ARBvp1.0 +SUB result.color, vertex.color.yzxw, vertex.color; +MOV result.position, vertex.position; +END + diff --git a/progs/vp/swz.txt b/progs/vp/swz.txt new file mode 100644 index 00000000000..92c58089b1a --- /dev/null +++ b/progs/vp/swz.txt @@ -0,0 +1,5 @@ +!!ARBvp1.0 +MOV result.color, vertex.color.xxzx; +MOV result.position, vertex.position; +END + diff --git a/progs/vp/swz2.txt b/progs/vp/swz2.txt new file mode 100644 index 00000000000..84c78db49f6 --- /dev/null +++ b/progs/vp/swz2.txt @@ -0,0 +1,5 @@ +!!ARBvp1.0 +SWZ result.color, vertex.color, 1,x,y,z; +MOV result.position, vertex.position; +END + diff --git a/progs/vp/vp-tris.c b/progs/vp/vp-tris.c new file mode 100644 index 00000000000..5dbe5ac8359 --- /dev/null +++ b/progs/vp/vp-tris.c @@ -0,0 +1,216 @@ +/* Test glGenProgramsNV(), glIsProgramNV(), glLoadProgramNV() */ + +#include +#include +#include +#include +#include +#define GL_GLEXT_PROTOTYPES +#include + +static const char *filename = NULL; +static GLuint nr_steps = 4; + +static void usage( char *name ) +{ + fprintf( stderr, "usage: %s [ options ] shader_filename\n", name ); + fprintf( stderr, "\n" ); + fprintf( stderr, "options:\n" ); + fprintf( stderr, " -f flat shaded\n" ); + fprintf( stderr, " -nNr subdivision steps\n" ); +} + + +static void args(int argc, char *argv[]) +{ + GLint i; + + for (i = 1; i < argc; i++) { + if (strncmp(argv[i], "-n", 2) == 0) { + nr_steps = atoi((argv[i]) + 2); + } + else if (strcmp(argv[i], "-f") == 0) { + glShadeModel(GL_FLAT); + } + else if (i == argc - 1) { + filename = argv[i]; + } + else { + usage(argv[0]); + exit(1); + } + } + + if (!filename) { + usage(argv[0]); + exit(1); + } +} + + + +static void Init( void ) +{ + GLint errno; + GLuint prognum; + char buf[4096]; + GLuint sz; + FILE *f; + + if ((f = fopen(filename, "r")) == NULL) { + fprintf(stderr, "couldn't open %s\n", filename); + exit(1); + } + + sz = fread(buf, 1, sizeof(buf), f); + if (!feof(f)) { + fprintf(stderr, "file too long\n"); + exit(1); + } + + fprintf(stderr, "%.*s\n", sz, buf); + + glGenProgramsARB(1, &prognum); + + glBindProgramARB(GL_VERTEX_PROGRAM_ARB, prognum); + glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + sz, (const GLubyte *) buf); + + errno = glGetError(); + printf("glGetError = %d\n", errno); + if (errno != GL_NO_ERROR) + { + GLint errorpos; + + glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errorpos); + printf("errorpos: %d\n", errorpos); + printf("%s\n", (char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + } + assert(glIsProgramARB(prognum)); +} + + +union vert { + struct { + GLfloat color[3]; + GLfloat pos[3]; + } v; + GLfloat f[6]; +}; + +static void make_midpoint( union vert *out, + const union vert *v0, + const union vert *v1) +{ + int i; + for (i = 0; i < 6; i++) + out->f[i] = v0->f[i] + .5 * (v1->f[i] - v0->f[i]); +} + +static void subdiv( union vert *v0, + union vert *v1, + union vert *v2, + GLuint depth ) +{ + if (depth == 0) { + glColor3fv(v0->v.color); + glVertex3fv(v0->v.pos); + glColor3fv(v1->v.color); + glVertex3fv(v1->v.pos); + glColor3fv(v2->v.color); + glVertex3fv(v2->v.pos); + } + else { + union vert m[3]; + + make_midpoint(&m[0], v0, v1); + make_midpoint(&m[1], v1, v2); + make_midpoint(&m[2], v2, v0); + + subdiv(&m[0], &m[2], v0, depth-1); + subdiv(&m[1], &m[0], v1, depth-1); + subdiv(&m[2], &m[1], v2, depth-1); + subdiv(&m[0], &m[1], &m[2], depth-1); + } +} + +/** Assignment */ +#define ASSIGN_3V( V, V0, V1, V2 ) \ +do { \ + V[0] = V0; \ + V[1] = V1; \ + V[2] = V2; \ +} while(0) + +static void Display( void ) +{ + glClearColor(0.3, 0.3, 0.3, 1); + glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); + + glEnable(GL_VERTEX_PROGRAM_NV); + + glBegin(GL_TRIANGLES); + + + { + union vert v[3]; + + ASSIGN_3V(v[0].v.color, 0,0,1); + ASSIGN_3V(v[0].v.pos, 0.9, -0.9, 0.0); + ASSIGN_3V(v[1].v.color, 1,0,0); + ASSIGN_3V(v[1].v.pos, 0.9, 0.9, 0.0); + ASSIGN_3V(v[2].v.color, 0,1,0); + ASSIGN_3V(v[2].v.pos, -0.9, 0, 0.0); + + subdiv(&v[0], &v[1], &v[2], nr_steps); + } + + glEnd(); + + + glFlush(); +} + + +static void Reshape( int width, int height ) +{ + glViewport( 0, 0, width, height ); + glMatrixMode( GL_PROJECTION ); + glLoadIdentity(); + glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0); + glMatrixMode( GL_MODELVIEW ); + glLoadIdentity(); + /*glTranslatef( 0.0, 0.0, -15.0 );*/ +} + + +static void Key( unsigned char key, int x, int y ) +{ + (void) x; + (void) y; + switch (key) { + case 27: + exit(0); + break; + } + glutPostRedisplay(); +} + + + + +int main( int argc, char *argv[] ) +{ + glutInit( &argc, argv ); + glutInitWindowPosition( 0, 0 ); + glutInitWindowSize( 250, 250 ); + glutInitDisplayMode( GLUT_RGB | GLUT_SINGLE | GLUT_DEPTH ); + glutCreateWindow(argv[0]); + glutReshapeFunc( Reshape ); + glutKeyboardFunc( Key ); + glutDisplayFunc( Display ); + args( argc, argv ); + Init(); + glutMainLoop(); + return 0; +} diff --git a/progs/vp/xpd.txt b/progs/vp/xpd.txt new file mode 100644 index 00000000000..b8818ebc60e --- /dev/null +++ b/progs/vp/xpd.txt @@ -0,0 +1,5 @@ +!!ARBvp1.0 +XPD result.color, vertex.color, {2,2,2,0}; +MOV result.position, vertex.position; +END + diff --git a/progs/windml/Makefile.ugl b/progs/windml/Makefile.ugl new file mode 100644 index 00000000000..90b0b29bc82 --- /dev/null +++ b/progs/windml/Makefile.ugl @@ -0,0 +1,68 @@ +# Mesa 3-D graphics library +# Version: 3.5 +# +# Copyright (C) 2001 Wind River Systems, Inc + +# The MIT License +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, including without limitation +# the rights to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to whom the +# Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +# DEALINGS IN THE SOFTWARE. + +# Makefile for UGL/Mesa demos + +DEMO_SOURCES = readtex.c uglaccum.c uglalldemos.c uglbounce.c uglcube.c \ +ugldrawpix.c uglflip.c uglgears.c uglicotorus.c uglline.c uglolympic.c \ +uglpoint.c uglstencil.c uglteapot.c ugltexcube.c ugltexcyl.c +#win2d3d/winRoot.c win2d3d/winBall.c win2d3d/winPuzzle.c win2d3d/winHello.c \ +#win2d3d/winImage.c win2d3d/winGears.c + +DEMO_OBJECTS = $(DEMO_SOURCES:.c=.o) + +SOURCES = $(DEMO_SOURCES) + +include ../rules.windml + +##### TARGETS ##### + +all: depend.$(CPU)$(TOOL) $(DEMO_OBJECTS) + +depend.$(CPU)$(TOOL): +ifeq ($(WIND_HOST_TYPE),x86-win32) + @ $(RM) $@ + @ $(ECHO) Creating depend.$(CPU)$(TOOL) +ifneq ($(SOURCES),) + @ for %f in ($(SOURCES)) do \ + $(CC) -MM $(CFLAGS) %f >>$@ +endif +else +Makefile + @ $(RM) $@ + @ $(ECHO) "Creating depend.$(CPU)$(TOOL)" +ifneq ($(SOURCES),) + @ for FILE in $(filter-out $(NODEPENDOBJS), $(SOURCES)); \ + do \ + $(CC) -MM $(CFLAGS) $$FILE \ + | $(TCL) $(BIN_DIR)/depend.tcl $(TGT_DIR) >>$@; \ + done +endif +endif + +.PHONY = clean + +clean: + $(RM) $(DEMO_OBJECTS) + $(RM) depend.$(CPU)$(TOOL) diff --git a/progs/windml/readtex.c b/progs/windml/readtex.c new file mode 100644 index 00000000000..659c49de8de --- /dev/null +++ b/progs/windml/readtex.c @@ -0,0 +1,365 @@ +/* readtex.c */ + +/* + * Read an SGI .rgb image file and generate a mipmap texture set. + * Much of this code was borrowed from SGI's tk OpenGL toolkit. + */ + +#include +#include +#include +#include +#include +#include "../util/readtex.h" + + +#ifndef SEEK_SET +# define SEEK_SET 0 +#endif + + +/* +** RGB Image Structure +*/ + +typedef struct _TK_RGBImageRec { + GLint sizeX, sizeY; + GLint components; + unsigned char *data; +} TK_RGBImageRec; + + + +/******************************************************************************/ + +typedef struct _rawImageRec { + unsigned short imagic; + unsigned short type; + unsigned short dim; + unsigned short sizeX, sizeY, sizeZ; + unsigned long min, max; + unsigned long wasteBytes; + char name[80]; + unsigned long colorMap; + FILE *file; + unsigned char *tmp, *tmpR, *tmpG, *tmpB, *tmpA; + unsigned long rleEnd; + GLuint *rowStart; + GLint *rowSize; +} rawImageRec; + +/******************************************************************************/ + +static void ConvertShort(unsigned short *array, long length) +{ + unsigned long b1, b2; + unsigned char *ptr; + + ptr = (unsigned char *)array; + while (length--) { + b1 = *ptr++; + b2 = *ptr++; + *array++ = (unsigned short) ((b1 << 8) | (b2)); + } +} + +static void ConvertLong(GLuint *array, long length) +{ + unsigned long b1, b2, b3, b4; + unsigned char *ptr; + + ptr = (unsigned char *)array; + while (length--) { + b1 = *ptr++; + b2 = *ptr++; + b3 = *ptr++; + b4 = *ptr++; + *array++ = (b1 << 24) | (b2 << 16) | (b3 << 8) | (b4); + } +} + +static rawImageRec *RawImageOpen(const char *fileName) +{ + union { + int testWord; + char testByte[4]; + } endianTest; + rawImageRec *raw; + GLenum swapFlag; + int x; + + endianTest.testWord = 1; + if (endianTest.testByte[0] == 1) { + swapFlag = GL_TRUE; + } else { + swapFlag = GL_FALSE; + } + + raw = (rawImageRec *)malloc(sizeof(rawImageRec)); + if (raw == NULL) { + fprintf(stderr, "Out of memory!\n"); + return NULL; + } + if ((raw->file = fopen(fileName, "rb")) == NULL) { + perror(fileName); + return NULL; + } + + fread(raw, 1, 12, raw->file); + + if (swapFlag) { + ConvertShort(&raw->imagic, 6); + } + + raw->tmp = (unsigned char *)malloc(raw->sizeX*256); + raw->tmpR = (unsigned char *)malloc(raw->sizeX*256); + raw->tmpG = (unsigned char *)malloc(raw->sizeX*256); + raw->tmpB = (unsigned char *)malloc(raw->sizeX*256); + if (raw->sizeZ==4) { + raw->tmpA = (unsigned char *)malloc(raw->sizeX*256); + } + if (raw->tmp == NULL || raw->tmpR == NULL || raw->tmpG == NULL || + raw->tmpB == NULL) { + fprintf(stderr, "Out of memory!\n"); + return NULL; + } + + if ((raw->type & 0xFF00) == 0x0100) { + x = raw->sizeY * raw->sizeZ * sizeof(GLuint); + raw->rowStart = (GLuint *)malloc(x); + raw->rowSize = (GLint *)malloc(x); + if (raw->rowStart == NULL || raw->rowSize == NULL) { + fprintf(stderr, "Out of memory!\n"); + return NULL; + } + raw->rleEnd = 512 + (2 * x); + fseek(raw->file, 512, SEEK_SET); + fread(raw->rowStart, 1, x, raw->file); + fread(raw->rowSize, 1, x, raw->file); + if (swapFlag) { + ConvertLong(raw->rowStart, (long) (x/sizeof(GLuint))); + ConvertLong((GLuint *)raw->rowSize, (long) (x/sizeof(GLint))); + } + } + return raw; +} + +static void RawImageClose(rawImageRec *raw) +{ + + fclose(raw->file); + free(raw->tmp); + free(raw->tmpR); + free(raw->tmpG); + free(raw->tmpB); + if (raw->sizeZ>3) { + free(raw->tmpA); + } + free(raw); +} + +static void RawImageGetRow(rawImageRec *raw, unsigned char *buf, int y, int z) +{ + unsigned char *iPtr, *oPtr, pixel; + int count, done = 0; + + if ((raw->type & 0xFF00) == 0x0100) { + fseek(raw->file, (long) raw->rowStart[y+z*raw->sizeY], SEEK_SET); + fread(raw->tmp, 1, (unsigned int)raw->rowSize[y+z*raw->sizeY], + raw->file); + + iPtr = raw->tmp; + oPtr = buf; + while (!done) { + pixel = *iPtr++; + count = (int)(pixel & 0x7F); + if (!count) { + done = 1; + return; + } + if (pixel & 0x80) { + while (count--) { + *oPtr++ = *iPtr++; + } + } else { + pixel = *iPtr++; + while (count--) { + *oPtr++ = pixel; + } + } + } + } else { + fseek(raw->file, 512+(y*raw->sizeX)+(z*raw->sizeX*raw->sizeY), + SEEK_SET); + fread(buf, 1, raw->sizeX, raw->file); + } +} + + +static void RawImageGetData(rawImageRec *raw, TK_RGBImageRec *final) +{ + unsigned char *ptr; + int i, j; + + final->data = (unsigned char *)malloc((raw->sizeX+1)*(raw->sizeY+1)*4); + if (final->data == NULL) { + fprintf(stderr, "Out of memory!\n"); + } + + ptr = final->data; + for (i = 0; i < (int)(raw->sizeY); i++) { + RawImageGetRow(raw, raw->tmpR, i, 0); + RawImageGetRow(raw, raw->tmpG, i, 1); + RawImageGetRow(raw, raw->tmpB, i, 2); + if (raw->sizeZ>3) { + RawImageGetRow(raw, raw->tmpA, i, 3); + } + for (j = 0; j < (int)(raw->sizeX); j++) { + *ptr++ = *(raw->tmpR + j); + *ptr++ = *(raw->tmpG + j); + *ptr++ = *(raw->tmpB + j); + if (raw->sizeZ>3) { + *ptr++ = *(raw->tmpA + j); + } + } + } +} + + +static TK_RGBImageRec *tkRGBImageLoad(const char *fileName) +{ + rawImageRec *raw; + TK_RGBImageRec *final; + + raw = RawImageOpen(fileName); + if (!raw) { + fprintf(stderr, "File not found\n"); + return NULL; + } + final = (TK_RGBImageRec *)malloc(sizeof(TK_RGBImageRec)); + if (final == NULL) { + fprintf(stderr, "Out of memory!\n"); + return NULL; + } + final->sizeX = raw->sizeX; + final->sizeY = raw->sizeY; + final->components = raw->sizeZ; + RawImageGetData(raw, final); + RawImageClose(raw); + return final; +} + + +static void FreeImage( TK_RGBImageRec *image ) +{ + free(image->data); + free(image); +} + + +/* + * Load an SGI .rgb file and generate a set of 2-D mipmaps from it. + * Input: imageFile - name of .rgb to read + * intFormat - internal texture format to use, or number of components + * 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; + TK_RGBImageRec *image; + + image = tkRGBImageLoad( imageFile ); + if (!image) { + return GL_FALSE; + } + + if (image->components==3) { + format = GL_RGB; + } + else if (image->components==4) { + format = GL_RGBA; + } + else { + /* not implemented */ + fprintf(stderr, + "Error in LoadRGBMipmaps %d-component images not implemented\n", + image->components ); + return GL_FALSE; + } + + error = gluBuild2DMipmaps( target, + 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; +} + + + +/* + * Load an SGI .rgb file and return a pointer to the image data. + * Input: imageFile - name of .rgb to read + * Output: width - width of image + * height - height of image + * format - format of image (GL_RGB or GL_RGBA) + * Return: pointer to image data or NULL if error + */ +GLubyte *LoadRGBImage( const char *imageFile, GLint *width, GLint *height, + GLenum *format ) +{ + TK_RGBImageRec *image; + GLint bytes; + GLubyte *buffer; + + image = tkRGBImageLoad( imageFile ); + if (!image) { + return NULL; + } + + if (image->components==3) { + *format = GL_RGB; + } + else if (image->components==4) { + *format = GL_RGBA; + } + else { + /* not implemented */ + fprintf(stderr, + "Error in LoadRGBImage %d-component images not implemented\n", + image->components ); + return NULL; + } + + *width = image->sizeX; + *height = image->sizeY; + + bytes = image->sizeX * image->sizeY * image->components; + buffer = (GLubyte *) malloc(bytes); + if (!buffer) + return NULL; + + memcpy( (void *) buffer, (void *) image->data, bytes ); + + FreeImage(image); + + return buffer; +} + diff --git a/progs/windml/uglaccum.c b/progs/windml/uglaccum.c new file mode 100644 index 00000000000..fd7cb3125c1 --- /dev/null +++ b/progs/windml/uglaccum.c @@ -0,0 +1,250 @@ + +/* 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. + */ + +/* Original name: accanti.c + * + * Conversion to UGL/Mesa by Stephane Raimbault + */ + +#include +#include + +#include +#include +#include + +#include +#include + +#include "../book/jitter.h" + +UGL_LOCAL UGL_EVENT_SERVICE_ID eventServiceId; +UGL_LOCAL UGL_EVENT_Q_ID qId; +UGL_LOCAL UGL_MESA_CONTEXT umc; + +/* Initialize lighting and other values. + */ +UGL_LOCAL void initGL(GLsizei w, GLsizei h) + { + GLfloat mat_ambient[] = { 1.0, 1.0, 1.0, 1.0 }; + GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 }; + GLfloat light_position[] = { 0.0, 0.0, 10.0, 1.0 }; + GLfloat lm_ambient[] = { 0.2, 0.2, 0.2, 1.0 }; + + glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient); + glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); + glMaterialf(GL_FRONT, GL_SHININESS, 50.0); + glLightfv(GL_LIGHT0, GL_POSITION, light_position); + glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lm_ambient); + + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + glDepthFunc(GL_LESS); + glEnable(GL_DEPTH_TEST); + glShadeModel (GL_FLAT); + + glClearColor(0.0, 0.0, 0.0, 0.0); + glClearAccum(0.0, 0.0, 0.0, 0.0); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + if (w <= h) + glOrtho (-2.25, 2.25, -2.25*h/w, 2.25*h/w, -10.0, 10.0); + else + glOrtho (-2.25*w/h, 2.25*w/h, -2.25, 2.25, -10.0, 10.0); + glMatrixMode(GL_MODELVIEW); + } + +UGL_LOCAL void displayObjects(void) + { + GLfloat torus_diffuse[] = { 0.7, 0.7, 0.0, 1.0 }; + GLfloat cube_diffuse[] = { 0.0, 0.7, 0.7, 1.0 }; + GLfloat sphere_diffuse[] = { 0.7, 0.0, 0.7, 1.0 }; + GLfloat octa_diffuse[] = { 0.7, 0.4, 0.4, 1.0 }; + + glPushMatrix (); + glRotatef (30.0, 1.0, 0.0, 0.0); + + glPushMatrix (); + glTranslatef (-0.80, 0.35, 0.0); + glRotatef (100.0, 1.0, 0.0, 0.0); + glMaterialfv(GL_FRONT, GL_DIFFUSE, torus_diffuse); + glutSolidTorus (0.275, 0.85, 16, 16); + glPopMatrix (); + + glPushMatrix (); + glTranslatef (-0.75, -0.50, 0.0); + glRotatef (45.0, 0.0, 0.0, 1.0); + glRotatef (45.0, 1.0, 0.0, 0.0); + glMaterialfv(GL_FRONT, GL_DIFFUSE, cube_diffuse); + glutSolidCube (1.5); + glPopMatrix (); + + glPushMatrix (); + glTranslatef (0.75, 0.60, 0.0); + glRotatef (30.0, 1.0, 0.0, 0.0); + glMaterialfv(GL_FRONT, GL_DIFFUSE, sphere_diffuse); + glutSolidSphere (1.0, 16, 16); + glPopMatrix (); + + glPushMatrix (); + glTranslatef (0.70, -0.90, 0.25); + glMaterialfv(GL_FRONT, GL_DIFFUSE, octa_diffuse); + glutSolidOctahedron (); + glPopMatrix (); + + glPopMatrix (); + } + +#define ACSIZE 8 + +UGL_LOCAL void drawGL(void) + { + GLint viewport[4]; + int jitter; + + glGetIntegerv (GL_VIEWPORT, viewport); + + glClear(GL_ACCUM_BUFFER_BIT); + for (jitter = 0; jitter < ACSIZE; jitter++) + { + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glPushMatrix (); +/* Note that 4.5 is the distance in world space between + * left and right and bottom and top. + * This formula converts fractional pixel movement to + * world coordinates. + */ + glTranslatef (j8[jitter].x*4.5/viewport[2], + j8[jitter].y*4.5/viewport[3], 0.0); + displayObjects (); + glPopMatrix (); + glAccum(GL_ACCUM, 1.0/ACSIZE); + } + glAccum (GL_RETURN, 1.0); + glFlush(); + + uglMesaSwapBuffers(); + } + +UGL_LOCAL int getEvent(void) + { + UGL_EVENT event; + UGL_STATUS status; + int retVal = 0; + + status = uglEventGet (qId, &event, sizeof (event), UGL_NO_WAIT); + + while (status != UGL_STATUS_Q_EMPTY) + { + UGL_INPUT_EVENT * pInputEvent = (UGL_INPUT_EVENT *)&event; + + if (pInputEvent->modifiers & UGL_KEYBOARD_KEYDOWN) + retVal = 1; + + status = uglEventGet (qId, &event, sizeof (event), UGL_NO_WAIT); + } + + return(retVal); + } + +void windMLAccum (UGL_BOOL windMLMode); + +void uglaccum (void) + { + taskSpawn("tAccum", 210, VX_FP_TASK, 100000, + (FUNCPTR)windMLAccum,UGL_FALSE,1,2,3,4,5,6,7,8,9); + } + +void windMLAccum (UGL_BOOL windMLMode) + { + UGL_INPUT_DEVICE_ID keyboardDevId; + GLsizei width, height; + + uglInitialize(); + + uglDriverFind (UGL_KEYBOARD_TYPE, 0, (UGL_UINT32 *)&keyboardDevId); + + uglDriverFind (UGL_EVENT_SERVICE_TYPE, 0, (UGL_UINT32 *)&eventServiceId); + + qId = uglEventQCreate (eventServiceId, 100); + + if (windMLMode) + umc = uglMesaCreateNewContextExt(UGL_MESA_DOUBLE + | UGL_MESA_WINDML_EXCLUSIVE, + 16, + 0, + 8,8,8,0, + NULL); + else + umc = uglMesaCreateNewContextExt(UGL_MESA_DOUBLE, + 16, + 0, + 8,8,8,0, + NULL); + + if (umc == NULL) + { + uglDeinitialize(); + return; + } + + /* Fullscreen */ + + uglMesaMakeCurrentContext(umc, 0, 0, + UGL_MESA_FULLSCREEN_WIDTH, + UGL_MESA_FULLSCREEN_HEIGHT); + + uglMesaGetIntegerv(UGL_MESA_WIDTH, &width); + uglMesaGetIntegerv(UGL_MESA_HEIGHT, &height); + + initGL(width, height); + + drawGL(); + + while (!getEvent()); + + uglEventQDestroy (eventServiceId, qId); + + uglMesaDestroyContext(); + uglDeinitialize(); + + return; + } diff --git a/progs/windml/uglalldemos.c b/progs/windml/uglalldemos.c new file mode 100644 index 00000000000..283e4870740 --- /dev/null +++ b/progs/windml/uglalldemos.c @@ -0,0 +1,198 @@ + +/* uglalldemos.c - WindML/Mesa example program */ + +/* Copyright (C) 2001 by Wind River Systems, Inc */ + +/* + * Mesa 3-D graphics library + * Version: 3.5 + * + * The MIT License + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT 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. + */ + +/* +modification history +-------------------- +02a,29aug01,sra WindML mode added +01a,17jul01,sra written +*/ + +/* +DESCRIPTION +Show all the UGL/Mesa demos +*/ + +#include +#include +#include +#include +#include +#include +#include + +#define BLACK 0 +#define RED 1 + +struct _colorStruct + { + UGL_RGB rgbColor; + UGL_COLOR uglColor; + } +colorTable[] = + { + { UGL_MAKE_RGB(0, 0, 0), 0}, + { UGL_MAKE_RGB(255, 0, 0), 0}, + }; + +void windMLPoint (UGL_BOOL windMLMode); +void windMLLine (UGL_BOOL windMLMode); +void windMLFlip (UGL_BOOL windMLMode); +void windMLCube (UGL_BOOL windMLMode); +void windMLBounce (UGL_BOOL windMLMode); +void windMLGears (UGL_BOOL windMLMode); +void windMLIcoTorus (UGL_BOOL windMLMode); +void windMLOlympic (UGL_BOOL windMLMode); +void windMLTexCube (UGL_BOOL windMLMode); +void windMLTexCyl (UGL_BOOL windMLMode); +void windMLTeapot (UGL_BOOL windMLMode); +void windMLStencil (UGL_BOOL windMLMode); +void windMLDrawPix (UGL_BOOL windMLMode); +void windMLAccum (UGL_BOOL windMLMode); +void windMLAllDemos (void); + +void uglalldemos (void) + { + taskSpawn("tAllDemos", 210, VX_FP_TASK, 200000, + (FUNCPTR)windMLAllDemos, 0,1,2,3,4,5,6,7,8,9); + } + +void windMLAllDemos(void) + { + UGL_BOOL windMLFlag = UGL_FALSE; + UGL_FB_INFO fbInfo; + UGL_EVENT event; + UGL_EVENT_SERVICE_ID eventServiceId; + UGL_EVENT_Q_ID qId; + UGL_INPUT_EVENT * pInputEvent; + UGL_INPUT_DEVICE_ID keyboardDevId; + UGL_DEVICE_ID devId; + UGL_GC_ID gc; + UGL_FONT_ID fontId; + UGL_FONT_DEF fontDef; + UGL_FONT_DRIVER_ID fontDrvId; + UGL_ORD textOrigin = UGL_FONT_TEXT_UPPER_LEFT; + int displayHeight, displayWidth; + int textWidth, textHeight; + static UGL_CHAR * message = + "Do you want to use WindML exclusively ? (y/n) "; + + uglInitialize(); + + uglDriverFind (UGL_DISPLAY_TYPE, 0, (UGL_UINT32 *)&devId); + uglDriverFind (UGL_KEYBOARD_TYPE, 0, (UGL_UINT32 *)&keyboardDevId); + uglDriverFind (UGL_EVENT_SERVICE_TYPE, 0, (UGL_UINT32 *)&eventServiceId); + qId = uglEventQCreate (eventServiceId, 100); + + gc = uglGcCreate(devId); + + uglDriverFind (UGL_FONT_ENGINE_TYPE, 0, (UGL_UINT32 *)&fontDrvId); + uglFontDriverInfo(fontDrvId, UGL_FONT_TEXT_ORIGIN, &textOrigin); + + uglFontFindString(fontDrvId, "familyName=Helvetica; pixelSize = 18", + &fontDef); + + if ((fontId = uglFontCreate(fontDrvId, &fontDef)) == UGL_NULL) + { + printf("Font not found. Exiting.\n"); + return; + } + + uglInfo(devId, UGL_FB_INFO_REQ, &fbInfo); + displayWidth = fbInfo.width; + displayHeight = fbInfo.height; + + uglColorAlloc (devId, &colorTable[BLACK].rgbColor, UGL_NULL, + &colorTable[BLACK].uglColor, 1); + uglColorAlloc(devId, &colorTable[RED].rgbColor, UGL_NULL, + &colorTable[RED].uglColor, 1); + + uglBackgroundColorSet(gc, colorTable[BLACK].uglColor); + uglForegroundColorSet(gc, colorTable[RED].uglColor); + uglFontSet(gc, fontId); + uglTextSizeGet(fontId, &textWidth, &textHeight, -1, message); + uglTextDraw(gc, (displayWidth - textWidth) / 2, + (displayHeight - textHeight) / 2 - textHeight, -1, message); +/* flushQ(); + */ + if (uglEventGet (qId, &event, sizeof (event), UGL_WAIT_FOREVER) + != UGL_STATUS_Q_EMPTY) + { + pInputEvent = (UGL_INPUT_EVENT *)&event; + + if (pInputEvent->header.type == UGL_EVENT_TYPE_KEYBOARD && + pInputEvent->modifiers & UGL_KEYBOARD_KEYDOWN) + { + switch(pInputEvent->type.keyboard.key) + { + case 'Y': + case 'y': + windMLFlag = UGL_TRUE; + break; + default: + windMLFlag = UGL_FALSE; + } + } + } + + uglFontDestroy (fontId); + uglGcDestroy (gc); + uglEventQDestroy (eventServiceId, qId); + uglDeinitialize(); + + windMLPoint(windMLFlag); + + windMLLine(windMLFlag); + + windMLFlip(windMLFlag); + + windMLCube(windMLFlag); + + windMLBounce(windMLFlag); + + windMLGears(windMLFlag); + + windMLIcoTorus(windMLFlag); + + windMLOlympic(windMLFlag); + + windMLTexCube(windMLFlag); + + windMLTexCyl(windMLFlag); + + windMLTeapot(windMLFlag); + + windMLStencil(windMLFlag); + + windMLDrawPix(windMLFlag); + + windMLAccum(windMLFlag); + + return; + } diff --git a/progs/windml/uglbounce.c b/progs/windml/uglbounce.c new file mode 100644 index 00000000000..287015a4131 --- /dev/null +++ b/progs/windml/uglbounce.c @@ -0,0 +1,272 @@ +/* + * Bouncing ball demo. + * + * This program is in the public domain + * + * Brian Paul + * + * Conversion to GLUT by Mark J. Kilgard + * + * Conversion to UGL/Mesa by Stephane Raimbault + */ + +#include +#include +#include + +#include +#include +#include + +#include + +#define COS(X) cos( (X) * 3.14159/180.0 ) +#define SIN(X) sin( (X) * 3.14159/180.0 ) + +#define RED 1 +#define WHITE 2 +#define CYAN 3 + +UGL_LOCAL UGL_EVENT_SERVICE_ID eventServiceId; +UGL_LOCAL UGL_EVENT_Q_ID qId; +UGL_LOCAL UGL_MESA_CONTEXT umc; + +UGL_LOCAL GLuint Ball; +UGL_LOCAL GLfloat Zrot, Zstep; +UGL_LOCAL GLfloat Xpos, Ypos; +UGL_LOCAL GLfloat Xvel, Yvel; +UGL_LOCAL GLfloat Xmin, Xmax; +UGL_LOCAL GLfloat Ymin; +/* UGL_LOCAL GLfloat Ymax = 4.0; */ +UGL_LOCAL GLfloat G; + +UGL_LOCAL GLuint make_ball(void) + { + GLuint list; + GLfloat a, b; + GLfloat da = 18.0, db = 18.0; + GLfloat radius = 1.0; + GLuint color; + GLfloat x, y, z; + + list = glGenLists(1); + + glNewList(list, GL_COMPILE); + + color = 0; + for (a = -90.0; a + da <= 90.0; a += da) + { + glBegin(GL_QUAD_STRIP); + for (b = 0.0; b <= 360.0; b += db) + { + if (color) + { + glIndexi(RED); + glColor3f(1, 0, 0); + } + else + { + glIndexi(WHITE); + glColor3f(1, 1, 1); + } + + x = radius * COS(b) * COS(a); + y = radius * SIN(b) * COS(a); + z = radius * SIN(a); + glVertex3f(x, y, z); + + x = radius * COS(b) * COS(a + da); + y = radius * SIN(b) * COS(a + da); + z = radius * SIN(a + da); + glVertex3f(x, y, z); + + color = 1 - color; + } + glEnd(); + + } + + glEndList(); + + return list; + } + +UGL_LOCAL void initGL(GLsizei width, GLsizei height) + { + float aspect = (float) width / (float) height; + glViewport(0, 0, (GLint) width, (GLint) height); + + uglMesaSetColor(RED, 1.0, 0.0, 0.0); + uglMesaSetColor(WHITE, 1.0, 1.0, 1.0); + uglMesaSetColor(CYAN, 0.0, 1.0, 1.0); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-6.0 * aspect, 6.0 * aspect, -6.0, 6.0, -6.0, 6.0); + glMatrixMode(GL_MODELVIEW); + + } + +UGL_LOCAL void drawGL(void) + { + GLint i; + static float vel0 = -100.0; + + glClear(GL_COLOR_BUFFER_BIT); + + glIndexi(CYAN); + glColor3f(0, 1, 1); + glBegin(GL_LINES); + for (i = -5; i <= 5; i++) + { + glVertex2i(i, -5); + glVertex2i(i, 5); + } + for (i = -5; i <= 5; i++) + { + glVertex2i(-5, i); + glVertex2i(5, i); + } + for (i = -5; i <= 5; i++) + { + glVertex2i(i, -5); + glVertex2f(i * 1.15, -5.9); + } + glVertex2f(-5.3, -5.35); + glVertex2f(5.3, -5.35); + glVertex2f(-5.75, -5.9); + glVertex2f(5.75, -5.9); + glEnd(); + + glPushMatrix(); + glTranslatef(Xpos, Ypos, 0.0); + glScalef(2.0, 2.0, 2.0); + glRotatef(8.0, 0.0, 0.0, 1.0); + glRotatef(90.0, 1.0, 0.0, 0.0); + glRotatef(Zrot, 0.0, 0.0, 1.0); + + glCallList(Ball); + + glPopMatrix(); + + glFlush(); + + uglMesaSwapBuffers(); + + Zrot += Zstep; + + Xpos += Xvel; + if (Xpos >= Xmax) + { + Xpos = Xmax; + Xvel = -Xvel; + Zstep = -Zstep; + } + if (Xpos <= Xmin) + { + Xpos = Xmin; + Xvel = -Xvel; + Zstep = -Zstep; + } + Ypos += Yvel; + Yvel += G; + if (Ypos < Ymin) + { + Ypos = Ymin; + if (vel0 == -100.0) + vel0 = fabs(Yvel); + Yvel = vel0; + } + } + +UGL_LOCAL int getEvent(void) + { + UGL_EVENT event; + UGL_STATUS status; + int retVal = 0; + + status = uglEventGet (qId, &event, sizeof (event), UGL_NO_WAIT); + + while (status != UGL_STATUS_Q_EMPTY) + { + UGL_INPUT_EVENT * pInputEvent = (UGL_INPUT_EVENT *)&event; + + if (pInputEvent->modifiers & UGL_KEYBOARD_KEYDOWN) + retVal = 1; + + status = uglEventGet (qId, &event, sizeof (event), UGL_NO_WAIT); + } + + return(retVal); + } + +void windMLBounce (UGL_BOOL windMLMode); + +void uglbounce (void) + { + taskSpawn("tBounce", 210, VX_FP_TASK, 100000, (FUNCPTR)windMLBounce, + UGL_FALSE,1,2,3,4,5,6,7,8,9); + } + +void windMLBounce(UGL_BOOL windMLMode) + { + GLsizei width, height; + UGL_INPUT_DEVICE_ID keyboardDevId; + + Zrot = 0.0; + Zstep = 6.0; + Xpos = 0.0; + Ypos = 1.0; + Xvel = 0.2; + Yvel = 0.0; + Xmin = -4.0; + Xmax = 4.0; + Ymin = -3.8; + G = -0.1; + + uglInitialize(); + + uglDriverFind (UGL_KEYBOARD_TYPE, 0, (UGL_UINT32 *)&keyboardDevId); + + uglDriverFind (UGL_EVENT_SERVICE_TYPE, 0, (UGL_UINT32 *)&eventServiceId); + + qId = uglEventQCreate (eventServiceId, 100); + + if (windMLMode) + umc = uglMesaCreateNewContext(UGL_MESA_DOUBLE + | UGL_MESA_WINDML_EXCLUSIVE, NULL); + else + umc = uglMesaCreateNewContext(UGL_MESA_DOUBLE, NULL); + + if (umc == NULL) + { + uglDeinitialize(); + return; + } + + /* Fullscreen */ + + uglMesaMakeCurrentContext(umc, 0, 0, UGL_MESA_FULLSCREEN_WIDTH, + UGL_MESA_FULLSCREEN_HEIGHT); + + Ball = make_ball(); + glCullFace(GL_BACK); + glEnable(GL_CULL_FACE); + glDisable(GL_DITHER); + glShadeModel(GL_FLAT); + + uglMesaGetIntegerv(UGL_MESA_WIDTH, &width); + uglMesaGetIntegerv(UGL_MESA_HEIGHT, &height); + + initGL(width, height); + + while(!getEvent()) + drawGL(); + + uglEventQDestroy (eventServiceId, qId); + + uglMesaDestroyContext(); + uglDeinitialize (); + + return; + } diff --git a/progs/windml/uglcube.c b/progs/windml/uglcube.c new file mode 100644 index 00000000000..e701d8db462 --- /dev/null +++ b/progs/windml/uglcube.c @@ -0,0 +1,257 @@ +/* uglcube.c - WindML/Mesa example program */ + +/* Copyright (C) 2001 by Wind River Systems, Inc */ + +/* + * Mesa 3-D graphics library + * Version: 3.5 + * + * The MIT License + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT 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. + */ + +/* +DESCRIPTION +Draw a smooth cube. +*/ + +#include +#include + +#include +#include + +#include +#include + +UGL_LOCAL UGL_EVENT_SERVICE_ID eventServiceId; +UGL_LOCAL UGL_EVENT_Q_ID qId; +UGL_LOCAL UGL_MESA_CONTEXT umc; +UGL_LOCAL GLfloat rotx; +UGL_LOCAL GLfloat roty; +UGL_LOCAL GLuint theCube; + +UGL_LOCAL void cube() + { + + /* Front */ + glBegin(GL_QUADS); + glColor3f(0.0f, 0.0f, 1.0f); + glVertex3f(-1.0f, 1.0f, 1.0f); + glColor3f(0.0f, 1.0f, 0.0f); + glVertex3f(1.0f, 1.0f, 1.0f); + glColor3f(1.0f, 0.0f, 0.0f); + glVertex3f(1.0f, -1.0f, 1.0f); + glColor3f(1.0f, 1.0f, 0.0f); + glVertex3f(-1.0f, -1.0f, 1.0f); + glEnd(); + + + /* Back */ + glBegin(GL_QUADS); + glColor3f(0.0f, 0.0f, 1.0f); + glVertex3f(-1.0f, 1.0f, -1.0f); + glColor3f(0.0f, 1.0f, 0.0f); + glVertex3f(1.0f, 1.0f, -1.0f); + glColor3f(1.0f, 0.0f, 0.0f); + glVertex3f(1.0f, -1.0f, -1.0f); + glColor3f(1.0f, 1.0f, 0.0f); + glVertex3f(-1.0f, -1.0f, -1.0f); + glEnd(); + + + /* Right */ + glBegin(GL_QUADS); + glColor3f(0.0f, 1.0f, 0.0f); + glVertex3f(1.0f, 1.0f, 1.0f); + glColor3f(0.0f, 1.0f, 0.0f); + glVertex3f(1.0f, 1.0f, -1.0f); + glColor3f(1.0f, 0.0f, 0.0f); + glVertex3f(1.0f, -1.0f, -1.0f); + glColor3f(1.0f, 0.0f, 0.0f); + glVertex3f(1.0f, -1.0f, 1.0f); + glEnd(); + + /* Left */ + glBegin(GL_QUADS); + glColor3f(0.0f, 0.0f, 1.0f); + glVertex3f(-1.0f, 1.0f, 1.0f); + glColor3f(0.0f, 0.0f, 1.0f); + glVertex3f(-1.0f, 1.0f, -1.0f); + glColor3f(1.0f, 1.0f, 0.0f); + glVertex3f(-1.0f, -1.0f, -1.0f); + glColor3f(1.0f, 1.0f, 0.0f); + glVertex3f(-1.0f, -1.0f, 1.0f); + glEnd(); + + /* Top */ + glBegin(GL_QUADS); + glColor3f(0.0f, 0.0f, 1.0f); + glVertex3f(-1.0f, 1.0f, -1.0f); + glColor3f(0.0f, 1.0f, 0.0f); + glVertex3f(1.0f, 1.0f, -1.0f); + glColor3f(0.0f, 1.0f, 0.0f); + glVertex3f(1.0f, 1.0f, 1.0f); + glColor3f(0.0f, 0.0f, 1.0f); + glVertex3f(-1.0f, 1.0f, 1.0f); + glEnd(); + + + /* Bottom */ + glBegin(GL_QUADS); + glColor3f(1.0f, 1.0f, 0.0f); + glVertex3f(-1.0f, -1.0f, -1.0f); + glColor3f(1.0f, 0.0f, 0.0f); + glVertex3f(1.0f, -1.0f, -1.0f); + glColor3f(1.0f, 0.0f, 0.0f); + glVertex3f(1.0f, -1.0f, 1.0f); + glColor3f(1.0f, 1.0f, 0.0f); + glVertex3f(-1.0f, -1.0f, 1.0f); + glEnd(); + } + +UGL_LOCAL void initGL + ( + int Width, + int Height + ) + { + glClearColor(0.0f, 0.0f, 0.0f, 0.0f); + glDepthFunc(GL_LESS); + glEnable(GL_DEPTH_TEST); + glShadeModel(GL_SMOOTH); + + theCube = glGenLists(1); + glNewList(theCube, GL_COMPILE); + cube(); + glEndList(); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluPerspective(45.0f, (GLfloat) Width / (GLfloat) Height, 0.1f, 100.0f); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTranslatef(0.0f, 0.0f, -6.0f); + } + + +/* The main drawing function. */ + +UGL_LOCAL void drawGL() + { + + /* Clear The Screen And The Depth Buffer */ + + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + /* Rotate the cube */ + + glRotatef(rotx, 1.0f, 0.0f, 0.0f); + glRotatef(roty, 0.0f, 1.0f, 0.0f); + + glCallList(theCube); + + glFlush(); + + uglMesaSwapBuffers(); + } + + +/* The function called whenever a key is pressed. */ + +UGL_LOCAL int getEvent(void) + { + UGL_EVENT event; + UGL_STATUS status; + int retVal = 0; + + status = uglEventGet (qId, &event, sizeof (event), UGL_NO_WAIT); + + while (status != UGL_STATUS_Q_EMPTY) + { + UGL_INPUT_EVENT * pInputEvent = (UGL_INPUT_EVENT *)&event; + + if (pInputEvent->modifiers & UGL_KEYBOARD_KEYDOWN) + retVal = 1; + + status = uglEventGet (qId, &event, sizeof (event), UGL_NO_WAIT); + } + + return(retVal); + } + +void windMLCube (UGL_BOOL windMLMode); + +void uglcube (void) + { + taskSpawn("tCube", 210, VX_FP_TASK, 100000, (FUNCPTR)windMLCube, + UGL_FALSE,1,2,3,4,5,6,7,8,9); + } + +void windMLCube (UGL_BOOL windMLMode) + { + GLsizei width, height; + UGL_INPUT_DEVICE_ID keyboardDevId; + + rotx = 2.5f; + roty = 1.0f; + + uglInitialize(); + + uglDriverFind (UGL_KEYBOARD_TYPE, 0, (UGL_UINT32 *)&keyboardDevId); + + if (uglDriverFind (UGL_EVENT_SERVICE_TYPE, 0, + (UGL_UINT32 *)&eventServiceId) == UGL_STATUS_OK) + { + qId = uglEventQCreate (eventServiceId, 100); + } + else + { + eventServiceId = UGL_NULL; + } + + if (windMLMode) + umc = uglMesaCreateNewContext(UGL_MESA_DOUBLE + | UGL_MESA_WINDML_EXCLUSIVE, NULL); + else + umc = uglMesaCreateNewContext(UGL_MESA_DOUBLE, NULL); + + /* Fullscreen */ + + uglMesaMakeCurrentContext(umc, 0, 0, UGL_MESA_FULLSCREEN_WIDTH, + UGL_MESA_FULLSCREEN_HEIGHT); + + uglMesaGetIntegerv(UGL_MESA_WIDTH, &width); + uglMesaGetIntegerv(UGL_MESA_HEIGHT, &height); + + /* Initialize our window. */ + + initGL(width, height); + + while (!getEvent()) + drawGL(); + + if (eventServiceId != UGL_NULL) + uglEventQDestroy (eventServiceId, qId); + + uglMesaDestroyContext(); + uglDeinitialize(); + + return; + } diff --git a/progs/windml/ugldrawpix.c b/progs/windml/ugldrawpix.c new file mode 100644 index 00000000000..f511a92ff56 --- /dev/null +++ b/progs/windml/ugldrawpix.c @@ -0,0 +1,438 @@ +/* + * glDrawPixels demo/test/benchmark + * + * Brian Paul September 25, 1997 This file is in the public domain. + * + * Conversion to UGL/Mesa by Stephane Raimbault july, 2001 + */ + +/* + * $Log: ugldrawpix.c,v $ + * Revision 1.2 2001-09-10 19:21:13 brianp + * WindML updates (Stephane Raimbault) + * + * Revision 1.1 2001/08/20 16:07:11 brianp + * WindML driver (Stephane Raimbault) + * + * Revision 1.5 2000/12/24 22:53:54 pesco + * * demos/Makefile.am (INCLUDES): Added -I$(top_srcdir)/util. + * * demos/Makefile.X11, demos/Makefile.BeOS-R4, demos/Makefile.cygnus: + * Essentially the same. + * Program files updated to include "readtex.c", not "../util/readtex.c". + * * demos/reflect.c: Likewise for "showbuffer.c". + * + * + * * Makefile.am (EXTRA_DIST): Added top-level regular files. + * + * * include/GL/Makefile.am (INC_X11): Added glxext.h. + * + * + * * src/GGI/include/ggi/mesa/Makefile.am (EXTRA_HEADERS): Include + * Mesa GGI headers in dist even if HAVE_GGI is not given. + * + * * configure.in: Look for GLUT and demo source dirs in $srcdir. + * + * * src/swrast/Makefile.am (libMesaSwrast_la_SOURCES): Set to *.[ch]. + * More source list updates in various Makefile.am's. + * + * * Makefile.am (dist-hook): Remove CVS directory from distribution. + * (DIST_SUBDIRS): List all possible subdirs here. + * (SUBDIRS): Only list subdirs selected for build again. + * The above two applied to all subdir Makefile.am's also. + * + * Revision 1.4 2000/09/08 21:45:21 brianp + * added dither key option + * + * Revision 1.3 1999/10/28 18:23:29 brianp + * minor changes to Usage() function + * + * Revision 1.2 1999/10/21 22:13:58 brianp + * added f key to toggle front/back drawing + * + * Revision 1.1.1.1 1999/08/19 00:55:40 jtg + * Imported sources + * + * Revision 3.3 1999/03/28 18:18:33 brianp + * minor clean-up + * + * Revision 3.2 1998/11/05 04:34:04 brianp + * moved image files to ../images/ directory + * + * Revision 3.1 1998/02/22 16:43:17 brianp + * added a few casts to silence compiler warnings + * + * Revision 3.0 1998/02/14 18:42:29 brianp + * initial rev + * + */ + + +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include + +#include "../util/readtex.h" + +#define IMAGE_FILE "Mesa/images/wrs_logo.rgb" + +UGL_LOCAL UGL_EVENT_SERVICE_ID eventServiceId; +UGL_LOCAL UGL_EVENT_Q_ID qId; +UGL_LOCAL volatile UGL_BOOL stopWex; +UGL_LOCAL UGL_MESA_CONTEXT umc; + +UGL_LOCAL int ImgWidth, ImgHeight; +UGL_LOCAL GLenum ImgFormat; +UGL_LOCAL GLubyte *Image; + +UGL_LOCAL int Xpos, Ypos; +UGL_LOCAL int SkipPixels, SkipRows; +UGL_LOCAL int DrawWidth, DrawHeight; +UGL_LOCAL float Xzoom, Yzoom; +UGL_LOCAL GLboolean Scissor; +UGL_LOCAL GLboolean DrawFront; +UGL_LOCAL GLboolean Dither; + +UGL_LOCAL void cleanUp (void); + +UGL_LOCAL void reset(void) + { + Xpos = Ypos = 20; + DrawWidth = ImgWidth; + DrawHeight = ImgHeight; + SkipPixels = SkipRows = 0; + Scissor = GL_FALSE; + Xzoom = Yzoom = 1.0; + } + +UGL_LOCAL void initGL(GLboolean ciMode, GLsizei width, GLsizei height) + { + printf("GL_VERSION = %s\n", (char *) glGetString(GL_VERSION)); + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + printf("GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR)); + + Image = LoadRGBImage(IMAGE_FILE, &ImgWidth, &ImgHeight, &ImgFormat); + if (!Image) + { + printf("Couldn't read %s\n", IMAGE_FILE); + cleanUp(); + exit(1); + } + + glScissor(width/4, height/4, width/2, height/2); + + if (ciMode) + { + /* Convert RGB image to grayscale */ + GLubyte *indexImage = malloc( ImgWidth * ImgHeight ); + GLint i; + for (i=0; i 0) + DrawWidth--; + break; + case 'W': + DrawWidth++; + break; + case 'h': + if (DrawHeight > 0) + DrawHeight--; + break; + case 'H': + DrawHeight++; + break; + case 'p': + if (SkipPixels > 0) + SkipPixels--; + break; + case 'P': + SkipPixels++; + break; + case 'r': + if (SkipRows > 0) + SkipRows--; + break; + case 'R': + SkipRows++; + break; + case 's': + Scissor = !Scissor; + break; + case 'x': + Xzoom -= 0.1; + break; + case 'X': + Xzoom += 0.1; + break; + case 'y': + Yzoom -= 0.1; + break; + case 'Y': + Yzoom += 0.1; + break; + case 'b': + benchmark(); + break; + case 'f': + DrawFront = !DrawFront; + if (DrawFront) + glDrawBuffer(GL_FRONT); + else + glDrawBuffer(GL_BACK); + printf("glDrawBuffer(%s)\n", DrawFront ? "GL_FRONT" : "GL_BACK"); + break; + case UGL_UNI_UP_ARROW: + Ypos += 1; + break; + case UGL_UNI_DOWN_ARROW: + Ypos -= 1; + break; + case UGL_UNI_LEFT_ARROW: + Xpos -= 1; + break; + case UGL_UNI_RIGHT_ARROW: + Xpos += 1; + break; + case UGL_UNI_ESCAPE: + stopWex = UGL_TRUE; + break; + } + } + +UGL_LOCAL void loopEvent(void) + { + UGL_EVENT event; + UGL_INPUT_EVENT * pInputEvent; + + UGL_FOREVER + { + if (uglEventGet (qId, &event, sizeof (event), UGL_NO_WAIT) + != UGL_STATUS_Q_EMPTY) + { + pInputEvent = (UGL_INPUT_EVENT *)&event; + + if (pInputEvent->header.type == UGL_EVENT_TYPE_KEYBOARD && + pInputEvent->modifiers & UGL_KEYBOARD_KEYDOWN) + readKey(pInputEvent->type.keyboard.key); + } + + drawGL(); + if (stopWex) + break; + } + } + +UGL_LOCAL void cleanUp (void) + { + uglEventQDestroy (eventServiceId, qId); + + uglMesaDestroyContext(); + uglDeinitialize (); + } + +void windMLDrawPix (UGL_BOOL windMLMode); + +void ugldrawpix (void) + { + taskSpawn ("tDrawPix", 210, VX_FP_TASK, 100000, (FUNCPTR)windMLDrawPix, + UGL_FALSE,1,2,3,4,5,6,7,8,9); + } + +void windMLDrawPix (UGL_BOOL windMLMode) + { + UGL_INPUT_DEVICE_ID keyboardDevId; + GLuint ciMode; + GLsizei width, height; + + Image = NULL; + Scissor = GL_FALSE; + DrawFront = GL_FALSE; + Dither = GL_TRUE; + + uglInitialize (); + + uglDriverFind (UGL_KEYBOARD_TYPE, 0, + (UGL_UINT32 *)&keyboardDevId); + + uglDriverFind (UGL_EVENT_SERVICE_TYPE, 0, (UGL_UINT32 *)&eventServiceId); + + qId = uglEventQCreate (eventServiceId, 100); + + /* Double buffering */ + if (windMLMode) + umc = uglMesaCreateNewContext(UGL_MESA_DOUBLE + | UGL_MESA_WINDML_EXCLUSIVE, NULL); + else + umc = uglMesaCreateNewContext(UGL_MESA_DOUBLE, NULL); + + if (umc == NULL) + { + uglDeinitialize (); + return; + } + + uglMesaMakeCurrentContext(umc, 0, 0, UGL_MESA_FULLSCREEN_WIDTH, + UGL_MESA_FULLSCREEN_HEIGHT); + + uglMesaGetIntegerv(UGL_MESA_COLOR_INDEXED, &ciMode); + uglMesaGetIntegerv(UGL_MESA_WIDTH, &width); + uglMesaGetIntegerv(UGL_MESA_HEIGHT, &height); + + initGL(ciMode, width, height); + + echoUse(); + + stopWex = UGL_FALSE; + loopEvent(); + + cleanUp(); + free(Image); + + return; + } diff --git a/progs/windml/uglflip.c b/progs/windml/uglflip.c new file mode 100644 index 00000000000..0ca068f417d --- /dev/null +++ b/progs/windml/uglflip.c @@ -0,0 +1,224 @@ + +/* uglflip.c - WindML/Mesa example program */ + +/* Copyright (C) 2001 by Wind River Systems, Inc */ + +/* + * Mesa 3-D graphics library + * Version: 3.5 + * + * The MIT License + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT 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. + */ + +/* + * Authors: + * Stephane Raimbault + */ + +/* +DESCRIPTION +Draw a triangle and flip the screen +*/ + +#include +#include + +#include +#include +#include +#include + +#include +#include + +#define BLACK (0) +#define RED (1) +#define GREEN (2) +#define BLUE (3) +#define CI_OFFSET 4 + +UGL_LOCAL GLuint rgb; +UGL_LOCAL UGL_EVENT_SERVICE_ID eventServiceId; +UGL_LOCAL UGL_EVENT_Q_ID qId; +UGL_LOCAL volatile UGL_BOOL stopWex; + +UGL_LOCAL UGL_MESA_CONTEXT umc; + +UGL_LOCAL void initGL (void) + { + uglMesaSetColor(BLACK, 0.0, 0.0, 0.0); + uglMesaSetColor(RED, 1.0, 0.3, 0.3); + uglMesaSetColor(GREEN, 0.3, 1.0, 0.3); + uglMesaSetColor(BLUE, 0.3, 0.3, 1.0); + + glClearColor(0.0, 0.0, 0.0, 0.0); + glClearIndex(BLACK); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glMatrixMode(GL_MODELVIEW); + } + +UGL_LOCAL void drawGL (void) + { + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + (rgb) ? glColor3f(1.0, 0.3, 0.3) : glIndexi(RED); + glVertex2f(0.75, -0.50); + (rgb) ? glColor3f(0.3, 1.0, 0.3) : glIndexi(GREEN); + glVertex2f(0.0, 0.75); + (rgb) ? glColor3f(0.3, 0.3, 1.0) : glIndexi(BLUE); + glVertex2f(-0.75, -0.50); + glEnd(); + + glBegin(GL_LINES); + (rgb) ? glColor3f(1.0, 0.3, 0.3) : glIndexi(RED); + glVertex2f(-1.0, 1.0); + (rgb) ? glColor3f(0.3, 0.3, 1.0) : glIndexi(BLUE); + glVertex2f(1.0, -1.0); + glEnd(); + + glFlush(); + + uglMesaSwapBuffers(); + } + +UGL_LOCAL void echoUse(void) + { + printf("tFlip keys:\n"); + printf(" d Toggle dithering\n"); + printf(" up Reduce the window\n"); + printf(" down Enlarge the window\n"); + printf(" page up Y==0 is the bottom line and increases upward\n"); + printf(" page down Y==0 is the bottom line and increases downward\n"); + printf(" ESC Exit\n"); + } + +UGL_LOCAL void readKey (UGL_WCHAR key) + { + + switch(key) + { + case UGL_UNI_UP_ARROW: + uglMesaResizeWindow(8, 8); + break; + case UGL_UNI_DOWN_ARROW: + glDrawBuffer(GL_FRONT_LEFT); + glClear(GL_COLOR_BUFFER_BIT); + glDrawBuffer(GL_BACK_LEFT); + uglMesaResizeWindow(-8, -8); + break; + case UGL_UNI_PAGE_UP: + uglMesaPixelStore(UGL_MESA_Y_UP, GL_TRUE); + break; + case UGL_UNI_PAGE_DOWN: + uglMesaPixelStore(UGL_MESA_Y_UP, GL_FALSE); + break; + case UGL_UNI_ESCAPE: + stopWex = UGL_TRUE; + break; + case 'd': + if (glIsEnabled(GL_DITHER)) + glDisable(GL_DITHER); + else + glEnable(GL_DITHER); + break; + } + } + +UGL_LOCAL void loopEvent(void) + { + UGL_EVENT event; + UGL_INPUT_EVENT * pInputEvent; + + drawGL(); + + UGL_FOREVER + { + if (uglEventGet (qId, &event, sizeof (event), UGL_WAIT_FOREVER) + != UGL_STATUS_Q_EMPTY) + { + pInputEvent = (UGL_INPUT_EVENT *)&event; + + if (pInputEvent->header.type == UGL_EVENT_TYPE_KEYBOARD && + pInputEvent->modifiers & UGL_KEYBOARD_KEYDOWN) + { + readKey(pInputEvent->type.keyboard.key); + drawGL(); + } + } + + if (stopWex) + break; + } + } + +void windMLFlip (UGL_BOOL windMLMode); + +void uglflip (void) + { + taskSpawn ("tFlip", 210, VX_FP_TASK, 100000, (FUNCPTR)windMLFlip, + UGL_FALSE,1,2,3,4,5,6,7,8,9); + } + +void windMLFlip (UGL_BOOL windMLMode) + { + + UGL_INPUT_DEVICE_ID keyboardDevId; + + uglInitialize(); + + uglDriverFind (UGL_KEYBOARD_TYPE, 0, (UGL_UINT32 *)&keyboardDevId); + + uglDriverFind (UGL_EVENT_SERVICE_TYPE, 0, (UGL_UINT32 *)&eventServiceId); + + qId = uglEventQCreate (eventServiceId, 100); + + if (windMLMode) + umc = uglMesaCreateNewContext(UGL_MESA_SINGLE + | UGL_MESA_WINDML_EXCLUSIVE, NULL); + else + umc = uglMesaCreateNewContext(UGL_MESA_DOUBLE_SOFTWARE, NULL); + + if (umc == NULL) + { + uglDeinitialize(); + return; + } + + uglMesaMakeCurrentContext(umc, 0, 0, UGL_MESA_FULLSCREEN_WIDTH, + UGL_MESA_FULLSCREEN_HEIGHT); + + uglMesaGetIntegerv(UGL_MESA_RGB, &rgb); + + initGL(); + + echoUse(); + stopWex = UGL_FALSE; + loopEvent(); + + uglEventQDestroy (eventServiceId, qId); + + uglMesaDestroyContext(); + uglDeinitialize(); + + return; + } diff --git a/progs/windml/uglgears.c b/progs/windml/uglgears.c new file mode 100644 index 00000000000..468fe899806 --- /dev/null +++ b/progs/windml/uglgears.c @@ -0,0 +1,428 @@ + +/* uglgears.c - WindML/Mesa example program */ + +/* + * 3-D gear wheels. This program is in the public domain. + * + * Brian Paul + * + * Conversion to GLUT by Mark J. Kilgard + * Conversion to UGL/Mesa from GLUT by Stephane Raimbault + */ + +/* +DESCRIPTION +Spinning gears demo +*/ + +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#ifndef M_PI +#define M_PI 3.14159265358979323846 +#endif + +#define COUNT_FRAMES + +UGL_LOCAL UGL_EVENT_SERVICE_ID eventServiceId; +UGL_LOCAL UGL_EVENT_Q_ID qId; +UGL_LOCAL volatile UGL_BOOL stopWex; +UGL_LOCAL UGL_MESA_CONTEXT umc; + +UGL_LOCAL GLfloat view_rotx, view_roty, view_rotz; +UGL_LOCAL GLint gear1, gear2, gear3; +UGL_LOCAL GLfloat angle; + +UGL_LOCAL GLuint limit; +UGL_LOCAL GLuint count; +UGL_LOCAL GLuint tickStart, tickStop, tickBySec; + + +/* +* Draw a gear wheel. You'll probably want to call this function when +* building a display list since we do a lot of trig here. +* +* Input: inner_radius - radius of hole at center +* outer_radius - radius at center of teeth +* width - width of gear +* teeth - number of teeth +* tooth_depth - depth of tooth +*/ + +UGL_LOCAL void gear + ( + GLfloat inner_radius, + GLfloat outer_radius, + GLfloat width, + GLint teeth, + GLfloat tooth_depth + ) + { + GLint i; + GLfloat r0, r1, r2; + GLfloat angle, da; + GLfloat u, v, len; + + r0 = inner_radius; + r1 = outer_radius - tooth_depth/2.0; + r2 = outer_radius + tooth_depth/2.0; + + da = 2.0*M_PI / teeth / 4.0; + + glShadeModel (GL_FLAT); + + glNormal3f (0.0, 0.0, 1.0); + + /* draw front face */ + glBegin (GL_QUAD_STRIP); + for (i=0;i<=teeth;i++) + { + angle = i * 2.0*M_PI / teeth; + glVertex3f (r0*cos (angle), r0*sin (angle), width*0.5); + glVertex3f (r1*cos (angle), r1*sin (angle), width*0.5); + glVertex3f (r0*cos (angle), r0*sin (angle), width*0.5); + glVertex3f (r1*cos (angle+3*da), r1*sin (angle+3*da), width*0.5); + } + glEnd (); + + /* draw front sides of teeth */ + glBegin (GL_QUADS); + da = 2.0*M_PI / teeth / 4.0; + for (i=0; i limit) + { + tickStop = tickGet (); + time = (tickStop-tickStart)/tickBySec; + printf (" %i fps\n", count/time); + tickStart = tickStop; + count = 0; + } + else + count++; +#endif +} + + +UGL_LOCAL void initGL (GLsizei width, GLsizei height) + { + UGL_LOCAL GLfloat pos[4] = {5.0, 5.0, 10.0, 1.0 }; + UGL_LOCAL GLfloat red[4] = {0.8, 0.1, 0.0, 1.0 }; + UGL_LOCAL GLfloat green[4] = {0.0, 0.8, 0.2, 1.0 }; + UGL_LOCAL GLfloat blue[4] = {0.2, 0.2, 1.0, 1.0 }; + + glLightfv (GL_LIGHT0, GL_POSITION, pos); + glEnable (GL_CULL_FACE); + glEnable (GL_LIGHTING); + glEnable (GL_LIGHT0); + glEnable (GL_DEPTH_TEST); + + /* make the gears */ + gear1 = glGenLists (1); + glNewList (gear1, GL_COMPILE); + glMaterialfv (GL_FRONT, GL_AMBIENT_AND_DIFFUSE, red); + gear (1.0, 4.0, 1.0, 20, 0.7); + glEndList (); + + gear2 = glGenLists (1); + glNewList (gear2, GL_COMPILE); + glMaterialfv (GL_FRONT, GL_AMBIENT_AND_DIFFUSE, green); + gear (0.5, 2.0, 2.0, 10, 0.7); + glEndList (); + + gear3 = glGenLists (1); + glNewList (gear3, GL_COMPILE); + glMaterialfv (GL_FRONT, GL_AMBIENT_AND_DIFFUSE, blue); + gear (1.3, 2.0, 0.5, 10, 0.7); + glEndList (); + + glEnable (GL_NORMALIZE); + + glViewport (0, 0, width, height); + + glMatrixMode (GL_PROJECTION); + glLoadIdentity (); + if (width>height) + { + GLfloat w = (GLfloat) width / (GLfloat) height; + glFrustum (-w, w, -1.0, 1.0, 5.0, 60.0); + } + else + { + GLfloat h = (GLfloat) height / (GLfloat) width; + glFrustum (-1.0, 1.0, -h, h, 5.0, 60.0); + } + + glMatrixMode (GL_MODELVIEW); + glLoadIdentity (); + glTranslatef (0.0, 0.0, -40.0); + +#ifdef COUNT_FRAMES + tickStart = tickGet (); + tickBySec = sysClkRateGet (); +#endif +} + +UGL_LOCAL void echoUse(void) + { + printf("tGears keys:\n"); + printf(" z Counter clockwise rotation (z-axis)\n"); + printf(" Z Clockwise rotation (z-axis)\n"); + printf(" Up Counter clockwise rotation (x-axis)\n"); + printf(" Down Clockwise rotation (x-axis)\n"); + printf(" Left Counter clockwise rotation (y-axis)\n"); + printf(" Right Clockwise rotation (y-axis)\n"); + printf(" ESC Exit\n"); + } + + +UGL_LOCAL void readKey (UGL_WCHAR key) + { + + switch(key) + { + case 'z': + view_rotz += 5.0; + break; + case 'Z': + view_rotz -= 5.0; + break; + case UGL_UNI_UP_ARROW: + view_rotx += 5.0; + break; + case UGL_UNI_DOWN_ARROW: + view_rotx -= 5.0; + break; + case UGL_UNI_LEFT_ARROW: + view_roty += 5.0; + break; + case UGL_UNI_RIGHT_ARROW: + view_roty -= 5.0; + break; + case UGL_UNI_ESCAPE: + stopWex = UGL_TRUE; + break; + } + } + +UGL_LOCAL void loopEvent(void) + { + UGL_EVENT event; + UGL_INPUT_EVENT * pInputEvent; + + UGL_FOREVER + { + if (uglEventGet (qId, &event, sizeof (event), UGL_NO_WAIT) + != UGL_STATUS_Q_EMPTY) + { + pInputEvent = (UGL_INPUT_EVENT *)&event; + + if (pInputEvent->header.type == UGL_EVENT_TYPE_KEYBOARD && + pInputEvent->modifiers & UGL_KEYBOARD_KEYDOWN) + readKey(pInputEvent->type.keyboard.key); + } + + drawGL(); + if (stopWex) + break; + } + } + +void windMLGears (UGL_BOOL windMLMode); + +void uglgears (void) + { + taskSpawn ("tGears", 210, VX_FP_TASK, 100000, (FUNCPTR)windMLGears, + UGL_FALSE,1,2,3,4,5,6,7,8,9); + } + +void windMLGears (UGL_BOOL windMLMode) + { + GLsizei width, height; + UGL_INPUT_DEVICE_ID keyboardDevId; + + view_rotx=20.0; + view_roty=30.0; + view_rotz=0.0; + angle = 0.0; + limit = 100; + count = 1; + + uglInitialize (); + + uglDriverFind (UGL_KEYBOARD_TYPE, 0, + (UGL_UINT32 *)&keyboardDevId); + + uglDriverFind (UGL_EVENT_SERVICE_TYPE, 0, (UGL_UINT32 *)&eventServiceId); + + qId = uglEventQCreate (eventServiceId, 100); + + /* Double buffering */ + if (windMLMode) + umc = uglMesaCreateNewContext(UGL_MESA_DOUBLE + | UGL_MESA_WINDML_EXCLUSIVE, NULL); + else + umc = uglMesaCreateNewContext(UGL_MESA_DOUBLE, NULL); + + if (umc == NULL) + { + uglDeinitialize (); + return; + } + + /* Fullscreen */ + + uglMesaMakeCurrentContext (umc, 0, 0, UGL_MESA_FULLSCREEN_WIDTH, + UGL_MESA_FULLSCREEN_HEIGHT); + + uglMesaGetIntegerv(UGL_MESA_WIDTH, &width); + uglMesaGetIntegerv(UGL_MESA_HEIGHT, &height); + + initGL (width, height); + + echoUse(); + + stopWex = UGL_FALSE; + loopEvent(); + + uglEventQDestroy (eventServiceId, qId); + + uglMesaDestroyContext(); + uglDeinitialize (); + + return; + } diff --git a/progs/windml/uglicotorus.c b/progs/windml/uglicotorus.c new file mode 100644 index 00000000000..c09b6d1b520 --- /dev/null +++ b/progs/windml/uglicotorus.c @@ -0,0 +1,315 @@ +/* uglicotorus.c - WindML/Mesa example program */ + +/* Copyright (C) 2001 by Wind River Systems, Inc */ + +/* + * Mesa 3-D graphics library + * Version: 3.5 + * + * The MIT License + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT 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. + */ + +/* +modification history +-------------------- +01a,jun01,sra +*/ + +#include +#include + +#include +#include +#include + +#include +#include + +/* Need GLUT_SHAPES */ + +#include + +UGL_LOCAL UGL_EVENT_SERVICE_ID eventServiceId; +UGL_LOCAL UGL_EVENT_Q_ID qId; +UGL_LOCAL UGL_MESA_CONTEXT umc; +UGL_LOCAL volatile UGL_BOOL stopWex; + +UGL_LOCAL GLfloat angle; +UGL_LOCAL GLboolean chaos_on; +UGL_LOCAL GLboolean color_on; + +UGL_LOCAL GLuint theIco, theTorus, theSphere, theCube; + +UGL_LOCAL void initGL + ( + int w, + int h + ) + { + glViewport(0,0,(GLsizei)w,(GLsizei)h); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluPerspective(60.0,(GLfloat)w/(GLfloat)h,1.0,60.0); + + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + gluLookAt(0.0,0.0,25.0,0.0,0.0,0.0,0.0,1.0,0.0); + + glClearColor(0.0,0.0,0.0,0.0); + + glEnable(GL_DEPTH_TEST); + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + + glEnable(GL_COLOR_MATERIAL); + + theIco = glGenLists(1); + glNewList(theIco, GL_COMPILE); + glutSolidIcosahedron(); + glEndList(); + + theTorus = glGenLists(1); + glNewList(theTorus, GL_COMPILE); + glutSolidTorus(0.2,1.0,10,10); + glEndList(); + + theSphere = glGenLists(1); + glNewList(theSphere, GL_COMPILE); + glutSolidSphere(2.5,20,20); + glEndList(); + + theCube = glGenLists(1); + glNewList(theCube, GL_COMPILE); + glutSolidCube(4.0); + glEndList(); + + } + +UGL_LOCAL void createIcoToruses + ( + int i + ) + { + glPushMatrix(); + glRotatef(angle,1.0,1.0,1.0); + glCallList(theIco); + + switch (i) + { + case 9 : + glColor3f(1.0,0.0,0.0); + break; + case 0 : + glColor3f(1.0,0.1,0.7); + break; + case 1 : + glColor3f(1.0,0.0,1.0); + break; + case 2 : + glColor3f(0.0,0.0,1.0); + break; + case 3 : + glColor3f(0.0,0.5,1.0); + break; + case 4 : + glColor3f(0.0,1.0,0.7); + break; + case 5 : + glColor3f(0.0,1.0,0.0); + break; + case 6 : + glColor3f(0.5,1.0,0.0); + break; + case 7 : + glColor3f(1.0,1.0,0.0); + break; + case 8 : + glColor3f(1.0,0.5,0.0); + break; + } + + glRotatef(angle,1.0,1.0,1.0); + glCallList(theTorus); + glRotatef(-2*angle,1.0,1.0,1.0); + glCallList(theTorus); + glPopMatrix(); + } + +UGL_LOCAL void drawGL (void) + { + int i; + + if (color_on) + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + else + glClear(GL_DEPTH_BUFFER_BIT); + + glPushMatrix(); + + if (chaos_on) + glRotatef(angle,1.0,1.0,1.0); + + glPushMatrix(); + glRotatef(angle,1.0,1.0,1.0); + glColor3f(1.0,0.5,0.0); + glCallList(theSphere); + glColor3f(1.0,0.0,0.0); + glCallList(theCube); + glPopMatrix(); + + glRotatef(-angle,0.0,0.0,1.0); + glPushMatrix(); + /* draw ten icosahedrons */ + for (i = 0; i < 10; i++) + { + glPushMatrix(); + glRotatef(36*i,0.0,0.0,1.0); + glTranslatef(10.0,0.0,0.0); + glRotatef(2*angle,0.0,1.0,0.0); + glTranslatef(0.0,0.0,2.0); + + createIcoToruses(i); + glPopMatrix(); + } + glPopMatrix(); + + glPopMatrix(); + + uglMesaSwapBuffers(); + + angle += 1.0; + + } + +UGL_LOCAL void echoUse(void) + { + printf("tIcoTorus keys:\n"); + printf(" c Toggle color buffer clear\n"); + printf(" SPACE Toggle chaos mode\n"); + printf(" ESC Exit\n"); + } + +UGL_LOCAL void readKey (UGL_WCHAR key) + { + + switch(key) + { + case 'c': + color_on = !color_on; + break; + case UGL_UNI_SPACE: + chaos_on = !chaos_on; + break; + case UGL_UNI_ESCAPE: + stopWex = UGL_TRUE; + break; + } + } + +UGL_LOCAL void loopEvent(void) + { + UGL_EVENT event; + UGL_INPUT_EVENT * pInputEvent; + + UGL_FOREVER + { + if (uglEventGet (qId, &event, sizeof (event), UGL_NO_WAIT) + != UGL_STATUS_Q_EMPTY) + { + pInputEvent = (UGL_INPUT_EVENT *)&event; + + if (pInputEvent->header.type == UGL_EVENT_TYPE_KEYBOARD && + pInputEvent->modifiers & UGL_KEYBOARD_KEYDOWN) + readKey(pInputEvent->type.keyboard.key); + } + + drawGL(); + if (stopWex) + break; + } + } + +void windMLIcoTorus (UGL_BOOL windMLMode); + +void uglicotorus (void) + { + taskSpawn ("tIcoTorus", 210, VX_FP_TASK, 100000, (FUNCPTR)windMLIcoTorus, + UGL_FALSE,1,2,3,4,5,6,7,8,9); + } + +void windMLIcoTorus (UGL_BOOL windMLMode) + { + GLsizei width, height; + UGL_INPUT_DEVICE_ID keyboardDevId; + + angle = 0.0; + chaos_on = GL_TRUE; + color_on = GL_TRUE; + + uglInitialize (); + + uglDriverFind (UGL_KEYBOARD_TYPE, 0, + (UGL_UINT32 *)&keyboardDevId); + + if (uglDriverFind (UGL_EVENT_SERVICE_TYPE, 0, + (UGL_UINT32 *)&eventServiceId) == UGL_STATUS_OK) + { + qId = uglEventQCreate (eventServiceId, 100); + } + else + { + eventServiceId = UGL_NULL; + } + + /* Double buffering */ + if (windMLMode) + umc = uglMesaCreateNewContext(UGL_MESA_DOUBLE + | UGL_MESA_WINDML_EXCLUSIVE, NULL); + else + umc = uglMesaCreateNewContext(UGL_MESA_DOUBLE, NULL); + + if (umc == NULL) + { + uglDeinitialize (); + return; + } + + uglMesaMakeCurrentContext (umc, 0, 0, UGL_MESA_FULLSCREEN_WIDTH, + UGL_MESA_FULLSCREEN_HEIGHT); + + uglMesaGetIntegerv(UGL_MESA_WIDTH, &width); + uglMesaGetIntegerv(UGL_MESA_HEIGHT, &height); + + initGL (width, height); + + echoUse(); + + stopWex = UGL_FALSE; + loopEvent(); + + if (eventServiceId != UGL_NULL) + uglEventQDestroy (eventServiceId, qId); + + uglMesaDestroyContext (); + uglDeinitialize (); + + return; + } + diff --git a/progs/windml/uglline.c b/progs/windml/uglline.c new file mode 100644 index 00000000000..e58f071ea4b --- /dev/null +++ b/progs/windml/uglline.c @@ -0,0 +1,274 @@ + +/* uglline.c - WindML/Mesa example program */ + +/* + * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the name of + * Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF + * ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +/* +modification history +-------------------- +01a,jun01,sra Ported to UGL/Mesa and modifications +*/ + +/* +DESCRIPTION +Draw circular lines +*/ + +#include +#include + +#include +#include +#include +#include + +#include +#include + +#define BLACK (0) +#define YELLOW (1) +#define GREEN (2) +#define BLUE (3) +#define CI_OFFSET 4 + +UGL_LOCAL GLuint rgb; +UGL_LOCAL UGL_EVENT_SERVICE_ID eventServiceId; +UGL_LOCAL UGL_EVENT_Q_ID qId; +UGL_LOCAL volatile UGL_BOOL stopWex; +UGL_LOCAL UGL_MESA_CONTEXT umc; + +UGL_LOCAL GLboolean mode1, mode2; +UGL_LOCAL GLint size; + +UGL_LOCAL GLfloat pntA[3] = { + -10.0, 0.0, 0.0 +}; +UGL_LOCAL GLfloat pntB[3] = { + -5.0, 0.0, 0.0 +}; + +UGL_LOCAL GLint angleA; + +UGL_LOCAL void initGL (void) + { + GLint i; + + uglMesaSetColor(BLACK, 0.0, 0.0, 0.0); + uglMesaSetColor(YELLOW, 1.0, 1.0, 0.0); + uglMesaSetColor(GREEN, 0.0, 1.0, 0.0); + uglMesaSetColor(BLUE, 0.0, 0.0, 1.0); + + for (i = 0; i < 16; i++) + { + uglMesaSetColor(CI_OFFSET+i, i/15.0, i/15.0, 0.0); + } + + glClearColor(0.0, 0.0, 0.0, 0.0); + glClearIndex(BLACK); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-10, 10, -10, 10, -10.0, 10.0); + + glMatrixMode(GL_MODELVIEW); + + glLineStipple(1, 0xF0E0); + glBlendFunc(GL_SRC_ALPHA, GL_ONE); + + mode1 = GL_FALSE; + mode2 = GL_FALSE; + size = 1; + } + +UGL_LOCAL void drawGL (void) + { + + GLint ci, i; + + glClear(GL_COLOR_BUFFER_BIT); + + glLineWidth(size); + + if (mode1) { + glEnable(GL_LINE_STIPPLE); + } else { + glDisable(GL_LINE_STIPPLE); + } + + if (mode2) { + ci = CI_OFFSET; + glEnable(GL_LINE_SMOOTH); + glEnable(GL_BLEND); + } else { + ci = YELLOW; + glDisable(GL_LINE_SMOOTH); + glDisable(GL_BLEND); + } + + glPushMatrix(); + + glRotatef(angleA, 1, 0, 1); + angleA = angleA++ % 360; + + for (i = 0; i < 360; i += 5) { + glRotatef(5.0, 0, 0, 1); + + glColor3f(1.0, 1.0, 0.0); + glBegin(GL_LINE_STRIP); + glVertex3fv(pntA); + glVertex3fv(pntB); + glEnd(); + + glPointSize(1); + + glColor3f(0.0, 1.0, 0.0); + glBegin(GL_POINTS); + glVertex3fv(pntA); + glVertex3fv(pntB); + glEnd(); + } + + glPopMatrix(); + + glFlush(); + + uglMesaSwapBuffers(); + + } + +UGL_LOCAL void echoUse(void) + { + printf("tLine keys:\n"); + printf(" b Blending/antialiasing\n"); + printf(" n Line stipple\n"); + printf(" Up/Down Pixel size\n"); + printf(" ESC Exit\n"); + } + +UGL_LOCAL void readKey (UGL_WCHAR key) + { + switch(key) + { + case 'n': + mode1 = (mode1) ? GL_FALSE: GL_TRUE; + break; + case 'b': + mode2 = (mode2) ? GL_FALSE: GL_TRUE; + break; + case UGL_UNI_DOWN_ARROW: + if(size>0) + size--; + break; + case UGL_UNI_UP_ARROW: + size++; + break; + case UGL_UNI_ESCAPE: + stopWex = UGL_TRUE; + break; + } + } + +UGL_LOCAL void loopEvent(void) + { + UGL_EVENT event; + UGL_INPUT_EVENT * pInputEvent; + + UGL_FOREVER + { + if (uglEventGet (qId, &event, sizeof (event), UGL_NO_WAIT) + != UGL_STATUS_Q_EMPTY) + { + pInputEvent = (UGL_INPUT_EVENT *)&event; + + if (pInputEvent->header.type == UGL_EVENT_TYPE_KEYBOARD && + pInputEvent->modifiers & UGL_KEYBOARD_KEYDOWN) + readKey(pInputEvent->type.keyboard.key); + } + + drawGL(); + if (stopWex) + break; + } + } + +void windMLLine (UGL_BOOL windMLMode); + +void uglline (void) + { + taskSpawn("tLine", 210, VX_FP_TASK, 100000, (FUNCPTR)windMLLine, + UGL_FALSE,1,2,3,4,5,6,7,8,9); + } + + +void windMLLine(UGL_BOOL windMLMode) + { + + UGL_INPUT_DEVICE_ID keyboardDevId; + + angleA = 0; + + uglInitialize(); + + uglDriverFind (UGL_KEYBOARD_TYPE, 0, (UGL_UINT32 *)&keyboardDevId); + + uglDriverFind (UGL_EVENT_SERVICE_TYPE, 0, (UGL_UINT32 *)&eventServiceId); + + qId = uglEventQCreate (eventServiceId, 100); + + /* Double buffer */ + + if (windMLMode) + umc = uglMesaCreateNewContext(UGL_MESA_DOUBLE + | UGL_MESA_WINDML_EXCLUSIVE, NULL); + else + umc = uglMesaCreateNewContext(UGL_MESA_DOUBLE, NULL); + + if (umc == NULL) + { + uglDeinitialize(); + return; + } + + /* Fullscreen */ + + uglMesaMakeCurrentContext(umc, 0, 0, UGL_MESA_FULLSCREEN_WIDTH, + UGL_MESA_FULLSCREEN_HEIGHT); + + uglMesaGetIntegerv(UGL_MESA_RGB, &rgb); + + initGL(); + + echoUse(); + + stopWex = UGL_FALSE; + loopEvent(); + + uglEventQDestroy(eventServiceId, qId); + + uglMesaDestroyContext(); + uglDeinitialize(); + + return; + } diff --git a/progs/windml/uglolympic.c b/progs/windml/uglolympic.c new file mode 100644 index 00000000000..282558dacbd --- /dev/null +++ b/progs/windml/uglolympic.c @@ -0,0 +1,479 @@ +/* + * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the name of + * Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF + * ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +/* + * Nov 20, 1995 use stdlib's rand()/srand() instead of random()/srand48(), etc. + */ + +/* + * Modified by Stephane Raimbault to be able to run in VxWorks 07/18/01 + * + * Modified by Li Wei(liwei@aiar.xjtu.edu.cn) to be able to run in Windows + * 6/13 + * + * Modified by Brian Paul to compile with Windows OR Unix. 7/23/97 + */ + + +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include + +#ifndef RAND_MAX +# define RAND_MAX 32767 +#endif + +#define XSIZE 100 +#define YSIZE 75 + +#define RINGS 5 +#define BLUERING 0 +#define BLACKRING 1 +#define REDRING 2 +#define YELLOWRING 3 +#define GREENRING 4 + +#define BACKGROUND 8 + +UGL_LOCAL UGL_EVENT_SERVICE_ID eventServiceId; +UGL_LOCAL UGL_EVENT_Q_ID qId; +UGL_LOCAL UGL_MESA_CONTEXT umc; +UGL_LOCAL volatile UGL_BOOL stopWex; + +UGL_LOCAL int rgb; +UGL_LOCAL unsigned char rgb_colors[RINGS][3]; +UGL_LOCAL int mapped_colors[RINGS]; +UGL_LOCAL float dests[RINGS][3]; +UGL_LOCAL float offsets[RINGS][3]; +UGL_LOCAL float angs[RINGS]; +UGL_LOCAL float rotAxis[RINGS][3]; +UGL_LOCAL int iters[RINGS]; +UGL_LOCAL GLuint theTorus; + +enum { + COLOR_BLACK = 0, + COLOR_RED, + COLOR_GREEN, + COLOR_YELLOW, + COLOR_BLUE, + COLOR_MAGENTA, + COLOR_CYAN, + COLOR_WHITE +}; + +/* +UGL_LOCAL float RGBMap[9][3] = { + {0, 0, 0}, + {1, 0, 0}, + {0, 1, 0}, + {1, 1, 0}, + {0, 0, 1}, + {1, 0, 1}, + {0, 1, 1}, + {1, 1, 1}, + {0.5, 0.5, 0.5} +}; + +UGL_LOCAL void SetColor(int c) + { + (rgb) ? glColor3fv(RGBMap[c]): glIndexf(c); + } + +UGL_LOCAL void InitMap(void) + { + int i; + + if (rgb) + return; + + for (i = 0; i < 9; i++) + uglMesaSetColor(i, RGBMap[i][0], RGBMap[i][1], RGBMap[i][2]); + } + +UGL_LOCAL void SetFogRamp(int density, int startIndex) + { + int fogValues, colorValues; + int i, j, k; + float intensity; + + fogValues = 1 << density; + colorValues = 1 << startIndex; + for (i = 0; i < colorValues; i++) + { + for (j = 0; j < fogValues; j++) + { + k = i * fogValues + j; + intensity = (i * fogValues + j * colorValues) / 255.0; + uglMesaSetColor(k, intensity, intensity, intensity); + } + } + } + +UGL_LOCAL void SetGreyRamp(void) + { + int i; + float intensity; + + for (i = 0; i < 255; i++) + { + intensity = i / 255.0; + uglMesaSetColor(i, intensity, intensity, intensity); + } + } +*/ + +UGL_LOCAL void FillTorus(float rc, int numc, float rt, int numt) + { + int i, j, k; + double s, t; + double x, y, z; + double pi, twopi; + + pi = 3.14159265358979323846; + twopi = 2 * pi; + + for (i = 0; i < numc; i++) + { + glBegin(GL_QUAD_STRIP); + for (j = 0; j <= numt; j++) + { + for (k = 1; k >= 0; k--) + { + s = (i + k) % numc + 0.5; + t = j % numt; + + x = cos(t*twopi/numt) * cos(s*twopi/numc); + y = sin(t*twopi/numt) * cos(s*twopi/numc); + z = sin(s*twopi/numc); + glNormal3f(x, y, z); + + x = (rt + rc * cos(s*twopi/numc)) * cos(t*twopi/numt); + y = (rt + rc * cos(s*twopi/numc)) * sin(t*twopi/numt); + z = rc * sin(s*twopi/numc); + glVertex3f(x, y, z); + } + } + glEnd(); + } + } + +UGL_LOCAL float Clamp(int iters_left, float t) + { + if (iters_left < 3) + { + return 0.0; + } + return (iters_left-2)*t/iters_left; + } + +UGL_LOCAL void drawGL(void) + { + int i, j; + + for (i = 0; i < RINGS; i++) + { + if (iters[i]) { + for (j = 0; j < 3; j++) + { + offsets[i][j] = Clamp(iters[i], offsets[i][j]); + } + angs[i] = Clamp(iters[i], angs[i]); + iters[i]--; + } + } + + glPushMatrix(); + + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + gluLookAt(0,0,10, 0,0,0, 0,1,0); + + for (i = 0; i < RINGS; i++) + { + if (rgb) + { + glColor3ubv(rgb_colors[i]); + } + else + { + glIndexi(mapped_colors[i]); + } + glPushMatrix(); + glTranslatef(dests[i][0]+offsets[i][0], dests[i][1]+offsets[i][1], + dests[i][2]+offsets[i][2]); + glRotatef(angs[i], rotAxis[i][0], rotAxis[i][1], rotAxis[i][2]); + glCallList(theTorus); + glPopMatrix(); + } + + glPopMatrix(); + + glFlush(); + + uglMesaSwapBuffers(); + } + +UGL_LOCAL float MyRand(void) + { + return 10.0 * ( (float) rand() / (float) RAND_MAX - 0.5 ); + } + +UGL_LOCAL void ReInit(void) + { + int i; + float deviation; + + deviation = MyRand() / 2; + deviation = deviation * deviation; + for (i = 0; i < RINGS; i++) + { + offsets[i][0] = MyRand(); + offsets[i][1] = MyRand(); + offsets[i][2] = MyRand(); + angs[i] = 260.0 * MyRand(); + rotAxis[i][0] = MyRand(); + rotAxis[i][1] = MyRand(); + rotAxis[i][2] = MyRand(); + iters[i] = (deviation * MyRand() + 60.0); + } + } + +UGL_LOCAL void initGL(void) + { + float base, height; + float aspect, x, y; + int i; + + float top_y = 1.0; + float bottom_y = 0.0; + float top_z = 0.15; + float bottom_z = 0.69; + float spacing = 2.5; + static float lmodel_ambient[] = {0.0, 0.0, 0.0, 0.0}; + static float lmodel_twoside[] = {GL_FALSE}; + static float lmodel_local[] = {GL_FALSE}; + static float light0_ambient[] = {0.1, 0.1, 0.1, 1.0}; + static float light0_diffuse[] = {1.0, 1.0, 1.0, 0.0}; + static float light0_position[] = {0.8660254, 0.5, 1, 0}; + static float light0_specular[] = {1.0, 1.0, 1.0, 0.0}; + static float bevel_mat_ambient[] = {0.0, 0.0, 0.0, 1.0}; + static float bevel_mat_shininess[] = {40.0}; + static float bevel_mat_specular[] = {1.0, 1.0, 1.0, 0.0}; + static float bevel_mat_diffuse[] = {1.0, 0.0, 0.0, 0.0}; + + ReInit(); + + for (i = 0; i < RINGS; i++) + { + rgb_colors[i][0] = rgb_colors[i][1] = rgb_colors[i][2] = 0; + } + rgb_colors[BLUERING][2] = 255; + rgb_colors[REDRING][0] = 255; + rgb_colors[GREENRING][1] = 255; + rgb_colors[YELLOWRING][0] = 255; + rgb_colors[YELLOWRING][1] = 255; + mapped_colors[BLUERING] = COLOR_BLUE; + mapped_colors[REDRING] = COLOR_RED; + mapped_colors[GREENRING] = COLOR_GREEN; + mapped_colors[YELLOWRING] = COLOR_YELLOW; + mapped_colors[BLACKRING] = COLOR_BLACK; + + dests[BLUERING][0] = -spacing; + dests[BLUERING][1] = top_y; + dests[BLUERING][2] = top_z; + + dests[BLACKRING][0] = 0.0; + dests[BLACKRING][1] = top_y; + dests[BLACKRING][2] = top_z; + + dests[REDRING][0] = spacing; + dests[REDRING][1] = top_y; + dests[REDRING][2] = top_z; + + dests[YELLOWRING][0] = -spacing / 2.0; + dests[YELLOWRING][1] = bottom_y; + dests[YELLOWRING][2] = bottom_z; + + dests[GREENRING][0] = spacing / 2.0; + dests[GREENRING][1] = bottom_y; + dests[GREENRING][2] = bottom_z; + + base = 2.0; + height = 2.0; + theTorus = glGenLists(1); + glNewList(theTorus, GL_COMPILE); + FillTorus(0.1, 8, 1.0, 25); + glEndList(); + + x = (float)XSIZE; + y = (float)YSIZE; + aspect = x / y; + glEnable(GL_CULL_FACE); + glCullFace(GL_BACK); + glEnable(GL_DEPTH_TEST); + glClearDepth(1.0); + + if (rgb) + { + glClearColor(0.5, 0.5, 0.5, 0.0); + glLightfv(GL_LIGHT0, GL_AMBIENT, light0_ambient); + glLightfv(GL_LIGHT0, GL_DIFFUSE, light0_diffuse); + glLightfv(GL_LIGHT0, GL_SPECULAR, light0_specular); + glLightfv(GL_LIGHT0, GL_POSITION, light0_position); + glEnable(GL_LIGHT0); + + glLightModelfv(GL_LIGHT_MODEL_LOCAL_VIEWER, lmodel_local); + glLightModelfv(GL_LIGHT_MODEL_TWO_SIDE, lmodel_twoside); + glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient); + glEnable(GL_LIGHTING); + + glMaterialfv(GL_FRONT, GL_AMBIENT, bevel_mat_ambient); + glMaterialfv(GL_FRONT, GL_SHININESS, bevel_mat_shininess); + glMaterialfv(GL_FRONT, GL_SPECULAR, bevel_mat_specular); + glMaterialfv(GL_FRONT, GL_DIFFUSE, bevel_mat_diffuse); + + glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE); + glEnable(GL_COLOR_MATERIAL); + glShadeModel(GL_SMOOTH); + } + else + { + glClearIndex(BACKGROUND); + glShadeModel(GL_FLAT); + } + + glMatrixMode(GL_PROJECTION); + gluPerspective(45, 1.33, 0.1, 100.0); + glMatrixMode(GL_MODELVIEW); + } + +UGL_LOCAL void echoUse(void) + { + printf("tOlympic keys:\n"); + printf(" SPACE Reinitialize\n"); + printf(" ESC Exit\n"); + } + +UGL_LOCAL void readKey (UGL_WCHAR key) + { + switch(key) + { + case UGL_UNI_SPACE: + ReInit(); + break; + case UGL_UNI_ESCAPE: + stopWex = 1; + break; + } + } + +UGL_LOCAL void loopEvent(void) + { + UGL_EVENT event; + UGL_INPUT_EVENT * pInputEvent; + + UGL_FOREVER + { + if (uglEventGet (qId, &event, sizeof (event), UGL_NO_WAIT) + != UGL_STATUS_Q_EMPTY) + { + pInputEvent = (UGL_INPUT_EVENT *)&event; + + if (pInputEvent->header.type == UGL_EVENT_TYPE_KEYBOARD && + pInputEvent->modifiers & UGL_KEYBOARD_KEYDOWN) + readKey(pInputEvent->type.keyboard.key); + } + + drawGL(); + if (stopWex) + break; + } + } + +void windMLOlympic (UGL_BOOL windMLMode); + +void uglolympic (void) + { + taskSpawn("tOlympic", 210, VX_FP_TASK, 100000, (FUNCPTR)windMLOlympic, + 0,1,2,3,4,5,6,7,8,9); + } + +void windMLOlympic(UGL_BOOL windMLMode) + { + UGL_INPUT_DEVICE_ID keyboardDevId; + + uglInitialize(); + + uglDriverFind (UGL_KEYBOARD_TYPE, 0, (UGL_UINT32 *)&keyboardDevId); + + if (uglDriverFind (UGL_EVENT_SERVICE_TYPE, 0, + (UGL_UINT32 *)&eventServiceId) == UGL_STATUS_OK) + { + qId = uglEventQCreate (eventServiceId, 100); + } + else + { + eventServiceId = UGL_NULL; + } + + if (windMLMode) + umc = uglMesaCreateNewContext(UGL_MESA_DOUBLE + | UGL_MESA_WINDML_EXCLUSIVE, NULL); + else + umc = uglMesaCreateNewContext(UGL_MESA_DOUBLE, NULL); + + if (umc == NULL) + { + uglDeinitialize(); + return; + } + + uglMesaMakeCurrentContext(umc, 0, 0, UGL_MESA_FULLSCREEN_WIDTH, + UGL_MESA_FULLSCREEN_HEIGHT); + + uglMesaGetIntegerv(UGL_MESA_RGB, &rgb); + + initGL(); + + echoUse(); + + stopWex = 0; + loopEvent(); + + if (eventServiceId != UGL_NULL) + uglEventQDestroy (eventServiceId, qId); + + uglMesaDestroyContext(); + uglDeinitialize(); + + return; + } diff --git a/progs/windml/uglpoint.c b/progs/windml/uglpoint.c new file mode 100644 index 00000000000..49c432c3a41 --- /dev/null +++ b/progs/windml/uglpoint.c @@ -0,0 +1,277 @@ + +/* uglpoint.c - WindML/Mesa example program */ + +/* Copyright (C) 2001 by Wind River Systems, Inc */ + +/* + * Mesa 3-D graphics library + * Version: 3.5 + * + * The MIT License + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT 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. + */ + +/* + * Authors: + * Stephane Raimbault + */ + +/* +DESCRIPTION +Draw a single point. +*/ + +#include +#include + +#include +#include +#include + +#include + +#define DOUBLE_BUFFER GL_TRUE + +enum { + BLACK = 0, + RED, + GREEN, + BLUE, + WHITE +}; + +UGL_LOCAL GLuint rgb; +UGL_LOCAL UGL_EVENT_SERVICE_ID eventServiceId; +UGL_LOCAL UGL_EVENT_Q_ID qId; +UGL_LOCAL UGL_MESA_CONTEXT umc; +UGL_LOCAL GLint angleT; + +UGL_LOCAL void initGL (void) + { + /* By passed in RGB mode */ + uglMesaSetColor(BLACK, 0.0, 0.0, 0.0); + uglMesaSetColor(RED, 1.0, 0.0, 0.0); + uglMesaSetColor(GREEN, 0.0, 1.0, 0.0); + uglMesaSetColor(BLUE, 0.0, 0.0, 1.0); + uglMesaSetColor(WHITE, 1.0, 1.0, 1.0); + + glOrtho(0.0, 1.0, 0.0, 1.0, -20.0, 20.0); + + glClearColor(0.0, 0.0, 0.0, 0.0); + glClearIndex(BLACK); + } + +UGL_LOCAL void drawGL (void) + { + GLint i; + GLfloat x, y; + + /* Avoid blinking in single buffer */ + + if (DOUBLE_BUFFER) + glClear(GL_COLOR_BUFFER_BIT); + + /* Random points */ + + glBegin(GL_POINTS); + (rgb) ? glColor3f(1.0, 0.0, 0.0): glIndexi(RED); + + for (i=0; i<150; i++) + { + x = rand() / (RAND_MAX+1.0); + y = rand() / (RAND_MAX+1.0); + glVertex2f(x, y); + } + + (rgb) ? glColor3f(0.0, 1.0, 0.0): glIndexi(GREEN); + + for (i=0; i<150; i++) + { + x = (rand() / (RAND_MAX+1.0)); + y = (rand() / (RAND_MAX+1.0)); + glVertex2f(x, y); + } + + (rgb) ? glColor3f(0.0, 0.0, 1.0): glIndexi(BLUE); + glVertex2f(0.5,0.5); + + for (i=0; i<150; i++) + { + x = rand() / (RAND_MAX+1.0); + y = rand() / (RAND_MAX+1.0); + glVertex2f(x, y); + } + + glEnd(); + + /* Smooth triangle */ + + glPushMatrix(); + glTranslatef(0.5, 0.5, 0); + glRotatef(angleT, 1.0, -1.0, 0.0); + angleT = angleT++ % 360; + glBegin(GL_TRIANGLES); + (rgb) ? glColor3f(1.0, 0.0, 0.0): glIndexi(RED); + glVertex2f(0.75, 0.25); + (rgb) ? glColor3f(0.0, 1.0, 0.0): glIndexi(GREEN); + glVertex2f(0.75, 0.75); + (rgb) ? glColor3f(0.0, 0.0, 1.0): glIndexi(BLUE); + glVertex2f(0.25, 0.75); + glEnd(); + glPopMatrix(); + + /* Flush and swap */ + + glFlush(); + + uglMesaSwapBuffers(); + } + +/************************************************************************ +* +* getEvent +* +* RETURNS: true or false +* +* NOMANUAL +* +*/ + +UGL_LOCAL int getEvent(void) + { + UGL_EVENT event; + UGL_STATUS status; + int retVal = 0; + + status = uglEventGet (qId, &event, sizeof (event), UGL_NO_WAIT); + + while (status != UGL_STATUS_Q_EMPTY) + { + UGL_INPUT_EVENT * pInputEvent = (UGL_INPUT_EVENT *)&event; + + if (pInputEvent->modifiers & UGL_KEYBOARD_KEYDOWN) + retVal = 1; + + status = uglEventGet (qId, &event, sizeof (event), UGL_NO_WAIT); + } + + return(retVal); + } + +void windMLPoint (UGL_BOOL windMLMode); + +void uglpoint (void) + { + taskSpawn ("tPoint", 210, VX_FP_TASK, 100000, + (FUNCPTR)windMLPoint, UGL_FALSE,1,2,3,4,5,6,7,8,9); + } + +void windMLPoint (UGL_BOOL windMLMode) + { + GLubyte pPixels[4]; + GLsizei width, height; + UGL_INPUT_DEVICE_ID keyboardDevId; + + angleT = 0; + + uglInitialize(); + + uglDriverFind (UGL_KEYBOARD_TYPE, 0, (UGL_UINT32 *)&keyboardDevId); + + if (uglDriverFind (UGL_EVENT_SERVICE_TYPE, 0, + (UGL_UINT32 *)&eventServiceId) == UGL_STATUS_OK) + { + qId = uglEventQCreate (eventServiceId, 100); + } + else + { + eventServiceId = UGL_NULL; + } + + if (DOUBLE_BUFFER) + { + if (windMLMode) + umc = uglMesaCreateNewContext(UGL_MESA_DOUBLE + | UGL_MESA_WINDML_EXCLUSIVE, NULL); + else + umc = uglMesaCreateNewContext(UGL_MESA_DOUBLE, NULL); + } + else + { + if (windMLMode) + umc = uglMesaCreateNewContext(UGL_MESA_SINGLE + | UGL_MESA_WINDML_EXCLUSIVE, NULL); + else + umc = uglMesaCreateNewContext(UGL_MESA_SINGLE, NULL); + } + + if (umc == NULL) + { + uglDeinitialize(); + return; + } + + /* Fullscreen */ + + uglMesaMakeCurrentContext(umc, 0, 0, UGL_MESA_FULLSCREEN_WIDTH, + UGL_MESA_FULLSCREEN_HEIGHT); + + /* RGB or CI ? */ + + uglMesaGetIntegerv(UGL_MESA_RGB, &rgb); + + initGL(); + + while (!getEvent()) + drawGL(); + + uglMesaGetIntegerv(UGL_MESA_WIDTH, &width); + uglMesaGetIntegerv(UGL_MESA_HEIGHT, &height); + + printf ("glReadPixel return "); + if (rgb) + { + glReadPixels(width/2, height/2, + 1, 1, GL_RGB, + GL_UNSIGNED_BYTE, pPixels); + glFlush(); + printf ("R:%i G:%i B:%i (RGB)", pPixels[0], pPixels[1], pPixels[2]); + } + else + { + glReadPixels(width/2, height/2, + 1, 1, GL_COLOR_INDEX, + GL_UNSIGNED_BYTE, pPixels); + glFlush(); + if (pPixels[0] == BLUE) + printf ("BLUE (CI)"); + else + printf ("%i (CI))", pPixels[0]); + } + + printf(" for %ix%i\n", width/2, height/2); + + if (eventServiceId != UGL_NULL) + uglEventQDestroy (eventServiceId, qId); + + uglMesaDestroyContext(); + uglDeinitialize(); + + return; + } diff --git a/progs/windml/uglstencil.c b/progs/windml/uglstencil.c new file mode 100644 index 00000000000..07e8fc626f3 --- /dev/null +++ b/progs/windml/uglstencil.c @@ -0,0 +1,242 @@ + +/* 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. + */ +/* stencil.c + * This program draws two rotated tori in a window. + * A diamond in the center of the window masks out part + * of the scene. Within this mask, a different model + * (a sphere) is drawn in a different color. + */ + +/* + * Conversion to UGL/Mesa by Stephane Raimbault, 2001 + */ + +#include +#include + +#include +#include +#include + +#include +#include +#include + +#define YELLOWMAT 1 +#define BLUEMAT 2 + +UGL_LOCAL UGL_EVENT_SERVICE_ID eventServiceId; +UGL_LOCAL UGL_EVENT_Q_ID qId; +UGL_LOCAL UGL_MESA_CONTEXT umc; + +UGL_LOCAL void initGL (GLsizei w, GLsizei h) + { + GLfloat yellow_diffuse[] = { 0.7, 0.7, 0.0, 1.0 }; + GLfloat yellow_specular[] = { 1.0, 1.0, 1.0, 1.0 }; + + GLfloat blue_diffuse[] = { 0.1, 0.1, 0.7, 1.0 }; + GLfloat blue_specular[] = { 0.1, 1.0, 1.0, 1.0 }; + + GLfloat position_one[] = { 1.0, 1.0, 1.0, 0.0 }; + + glNewList(YELLOWMAT, GL_COMPILE); + glMaterialfv(GL_FRONT, GL_DIFFUSE, yellow_diffuse); + glMaterialfv(GL_FRONT, GL_SPECULAR, yellow_specular); + glMaterialf(GL_FRONT, GL_SHININESS, 64.0); + glEndList(); + + glNewList(BLUEMAT, GL_COMPILE); + glMaterialfv(GL_FRONT, GL_DIFFUSE, blue_diffuse); + glMaterialfv(GL_FRONT, GL_SPECULAR, blue_specular); + glMaterialf(GL_FRONT, GL_SHININESS, 45.0); + glEndList(); + + glLightfv(GL_LIGHT0, GL_POSITION, position_one); + + glEnable(GL_LIGHT0); + glEnable(GL_LIGHTING); + glDepthFunc(GL_LESS); + glEnable(GL_DEPTH_TEST); + + glClearStencil(0x0); + glEnable(GL_STENCIL_TEST); + + glClear(GL_STENCIL_BUFFER_BIT); + +/* create a diamond shaped stencil area */ + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-3.0, 3.0, -3.0, 3.0, -1.0, 1.0); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + + glStencilFunc (GL_ALWAYS, 0x1, 0x1); + glStencilOp (GL_REPLACE, GL_REPLACE, GL_REPLACE); + glBegin(GL_QUADS); + glVertex3f (-1.0, 0.0, 0.0); + glVertex3f (0.0, 1.0, 0.0); + glVertex3f (1.0, 0.0, 0.0); + glVertex3f (0.0, -1.0, 0.0); + glEnd(); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluPerspective(45.0, (GLfloat) w/(GLfloat) h, 3.0, 7.0); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTranslatef(0.0, 0.0, -5.0); + } + +/* Draw a sphere in a diamond-shaped section in the + * middle of a window with 2 tori. + */ +UGL_LOCAL void drawGL(void) + { + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + glStencilOp (GL_KEEP, GL_KEEP, GL_KEEP); + +/* draw blue sphere where the stencil is 1 */ + glStencilFunc (GL_EQUAL, 0x1, 0x1); + glCallList (BLUEMAT); + glutSolidSphere (0.5, 15, 15); + +/* draw the tori where the stencil is not 1 */ + glStencilFunc (GL_NOTEQUAL, 0x1, 0x1); + glPushMatrix(); + glRotatef (45.0, 0.0, 0.0, 1.0); + glRotatef (45.0, 0.0, 1.0, 0.0); + glCallList (YELLOWMAT); + glutSolidTorus (0.275, 0.85, 15, 15); + glPushMatrix(); + glRotatef (90.0, 1.0, 0.0, 0.0); + glutSolidTorus (0.275, 0.85, 15, 15); + glPopMatrix(); + glPopMatrix(); + + glFlush(); + + uglMesaSwapBuffers(); + } + +UGL_LOCAL int getEvent(void) + { + UGL_EVENT event; + UGL_STATUS status; + int retVal = 0; + + status = uglEventGet (qId, &event, sizeof (event), UGL_NO_WAIT); + + while (status != UGL_STATUS_Q_EMPTY) + { + UGL_INPUT_EVENT * pInputEvent = (UGL_INPUT_EVENT *)&event; + + if (pInputEvent->modifiers & UGL_KEYBOARD_KEYDOWN) + retVal = 1; + + status = uglEventGet (qId, &event, sizeof (event), UGL_NO_WAIT); + } + + return(retVal); + } + +void windMLStencil (UGL_BOOL windMLMode); + +void uglstencil (void) + { + taskSpawn("tStencil", 210, VX_FP_TASK, 100000, + (FUNCPTR)windMLStencil,UGL_FALSE,1,2,3,4,5,6,7,8,9); + } + +void windMLStencil(UGL_BOOL windMLMode) + { + UGL_INPUT_DEVICE_ID keyboardDevId; + GLsizei width, height; + + uglInitialize(); + + uglDriverFind (UGL_KEYBOARD_TYPE, 0, (UGL_UINT32 *)&keyboardDevId); + + uglDriverFind (UGL_EVENT_SERVICE_TYPE, 0, (UGL_UINT32 *)&eventServiceId); + + qId = uglEventQCreate (eventServiceId, 100); + + if (windMLMode) + umc = uglMesaCreateNewContextExt(UGL_MESA_SINGLE + | UGL_MESA_WINDML_EXCLUSIVE, + 16, + 8, + 0,0,0,0, + NULL); + else + umc = uglMesaCreateNewContextExt(UGL_MESA_SINGLE, + 16, + 8, + 0,0,0,0, + NULL); + + if (umc == NULL) + { + uglDeinitialize(); + return; + } + + /* Fullscreen */ + + uglMesaMakeCurrentContext(umc, 0, 0, UGL_MESA_FULLSCREEN_WIDTH, + UGL_MESA_FULLSCREEN_HEIGHT); + + uglMesaGetIntegerv(UGL_MESA_WIDTH, &width); + uglMesaGetIntegerv(UGL_MESA_HEIGHT, &height); + + initGL(width, height); + + drawGL(); + + while (!getEvent()); + + uglEventQDestroy (eventServiceId, qId); + + uglMesaDestroyContext(); + uglDeinitialize(); + + return; + } + diff --git a/progs/windml/uglteapot.c b/progs/windml/uglteapot.c new file mode 100644 index 00000000000..651fe0990e1 --- /dev/null +++ b/progs/windml/uglteapot.c @@ -0,0 +1,295 @@ +/* + * Mesa 3-D graphics library + * Version: 3.5 + * + * The MIT License + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT 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. + */ + +/* + * Linux Magazine July 2001 + * Conversion to UGL/Mesa from GLUT by Stephane Raimbault, 2001 + */ + +#include +#include +#include + +#include +#include +#include +#include + +#include +#include + +/* Need GLUT_SHAPES */ + +#include + +#ifndef PI +#define PI 3.14159265 +#endif + +UGL_LOCAL UGL_EVENT_SERVICE_ID eventServiceId; +UGL_LOCAL UGL_EVENT_Q_ID qId; +UGL_LOCAL UGL_MESA_CONTEXT umc; +UGL_LOCAL volatile UGL_BOOL stopWex; + +UGL_LOCAL GLint angle; +UGL_LOCAL GLfloat Sin[360], Cos[360]; +UGL_LOCAL GLfloat L0pos[]={0.0, 2.0, -1.0}; +UGL_LOCAL GLfloat L0dif[]={0.3, 0.3, 0.8}; +UGL_LOCAL GLfloat L1pos[]={2.0, 2.0, 2.0}; +UGL_LOCAL GLfloat L1dif[]={0.5, 0.5, 0.5}; +UGL_LOCAL GLfloat Mspec[3]; +UGL_LOCAL GLfloat Mshiny; +UGL_LOCAL GLuint theTeapot; + +UGL_LOCAL void calcTableCosSin() +{ + int i; + for(i=0;i<360;i++) { + Cos[i] = cos(((float)i)/180.0*PI); + Sin[i] = sin(((float)i)/180.0*PI); + } +} + +UGL_LOCAL void initGL(void) + { + glClearColor(0.0, 0.0, 0.0, 0.0); + glColor3f(1.0, 0.0, 0.0); + glEnable(GL_DEPTH_TEST); + + glShadeModel(GL_SMOOTH); + glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE); + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + glEnable(GL_LIGHT1); + glLightfv(GL_LIGHT0, GL_DIFFUSE, L0dif); + glLightfv(GL_LIGHT0, GL_SPECULAR, L0dif); + glLightfv(GL_LIGHT1, GL_DIFFUSE, L1dif); + glLightfv(GL_LIGHT1, GL_SPECULAR, L1dif); + + glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, Mspec); + glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, Mshiny); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluPerspective(45.0, 1.0, 0.1, 10.0); + glMatrixMode(GL_MODELVIEW); + + theTeapot = glGenLists(1); + glNewList(theTeapot, GL_COMPILE); + glutSolidTeapot(1.0); + glEndList(); + + } + +UGL_LOCAL void drawGL() + { + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + glLoadIdentity(); + + gluLookAt(4.5*Cos[angle], 2.0,4.5*Sin[angle],0.0,0.0,0.0,0.0, + 1.0,0.0); + glLightfv(GL_LIGHT0, GL_POSITION, L0pos); + glLightfv(GL_LIGHT1, GL_POSITION, L1pos); + + glCallList(theTeapot); + + glFlush(); + + uglMesaSwapBuffers(); + } + +UGL_LOCAL void echoUse(void) + { + printf("tTeapot keys:\n"); + printf(" Left Counter clockwise rotation (y-axis)\n"); + printf(" Right Clockwise rotation (y-axis)\n"); + printf(" j Enable/disable Light0\n"); + printf(" k Enable/disable Light1\n"); + printf(" m Add specular\n"); + printf(" l Remove specular\n"); + printf(" o Add shininess\n"); + printf(" p Remove shininess\n"); + printf(" ESC Exit\n"); + } + + +UGL_LOCAL void readKey (UGL_WCHAR key) + { + switch(key) + { + case UGL_UNI_RIGHT_ARROW: + angle +=2; + if (angle>= 360) + angle-=360; + break; + case UGL_UNI_LEFT_ARROW: + angle -=2; + if (angle<0) + angle+=360; + break; + case 'j': + glIsEnabled(GL_LIGHT0) ? + glDisable(GL_LIGHT0) : glEnable(GL_LIGHT0); + break; + case 'k': + glIsEnabled(GL_LIGHT1) ? + glDisable(GL_LIGHT1) : glEnable(GL_LIGHT1); + break; + case 'm': + Mspec[0]+=0.1; + if(Mspec[0]>1) + Mspec[0]=1; + Mspec[1]+=0.1; + if(Mspec[1]>1) + Mspec[1]=1; + Mspec[2]+=0.1; + if(Mspec[2]>1) + Mspec[2]=1; + glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, Mspec); + break; + case 'l': + Mspec[0]-=0.1; + if(Mspec[0]>1) + Mspec[0]=1; + Mspec[1]-=0.1; + if(Mspec[1]>1) + Mspec[1]=1; + Mspec[2]-=0.1; + if(Mspec[2]>1) + Mspec[2]=1; + glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, Mspec); + break; + case 'o': + Mshiny -= 1; + if (Mshiny<0) + Mshiny=0; + glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, Mshiny); + break; + case 'p': + Mshiny += 1; + if (Mshiny>128) + Mshiny=128; + glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, Mshiny); + break; + case UGL_UNI_ESCAPE: + stopWex = UGL_TRUE; + break; + } + } + +UGL_LOCAL void loopEvent(void) + { + UGL_EVENT event; + UGL_INPUT_EVENT * pInputEvent; + + UGL_FOREVER + { + if (uglEventGet (qId, &event, sizeof (event), UGL_NO_WAIT) + != UGL_STATUS_Q_EMPTY) + { + pInputEvent = (UGL_INPUT_EVENT *)&event; + + if (pInputEvent->header.type == UGL_EVENT_TYPE_KEYBOARD && + pInputEvent->modifiers & UGL_KEYBOARD_KEYDOWN) + readKey(pInputEvent->type.keyboard.key); + } + + drawGL(); + if (stopWex) + break; + } + } + +void windMLTeapot (UGL_BOOL windMLMode); + +void uglteapot (void) + { + taskSpawn ("tTeapot", 210, VX_FP_TASK, 100000, (FUNCPTR)windMLTeapot, + UGL_FALSE,1,2,3,4,5,6,7,8,9); + } + +void windMLTeapot (UGL_BOOL windMLMode) + { + UGL_INPUT_DEVICE_ID keyboardDevId; + GLsizei displayWidth, displayHeight; + GLsizei x, y, w, h; + + angle = 45; + Mspec[0] = 0.5; + Mspec[1] = 0.5; + Mspec[2] = 0.5; + Mshiny = 50; + + uglInitialize (); + + uglDriverFind (UGL_KEYBOARD_TYPE, 0, + (UGL_UINT32 *)&keyboardDevId); + + uglDriverFind (UGL_EVENT_SERVICE_TYPE, 0, (UGL_UINT32 *)&eventServiceId); + + qId = uglEventQCreate (eventServiceId, 100); + + /* Double buffering */ + if (windMLMode) + umc = uglMesaCreateNewContext(UGL_MESA_DOUBLE + | UGL_MESA_WINDML_EXCLUSIVE, NULL); + else + umc = uglMesaCreateNewContext(UGL_MESA_DOUBLE, NULL); + + if (umc == NULL) + { + uglDeinitialize (); + return; + } + + uglMesaMakeCurrentContext (umc, 0, 0, 1, 1); + + uglMesaGetIntegerv(UGL_MESA_DISPLAY_WIDTH, &displayWidth); + uglMesaGetIntegerv(UGL_MESA_DISPLAY_HEIGHT, &displayHeight); + + h = (displayHeight*2)/3; + w = h; + x = (displayWidth-w)/2; + y = (displayHeight-h)/2; + + uglMesaMoveToWindow(x, y); + uglMesaResizeToWindow(w, h); + + calcTableCosSin(); + + initGL (); + + echoUse(); + + stopWex = UGL_FALSE; + loopEvent(); + + uglEventQDestroy (eventServiceId, qId); + + uglMesaDestroyContext(); + uglDeinitialize (); + + return; + } diff --git a/progs/windml/ugltexcube.c b/progs/windml/ugltexcube.c new file mode 100644 index 00000000000..62b0306e647 --- /dev/null +++ b/progs/windml/ugltexcube.c @@ -0,0 +1,379 @@ + +/* ugltexcube.c - WindML/Mesa example program */ + +/* Copyright (C) 2001 by Wind River Systems, Inc */ + +/* + * Mesa 3-D graphics library + * Version: 3.5 + * + * The MIT License + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT 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. + */ + +/* + * Authors: + * Stephane Raimbault + */ + +/* +DESCRIPTION +Draw a textured cube +*/ + +#include +#include +#include + +#include +#include +#include +#include +#include + +#include "../util/readtex.h" + +#define IMAGE_FILE "Mesa/images/wrs_logo.rgb" + +UGL_LOCAL UGL_EVENT_SERVICE_ID eventServiceId; +UGL_LOCAL UGL_EVENT_Q_ID qId; +UGL_LOCAL UGL_MESA_CONTEXT umc; + +UGL_LOCAL GLfloat xrot, yrot, zrot; +UGL_LOCAL GLuint texture[1]; +UGL_LOCAL GLuint theTexCube; + +typedef struct { + GLubyte *data; + int width, height; + GLenum format; + } TEX_IMAGE; + +UGL_LOCAL void cleanUp (void); + +UGL_LOCAL void loadGLTexture() + { + TEX_IMAGE * texImage=NULL; + + texImage = (TEX_IMAGE *) malloc(sizeof(TEX_IMAGE)); + + if (texImage == NULL) + { + printf("Error allocating space for image"); + cleanUp(); + exit(1); + } + + texImage->data = LoadRGBImage(IMAGE_FILE, &texImage->width, + &texImage->height, &texImage->format); + if (!texImage->data) + { + printf("Couldn't read %s\n", IMAGE_FILE); + free(texImage); + cleanUp(); + exit(1); + } + + /* Create Texture */ + glGenTextures(1, &texture[0]); + glBindTexture(GL_TEXTURE_2D, texture[0]); + glTexImage2D(GL_TEXTURE_2D, 0, 3, + texImage->width, texImage->height, + 0, GL_RGB, GL_UNSIGNED_BYTE, texImage->data); + + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + + free(texImage->data); + free(texImage); + } + +UGL_LOCAL void initGL(int width, int height) + { + + /* Load the texture(s) */ + loadGLTexture(); + + /* Enable texture mapping */ + glEnable(GL_TEXTURE_2D); + + /* Clear the background color to black */ + glClearColor(0.0f, 0.0f, 0.0f, 0.0f); + + glEnable(GL_CULL_FACE); + + /* Enables smooth color shading */ + glShadeModel(GL_SMOOTH); + +/* glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); */ +/* glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST); */ + + theTexCube = glGenLists(1); + glNewList(theTexCube, GL_COMPILE); + + /* Choose the texture to use */ + glBindTexture(GL_TEXTURE_2D, texture[0]); + + /* Begin drawing a cube */ + glBegin(GL_QUADS); + + /* Front face (note that the texture's corners have to match the + quad's corners) */ + + /* Bottom left of the texture and quad */ + glTexCoord2f(0.0f, 0.0f); + glVertex3f(-1.0f, -1.0f, 1.0f); + + /* Bottom Right Of The Texture and Quad */ + glTexCoord2f(1.0f, 0.0f); + glVertex3f(1.0f, -1.0f, 1.0f); + + /* Top Right Of The Texture and Quad */ + glTexCoord2f(1.0f, 1.0f); + glVertex3f(1.0f, 1.0f, 1.0f); + /* Top Left Of The Texture and Quad */ + glTexCoord2f(0.0f, 1.0f); + glVertex3f(-1.0f, 1.0f, 1.0f); + + /* Back Face */ + + /* Bottom Right Of The Texture and Quad */ + glTexCoord2f(1.0f, 0.0f); + glVertex3f(-1.0f, -1.0f, -1.0f); + + /* Top Right Of The Texture and Quad */ + glTexCoord2f(1.0f, 1.0f); + glVertex3f(-1.0f, 1.0f, -1.0f); + + /* Top Left Of The Texture and Quad */ + glTexCoord2f(0.0f, 1.0f); + glVertex3f(1.0f, 1.0f, -1.0f); + + /* Bottom Left Of The Texture and Quad */ + glTexCoord2f(0.0f, 0.0f); + glVertex3f(1.0f, -1.0f, -1.0f); + + + /* Top Face */ + + /* Top Left Of The Texture and Quad */ + glTexCoord2f(0.0f, 1.0f); + glVertex3f(-1.0f, 1.0f, -1.0f); + + /* Bottom Left Of The Texture and Quad */ + glTexCoord2f(0.0f, 0.0f); + glVertex3f(-1.0f, 1.0f, 1.0f); + + /* Bottom Right Of The Texture and Quad */ + glTexCoord2f(1.0f, 0.0f); + glVertex3f(1.0f, 1.0f, 1.0f); + + /* Top Right Of The Texture and Quad */ + glTexCoord2f(1.0f, 1.0f); + glVertex3f(1.0f, 1.0f, -1.0f); + + /* Bottom Face */ + + /* Top Right Of The Texture and Quad */ + glTexCoord2f(1.0f, 1.0f); + glVertex3f(-1.0f, -1.0f, -1.0f); + + /* Top Left Of The Texture and Quad */ + glTexCoord2f(0.0f, 1.0f); + glVertex3f(1.0f, -1.0f, -1.0f); + + /* Bottom Left Of The Texture and Quad */ + glTexCoord2f(0.0f, 0.0f); + glVertex3f(1.0f, -1.0f, 1.0f); + + /* Bottom Right Of The Texture and Quad */ + glTexCoord2f(1.0f, 0.0f); + glVertex3f(-1.0f, -1.0f, 1.0f); + + + /* Right face */ + /* Bottom Right Of The Texture and Quad */ + glTexCoord2f(1.0f, 0.0f); + glVertex3f(1.0f, -1.0f, -1.0f); + + /* Top Right Of The Texture and Quad */ + glTexCoord2f(1.0f, 1.0f); + glVertex3f(1.0f, 1.0f, -1.0f); + + /* Top Left Of The Texture and Quad */ + glTexCoord2f(0.0f, 1.0f); + glVertex3f(1.0f, 1.0f, 1.0f); + + /* Bottom Left Of The Texture and Quad */ + glTexCoord2f(0.0f, 0.0f); + glVertex3f(1.0f, -1.0f, 1.0f); + + + /* Left Face */ + /* Bottom Left Of The Texture and Quad */ + glTexCoord2f(0.0f, 0.0f); + glVertex3f(-1.0f, -1.0f, -1.0f); + + /* Bottom Right Of The Texture and Quad */ + glTexCoord2f(1.0f, 0.0f); + glVertex3f(-1.0f, -1.0f, 1.0f); + + /* Top Right Of The Texture and Quad */ + glTexCoord2f(1.0f, 1.0f); + glVertex3f(-1.0f, 1.0f, 1.0f); + + /* Top Left Of The Texture and Quad */ + glTexCoord2f(0.0f, 1.0f); + glVertex3f(-1.0f, 1.0f, -1.0f); + + glEnd(); /* done with the polygon */ + glEndList(); + + glDisable(GL_DITHER); + glMatrixMode(GL_PROJECTION); + /* Reset the projection matrix */ + glLoadIdentity(); + /* Calculate the aspect ratio of the window */ + gluPerspective(45.0f, (GLfloat) width / (GLfloat) height, 0.1f, 100.0f); + + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + } + +UGL_LOCAL void drawGL() + { + glClear(GL_COLOR_BUFFER_BIT); + + /* Reset The View */ + glPushMatrix(); + + /* Move 8 units into the screen */ + glTranslatef(0.0f, 0.0f, -8.0f); + + /* Rotate on the X axis */ + glRotatef(xrot, 1.0f, 0.0f, 0.0f); + + /* Rotate on the Y axis */ + glRotatef(yrot, 0.0f, 1.0f, 0.0f); + + /* Rotate On The Z Axis */ + glRotatef(zrot, 0.0f, 0.0f, 1.0f); + + glCallList(theTexCube); + + glFlush(); + + uglMesaSwapBuffers(); + + glPopMatrix(); + + xrot += 1.6f; + yrot += 1.6f; + zrot += 1.6f; +} + +UGL_LOCAL int getEvent(void) + { + UGL_EVENT event; + UGL_STATUS status; + int retVal = 0; + + status = uglEventGet (qId, &event, sizeof (event), UGL_NO_WAIT); + + while (status != UGL_STATUS_Q_EMPTY) + { + UGL_INPUT_EVENT * pInputEvent = (UGL_INPUT_EVENT *)&event; + + if (pInputEvent->modifiers & UGL_KEYBOARD_KEYDOWN) + retVal = 1; + + status = uglEventGet (qId, &event, sizeof (event), UGL_NO_WAIT); + } + + return(retVal); + } + +UGL_LOCAL void cleanUp (void) + { + if (eventServiceId != UGL_NULL) + uglEventQDestroy (eventServiceId, qId); + + uglMesaDestroyContext(); + uglDeinitialize(); + } + +void windMLTexCube (UGL_BOOL windMLMode); + +void ugltexcube (void) + { + taskSpawn("tTexCube", 210, VX_FP_TASK, 100000, (FUNCPTR)windMLTexCube, + UGL_FALSE,1,2,3,4,5,6,7,8,9); + } + + +void windMLTexCube(UGL_BOOL windMLMode) + { + GLuint width, height; + UGL_INPUT_DEVICE_ID keyboardDevId; + + uglInitialize(); + + uglDriverFind (UGL_KEYBOARD_TYPE, 0, (UGL_UINT32 *)&keyboardDevId); + + if (uglDriverFind (UGL_EVENT_SERVICE_TYPE, 0, + (UGL_UINT32 *)&eventServiceId) == UGL_STATUS_OK) + { + qId = uglEventQCreate (eventServiceId, 100); + } + else + { + eventServiceId = UGL_NULL; + } + + if (windMLMode) + umc = uglMesaCreateNewContext(UGL_MESA_DOUBLE + | UGL_MESA_WINDML_EXCLUSIVE, NULL); + else + umc = uglMesaCreateNewContext(UGL_MESA_DOUBLE, NULL); + + if (umc == NULL) + { + uglDeinitialize(); + return; + } + + uglMesaMakeCurrentContext(umc, 0, 0, + UGL_MESA_FULLSCREEN_WIDTH, + UGL_MESA_FULLSCREEN_HEIGHT); + + + uglMesaGetIntegerv(UGL_MESA_WIDTH, &width); + uglMesaGetIntegerv(UGL_MESA_HEIGHT, &height); + + initGL(width, height); + + while(!getEvent()) + drawGL(); + + cleanUp(); + + return; + } + + diff --git a/progs/windml/ugltexcyl.c b/progs/windml/ugltexcyl.c new file mode 100644 index 00000000000..cd453a3407f --- /dev/null +++ b/progs/windml/ugltexcyl.c @@ -0,0 +1,407 @@ +/* + * Textured cylinder demo: lighting, texturing, reflection mapping. + * + * Brian Paul May 1997 This program is in the public domain. + * + * Conversion to UGL/Mesa by Stephane Raimbault + */ + +/* + * $Log: ugltexcyl.c,v $ + * Revision 1.2 2001-09-10 19:21:13 brianp + * WindML updates (Stephane Raimbault) + * + * Revision 1.1 2001/08/20 16:07:11 brianp + * WindML driver (Stephane Raimbault) + * + * Revision 1.5 2001/03/27 17:35:26 brianp + * set initial window pos + * + * Revision 1.4 2000/12/24 22:53:54 pesco + * * demos/Makefile.am (INCLUDES): Added -I$(top_srcdir)/util. + * * demos/Makefile.X11, demos/Makefile.BeOS-R4, demos/Makefile.cygnus: + * Essentially the same. + * Program files updated to include "readtex.c", not "../util/readtex.c". + * * demos/reflect.c: Likewise for "showbuffer.c". + * + * + * * Makefile.am (EXTRA_DIST): Added top-level regular files. + * + * * include/GL/Makefile.am (INC_X11): Added glxext.h. + * + * + * * src/GGI/include/ggi/mesa/Makefile.am (EXTRA_HEADERS): Include + * Mesa GGI headers in dist even if HAVE_GGI is not given. + * + * * configure.in: Look for GLUT and demo source dirs in $srcdir. + * + * * src/swrast/Makefile.am (libMesaSwrast_la_SOURCES): Set to *.[ch]. + * More source list updates in various Makefile.am's. + * + * * Makefile.am (dist-hook): Remove CVS directory from distribution. + * (DIST_SUBDIRS): List all possible subdirs here. + * (SUBDIRS): Only list subdirs selected for build again. + * The above two applied to all subdir Makefile.am's also. + * + * Revision 1.3 2000/09/29 23:09:39 brianp + * added fps output + * + * 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.3 1999/03/28 18:24:37 brianp + * minor clean-up + * + * Revision 3.2 1998/11/05 04:34:04 brianp + * moved image files to ../images/ directory + * + * Revision 3.1 1998/06/23 03:16:51 brianp + * added Point/Linear sampling menu items + * + * Revision 3.0 1998/02/14 18:42:29 brianp + * initial rev + * + */ + + +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include + +#include "../util/readtex.h" + +#define TEXTURE_FILE "Mesa/images/reflect.rgb" + +#define LIT 1 +#define TEXTURED 2 +#define REFLECT 3 +#define ANIMATE 10 +#define POINT_FILTER 20 +#define LINEAR_FILTER 21 +#define QUIT 100 +#define COUNT_FRAMES + +UGL_LOCAL UGL_EVENT_SERVICE_ID eventServiceId; +UGL_LOCAL UGL_EVENT_Q_ID qId; +UGL_LOCAL volatile UGL_BOOL stopWex; +UGL_LOCAL UGL_MESA_CONTEXT umc; + +UGL_LOCAL GLuint CylinderObj; +UGL_LOCAL GLboolean Animate; +UGL_LOCAL GLboolean linearFilter; + +UGL_LOCAL GLfloat Xrot, Yrot, Zrot; +UGL_LOCAL GLfloat DXrot, DYrot; + +UGL_LOCAL GLuint limit; +UGL_LOCAL GLuint count; +UGL_LOCAL GLuint tickStart, tickStop, tickBySec; + +UGL_LOCAL void cleanUp (void); + +UGL_LOCAL void drawGL(void) + { +#ifdef COUNT_FRAMES + int time; +#endif + + glClear( GL_COLOR_BUFFER_BIT ); + + glPushMatrix(); + glRotatef(Xrot, 1.0, 0.0, 0.0); + glRotatef(Yrot, 0.0, 1.0, 0.0); + glRotatef(Zrot, 0.0, 0.0, 1.0); + glScalef(5.0, 5.0, 5.0); + glCallList(CylinderObj); + + glPopMatrix(); + + uglMesaSwapBuffers(); + + if (Animate) + { + Xrot += DXrot; + Yrot += DYrot; + } + +#ifdef COUNT_FRAMES + if (count > limit) + { + tickStop = tickGet (); + time = (tickStop-tickStart)/tickBySec; + printf (" %i fps\n", count/time); + tickStart = tickStop; + count = 0; + } + else + count++; +#endif + + } + +UGL_LOCAL void echoUse(void) + { + printf("Keys:\n"); + printf(" Up/Down Rotate on Y\n"); + printf(" Left/Right Rotate on X\n"); + printf(" a Toggle animation\n"); + printf(" f Toggle point/linear filtered\n"); + printf(" l Lit\n"); + printf(" t Textured\n"); + printf(" r Reflect\n"); + printf(" ESC Exit\n"); + } + +UGL_LOCAL void readKey(UGL_WCHAR key) + { + float step = 3.0; + switch (key) + { + case 'a': + Animate = !Animate; + break; + case 'f': + if(linearFilter) + { + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, + GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, + GL_NEAREST); + } + else + { + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, + GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, + GL_LINEAR); + } + linearFilter = !linearFilter; + break; + case 'l': + glEnable(GL_LIGHTING); + glDisable(GL_TEXTURE_2D); + glDisable(GL_TEXTURE_GEN_S); + glDisable(GL_TEXTURE_GEN_T); + break; + case 't': + glDisable(GL_LIGHTING); + glEnable(GL_TEXTURE_2D); + glDisable(GL_TEXTURE_GEN_S); + glDisable(GL_TEXTURE_GEN_T); + break; + case 'r': + glDisable(GL_LIGHTING); + glEnable(GL_TEXTURE_2D); + glEnable(GL_TEXTURE_GEN_S); + glEnable(GL_TEXTURE_GEN_T); + break; + case UGL_UNI_UP_ARROW: + Xrot += step; + break; + case UGL_UNI_DOWN_ARROW: + Xrot -= step; + break; + case UGL_UNI_LEFT_ARROW: + Yrot += step; + break; + case UGL_UNI_RIGHT_ARROW: + Yrot -= step; + break; + case UGL_UNI_ESCAPE: + stopWex = UGL_TRUE; + break; + } + } + +UGL_LOCAL void loopEvent(void) + { + UGL_EVENT event; + UGL_INPUT_EVENT * pInputEvent; + + UGL_FOREVER + { + if (uglEventGet (qId, &event, sizeof (event), UGL_NO_WAIT) + != UGL_STATUS_Q_EMPTY) + { + pInputEvent = (UGL_INPUT_EVENT *)&event; + + if (pInputEvent->header.type == UGL_EVENT_TYPE_KEYBOARD && + pInputEvent->modifiers & UGL_KEYBOARD_KEYDOWN) + readKey(pInputEvent->type.keyboard.key); + } + + drawGL(); + if (stopWex) + break; + } + } + +UGL_LOCAL void initGL(void) + { + GLUquadricObj *q = gluNewQuadric(); + CylinderObj = glGenLists(1); + glNewList(CylinderObj, GL_COMPILE); + + glTranslatef(0.0, 0.0, -1.0); + + /* cylinder */ + gluQuadricNormals(q, GL_SMOOTH); + gluQuadricTexture(q, GL_TRUE); + gluCylinder(q, 0.6, 0.6, 2.0, 24, 1); + + /* end cap */ + glTranslatef(0.0, 0.0, 2.0); + gluDisk(q, 0.0, 0.6, 24, 1); + + /* other end cap */ + glTranslatef(0.0, 0.0, -2.0); + gluQuadricOrientation(q, GLU_INSIDE); + gluDisk(q, 0.0, 0.6, 24, 1); + + glEndList(); + gluDeleteQuadric(q); + + /* lighting */ + glEnable(GL_LIGHTING); + { + GLfloat gray[4] = {0.2, 0.2, 0.2, 1.0}; + GLfloat white[4] = {1.0, 1.0, 1.0, 1.0}; + GLfloat teal[4] = { 0.0, 1.0, 0.8, 1.0 }; + glMaterialfv(GL_FRONT, GL_DIFFUSE, teal); + glLightfv(GL_LIGHT0, GL_AMBIENT, gray); + glLightfv(GL_LIGHT0, GL_DIFFUSE, white); + glEnable(GL_LIGHT0); + } + + /* fitering = nearest, initially */ + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + + 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); + glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); + + if (!LoadRGBMipmaps(TEXTURE_FILE, GL_RGB)) + { + printf("Error: couldn't load texture image\n"); + cleanUp(); + exit(1); + } + + glEnable(GL_CULL_FACE); /* don't need Z testing for convex objects */ + + glEnable(GL_LIGHTING); + + glMatrixMode( GL_PROJECTION ); + glLoadIdentity(); + glFrustum( -1.0, 1.0, -1.0, 1.0, 10.0, 100.0 ); + glMatrixMode( GL_MODELVIEW ); + glLoadIdentity(); + glTranslatef( 0.0, 0.0, -70.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)); + +#ifdef COUNT_FRAMES + tickStart = tickGet (); + tickBySec = sysClkRateGet (); +#endif + + } + +UGL_LOCAL void cleanUp (void) + { + uglEventQDestroy (eventServiceId, qId); + + uglMesaDestroyContext(); + uglDeinitialize (); + } + +void windMLTexCyl (UGL_BOOL windMLMode); + +void ugltexcyl (void) + { + taskSpawn ("tTexCyl", 210, VX_FP_TASK, 100000, (FUNCPTR)windMLTexCyl, + UGL_FALSE,1,2,3,4,5,6,7,8,9); + } + +void windMLTexCyl (UGL_BOOL windMLMode) + { + UGL_INPUT_DEVICE_ID keyboardDevId; + GLsizei displayWidth, displayHeight; + GLsizei x, y, w, h; + + CylinderObj = 0; + Animate = GL_TRUE; + linearFilter = GL_FALSE; + Xrot = 0.0; + Yrot = 0.0; + Zrot = 0.0; + DXrot = 1.0; + DYrot = 2.5; + limit = 100; + count = 1; + + uglInitialize (); + + uglDriverFind (UGL_KEYBOARD_TYPE, 0, + (UGL_UINT32 *)&keyboardDevId); + + uglDriverFind (UGL_EVENT_SERVICE_TYPE, 0, (UGL_UINT32 *)&eventServiceId); + + qId = uglEventQCreate (eventServiceId, 100); + + /* Double buffering */ + if (windMLMode) + umc = uglMesaCreateNewContext(UGL_MESA_DOUBLE + | UGL_MESA_WINDML_EXCLUSIVE, NULL); + else + umc = uglMesaCreateNewContext(UGL_MESA_DOUBLE, NULL); + + if (umc == NULL) + { + uglDeinitialize (); + return; + } + + uglMesaMakeCurrentContext (umc, 0, 0, 1, 1); + + uglMesaGetIntegerv(UGL_MESA_DISPLAY_WIDTH, &displayWidth); + uglMesaGetIntegerv(UGL_MESA_DISPLAY_HEIGHT, &displayHeight); + + h = (displayHeight*3)/4; + w = h; + x = (displayWidth-w)/2; + y = (displayHeight-h)/2; + + uglMesaMoveToWindow(x, y); + uglMesaResizeToWindow(w, h); + + initGL (); + + echoUse(); + + stopWex = UGL_FALSE; + loopEvent(); + + cleanUp(); + + return; + } + diff --git a/progs/windml/wrs_logo.bmp b/progs/windml/wrs_logo.bmp new file mode 100644 index 00000000000..9a9f04255be Binary files /dev/null and b/progs/windml/wrs_logo.bmp differ diff --git a/progs/xdemos/.cvsignore b/progs/xdemos/.cvsignore new file mode 100644 index 00000000000..4adffda2d1e --- /dev/null +++ b/progs/xdemos/.cvsignore @@ -0,0 +1,16 @@ +glthreads +glxdemo +glxgears +glxheads +glxinfo +glxpixmap +glxpbdemo +glxswapcontrol +manywin +offset +pbinfo +pbdemo +wincopy +xdemo +xfont +xrotfontdemo diff --git a/progs/xdemos/Makefile b/progs/xdemos/Makefile new file mode 100644 index 00000000000..37b9504e55d --- /dev/null +++ b/progs/xdemos/Makefile @@ -0,0 +1,83 @@ +# progs/xdemos/Makefile + +TOP = ../.. +include $(TOP)/configs/current + + +INCDIR = $(TOP)/include + +LIB_DEP = $(LIB_DIR)/$(GL_LIB_NAME) $(LIB_DIR)/$(GLU_LIB_NAME) + +PROGS = glthreads \ + glxdemo \ + glxgears \ + glxgears_fbconfig \ + glxcontexts \ + glxheads \ + glxinfo \ + glxpixmap \ + glxpbdemo \ + glxswapcontrol \ + manywin \ + offset \ + overlay \ + pbinfo \ + pbdemo \ + wincopy \ + xdemo \ + xfont \ + xrotfontdemo \ + yuvrect_client + + + +##### RULES ##### + +.SUFFIXES: +.SUFFIXES: .c + +.c: $(LIB_DEP) + $(CC) -I$(INCDIR) $(CFLAGS) $< $(APP_LIB_DEPS) -o $@ + + +##### TARGETS ##### + +default: $(PROGS) + + +clean: + -rm -f $(PROGS) + -rm -f *.o *~ + + +# special cases +pbinfo: pbinfo.o pbutil.o + $(CC) -I$(INCDIR) $(CFLAGS) pbinfo.o pbutil.o $(APP_LIB_DEPS) -o $@ + +pbdemo: pbdemo.o pbutil.o + $(CC) -I$(INCDIR) $(CFLAGS) pbdemo.o pbutil.o $(APP_LIB_DEPS) -o $@ + +pbinfo.o: pbinfo.c pbutil.h + $(CC) -c -I. -I$(INCDIR) $(CFLAGS) pbinfo.c + +pbdemo.o: pbdemo.c pbutil.h + $(CC) -c -I. -I$(INCDIR) $(CFLAGS) pbdemo.c + +pbutil.o: pbutil.c pbutil.h + $(CC) -c -I. -I$(INCDIR) $(CFLAGS) pbutil.c + +glxgears_fbconfig: glxgears_fbconfig.o pbutil.o + $(CC) -I$(INCDIR) $(CFLAGS) glxgears_fbconfig.o pbutil.o $(APP_LIB_DEPS) -o $@ + +glxgears_fbconfig.o: glxgears_fbconfig.c pbutil.h + $(CC) -I$(INCDIR) $(CFLAGS) -c -I. $(CFLAGS) glxgears_fbconfig.c + +xrotfontdemo: xrotfontdemo.o xuserotfont.o + $(CC) -I$(INCDIR) $(CFLAGS) xrotfontdemo.o xuserotfont.o $(APP_LIB_DEPS) -o $@ + +xuserotfont.o: xuserotfont.c xuserotfont.h + $(CC) -c -I. -I$(INCDIR) $(CFLAGS) xuserotfont.c + +xrotfontdemo.o: xrotfontdemo.c xuserotfont.h + $(CC) -c -I. -I$(INCDIR) $(CFLAGS) xrotfontdemo.c + diff --git a/progs/xdemos/descrip.mms b/progs/xdemos/descrip.mms new file mode 100644 index 00000000000..aa74daff599 --- /dev/null +++ b/progs/xdemos/descrip.mms @@ -0,0 +1,83 @@ +# Makefile for GLUT-based demo programs for VMS +# contributed by Jouk Jansen joukj@hrem.stm.tudelft.nl + + +.first + define gl [--.include.gl] + +.include [--]mms-config. + +##### MACROS ##### + +INCDIR = ([--.include],[-.util]) +CFLAGS = /include=$(INCDIR)/prefix=all/name=(as_is,short)/nowarn/float=ieee/ieee=denorm + +.ifdef SHARE +GL_LIBS = $(XLIBS) +.else +GL_LIBS = [--.lib]libGLUT/l,libMesaGLU/l,libMesaGL/l,$(XLIBS) +.endif + +LIB_DEP = [--.lib]$(GL_LIB) [--.lib]$(GLU_LIB) [--.lib]$(GLUT_LIB) + +PROGS =glthreads.exe,\ + glxdemo.exe,\ + glxgears.exe,\ + glxheads.exe,\ + glxinfo.exe,\ + glxpixmap.exe,\ + manywin.exe,\ + offset.exe,\ + pbinfo.exe,\ + pbdemo.exe,\ + wincopy.exe,\ + xdemo.exe,\ + xfont.exe + +##### RULES ##### +.obj.exe : + cxxlink $(MMS$TARGET_NAME),$(GL_LIBS) + +##### TARGETS ##### +default : + $(MMS)$(MMSQUALIFIERS) $(PROGS) + +clean : + delete *.obj;* + +realclean : + delete $(PROGS) + delete *.obj;* + + +glthreads.exe : glthreads.obj $(LIB_DEP) +glxdemo.exe : glxdemo.obj $(LIB_DEP) +glxgears.exe : glxgears.obj $(LIB_DEP) +glxheads.exe : glxheads.obj $(LIB_DEP) +glxinfo.exe : glxinfo.obj $(LIB_DEP) +glxpixmap.exe : glxpixmap.obj $(LIB_DEP) +manywin.exe : manywin.obj $(LIB_DEP) +offset.exe : offset.obj $(LIB_DEP) +pbinfo.exe : pbinfo.obj pbutil.obj $(LIB_DEP) + cxxlink pbinfo.obj,pbutil.obj,$(GL_LIBS) +pbdemo.exe : pbdemo.obj pbutil.obj $(LIB_DEP) + cxxlink pbdemo.obj,pbutil.obj,$(GL_LIBS) +wincopy.exe : wincopy.obj $(LIB_DEP) +xdemo.exe : xdemo.obj $(LIB_DEP) +xfont.exe :xfont.obj $(LIB_DEP) + + +glthreads.obj : glthreads.c +glxdemo.obj : glxdemo.c +glxgears.obj : glxgears.c +glxheads.obj : glxheads.c +glxinfo.obj : glxinfo.c +glxpixmap.obj : glxpixmap.c +manywin.obj : manywin.c +offset.obj : offset.c +pbinfo.obj : pbinfo.c +pbutil.obj : pbutil.c +pbdemo.obj : pbdemo.c +wincopy.obj : wincopy.c +xdemo.obj : xdemo.c +xfont.obj :xfont.c diff --git a/progs/xdemos/glthreads.c b/progs/xdemos/glthreads.c new file mode 100644 index 00000000000..83413383dd4 --- /dev/null +++ b/progs/xdemos/glthreads.c @@ -0,0 +1,544 @@ +/* + * 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: + * -p Open a display connection for each thread + * -n Number of threads to create (default is 2) + * -display Specify X display (default is :0.0) + * + * Brian Paul 20 July 2000 + */ + + +#if defined(PTHREADS) /* defined by Mesa on Linux and other platforms */ + +#include +#include +#include +#include +#include +#include +#include +#include + + +/* + * 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 volatile GLboolean ExitFlag = GL_FALSE; + +static GLboolean MultiDisplays = 0; +static GLboolean Locking = 0; + +static pthread_mutex_t Mutex; + + +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) +{ + GLboolean firstIter = GL_TRUE; + + while (!ExitFlag) { + + if (Locking) + pthread_mutex_lock(&Mutex); + + glXMakeCurrent(wt->Dpy, wt->Win, wt->Context); + if (firstIter) { + printf("glthreads: %d: GL_RENDERER = %s\n", wt->Index, + (char *) glGetString(GL_RENDERER)); + firstIter = GL_FALSE; + } + + if (Locking) + pthread_mutex_unlock(&Mutex); + + 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(); + + if (Locking) + pthread_mutex_lock(&Mutex); + + glXSwapBuffers(wt->Dpy, wt->Win); + + if (Locking) + pthread_mutex_unlock(&Mutex); + + usleep(5000); + wt->Angle += 1.0; + } +} + + +/* + * The main process thread runs this loop. + * Single display connection for all threads. + */ +static void +event_loop(Display *dpy) +{ + XEvent event; + int i; + + assert(!MultiDisplays); + + while (!ExitFlag) { + + if (Locking) { + while (1) { + int k; + pthread_mutex_lock(&Mutex); + k = XPending(dpy); + if (k) { + XNextEvent(dpy, &event); + pthread_mutex_unlock(&Mutex); + break; + } + pthread_mutex_unlock(&Mutex); + usleep(5000); + } + } + else { + XNextEvent(dpy, &event); + } + + switch (event.type) { + case ConfigureNotify: + /* Find winthread for this event's window */ + for (i = 0; i < NumWinThreads; i++) { + struct winthread *wt = &WinThreads[i]; + if (event.xconfigure.window == wt->Win) { + resize(wt, event.xconfigure.width, + event.xconfigure.height); + break; + } + } + break; + case KeyPress: + /* tell all threads to exit */ + ExitFlag = GL_TRUE; + /*printf("exit draw_loop %d\n", wt->Index);*/ + return; + default: + /*no-op*/ ; + } + } +} + + +/* + * Separate display connection for each thread. + */ +static void +event_loop_multi(void) +{ + XEvent event; + int w = 0; + + assert(MultiDisplays); + + while (!ExitFlag) { + struct winthread *wt = &WinThreads[w]; + if (XPending(wt->Dpy)) { + XNextEvent(wt->Dpy, &event); + 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*/ ; + } + } + w = (w + 1) % NumWinThreads; + usleep(5000); + } +} + + + +/* + * 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 = NULL; + int i; + Status threadStat; + + if (argc == 1) { + printf("glthreads: test of GL thread safety (any key = exit)\n"); + printf("Usage:\n"); + printf(" glthreads [-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], "-p") == 0) { + MultiDisplays = 1; + } + else if (strcmp(argv[i], "-l") == 0) { + Locking = 1; + } + 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++; + } + else { + fprintf(stderr, "glthreads: unexpected flag: %s\n", argv[i]); + } + } + } + + if (Locking) + printf("glthreads: Using explict locks around Xlib calls.\n"); + else + printf("glthreads: No explict locking.\n"); + + if (MultiDisplays) + printf("glthreads: Per-thread display connections.\n"); + else + printf("glthreads: Single display connection.\n"); + + /* + * VERY IMPORTANT: call XInitThreads() before any other Xlib functions. + */ + if (!MultiDisplays) { + if (!Locking) { + 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; + } + } + + if (Locking) { + pthread_mutex_init(&Mutex, NULL); + } + + printf("glthreads: creating windows\n"); + + NumWinThreads = numThreads; + + /* Create the GLX windows and contexts */ + for (i = 0; i < numThreads; i++) { + if (MultiDisplays) { + WinThreads[i].Dpy = XOpenDisplay(displayName); + assert(WinThreads[i].Dpy); + } + else { + WinThreads[i].Dpy = dpy; + } + WinThreads[i].Index = i; + create_window(&WinThreads[i]); + } + + printf("glthreads: creating threads\n"); + + /* Create the threads */ + for (i = 0; i < numThreads; i++) { + pthread_create(&WinThreads[i].Thread, NULL, thread_function, + (void*) &WinThreads[i]); + printf("glthreads: Created thread %u\n", (unsigned int) WinThreads[i].Thread); + } + + if (MultiDisplays) + event_loop_multi(); + else + event_loop(dpy); + + clean_up(); + + if (MultiDisplays) { + for (i = 0; i < numThreads; i++) { + XCloseDisplay(WinThreads[i].Dpy); + } + } + else { + XCloseDisplay(dpy); + } + + return 0; +} + + +#else /* PTHREADS */ + + +#include + +int +main(int argc, char *argv[]) +{ + printf("Sorry, this program wasn't compiled with PTHREADS defined.\n"); + return 0; +} + + +#endif /* PTHREADS */ diff --git a/progs/xdemos/glxcontexts.c b/progs/xdemos/glxcontexts.c new file mode 100644 index 00000000000..fbc296ef625 --- /dev/null +++ b/progs/xdemos/glxcontexts.c @@ -0,0 +1,609 @@ +/* + * Copyright (C) 1999-2001 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 port of the infamous "gears" demo to straight GLX (i.e. no GLUT) + * Port by Brian Paul 23 March 2001 + * + * Command line options: + * -info print GL implementation information + * -stereo use stereo enabled GLX visual + * + */ + + +#include +#include +#include +#include +#include +#include +#include +#include + + +#define BENCHMARK + +#ifdef BENCHMARK + +/* XXX this probably isn't very portable */ + +#include +#include + +/* return current time (in seconds) */ +static double +current_time(void) +{ + struct timeval tv; +#ifdef __VMS + (void) gettimeofday(&tv, NULL ); +#else + struct timezone tz; + (void) gettimeofday(&tv, &tz); +#endif + return (double) tv.tv_sec + tv.tv_usec / 1000000.0; +} + +#else /*BENCHMARK*/ + +/* dummy */ +static double +current_time(void) +{ + /* update this function for other platforms! */ + static double t = 0.0; + static int warn = 1; + if (warn) { + fprintf(stderr, "Warning: current_time() not implemented!!\n"); + warn = 0; + } + return t += 1.0; +} + +#endif /*BENCHMARK*/ + + + +#ifndef M_PI +#define M_PI 3.14159265 +#endif + + +static GLfloat view_rotx = 20.0, view_roty = 30.0, view_rotz = 0.0; +static GLint gear1, gear2, gear3; +static GLfloat angle = 0.0; + +static GLboolean fullscreen = GL_FALSE; /* Create a single fullscreen window */ +static GLboolean stereo = GL_FALSE; /* Enable stereo. */ +static GLfloat eyesep = 5.0; /* Eye separation. */ +static GLfloat fix_point = 40.0; /* Fixation point distance. */ +static GLfloat left, right, asp; /* Stereo frustum params. */ + + XVisualInfo *visinfo; + + +/* + * + * Draw a gear wheel. You'll probably want to call this function when + * building a display list since we do a lot of trig here. + * + * Input: inner_radius - radius of hole at center + * outer_radius - radius at center of teeth + * width - width of gear + * teeth - number of teeth + * tooth_depth - depth of tooth + */ +static void +gear(GLfloat inner_radius, GLfloat outer_radius, GLfloat width, + GLint teeth, GLfloat tooth_depth) +{ + GLint i; + GLfloat r0, r1, r2; + GLfloat angle, da; + GLfloat u, v, len; + + r0 = inner_radius; + r1 = outer_radius - tooth_depth / 2.0; + r2 = outer_radius + tooth_depth / 2.0; + + da = 2.0 * M_PI / teeth / 4.0; + + glShadeModel(GL_FLAT); + + glNormal3f(0.0, 0.0, 1.0); + + /* draw front face */ + glBegin(GL_QUAD_STRIP); + for (i = 0; i <= teeth; i++) { + angle = i * 2.0 * M_PI / teeth; + glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5); + glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5); + if (i < teeth) { + glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5); + glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), + width * 0.5); + } + } + glEnd(); + + /* draw front sides of teeth */ + glBegin(GL_QUADS); + da = 2.0 * M_PI / teeth / 4.0; + for (i = 0; i < teeth; i++) { + angle = i * 2.0 * M_PI / teeth; + + glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5); + glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), width * 0.5); + glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), + width * 0.5); + glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), + width * 0.5); + } + glEnd(); + + glNormal3f(0.0, 0.0, -1.0); + + /* draw back face */ + glBegin(GL_QUAD_STRIP); + for (i = 0; i <= teeth; i++) { + angle = i * 2.0 * M_PI / teeth; + glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5); + glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5); + if (i < teeth) { + glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), + -width * 0.5); + glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5); + } + } + glEnd(); + + /* draw back sides of teeth */ + glBegin(GL_QUADS); + da = 2.0 * M_PI / teeth / 4.0; + for (i = 0; i < teeth; i++) { + angle = i * 2.0 * M_PI / teeth; + + glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), + -width * 0.5); + glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), + -width * 0.5); + glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), -width * 0.5); + glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5); + } + glEnd(); + + /* draw outward faces of teeth */ + glBegin(GL_QUAD_STRIP); + for (i = 0; i < teeth; i++) { + angle = i * 2.0 * M_PI / teeth; + + glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5); + glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5); + u = r2 * cos(angle + da) - r1 * cos(angle); + v = r2 * sin(angle + da) - r1 * sin(angle); + len = sqrt(u * u + v * v); + u /= len; + v /= len; + glNormal3f(v, -u, 0.0); + glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), width * 0.5); + glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), -width * 0.5); + glNormal3f(cos(angle), sin(angle), 0.0); + glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), + width * 0.5); + glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), + -width * 0.5); + u = r1 * cos(angle + 3 * da) - r2 * cos(angle + 2 * da); + v = r1 * sin(angle + 3 * da) - r2 * sin(angle + 2 * da); + glNormal3f(v, -u, 0.0); + glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), + width * 0.5); + glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), + -width * 0.5); + glNormal3f(cos(angle), sin(angle), 0.0); + } + + glVertex3f(r1 * cos(0), r1 * sin(0), width * 0.5); + glVertex3f(r1 * cos(0), r1 * sin(0), -width * 0.5); + + glEnd(); + + glShadeModel(GL_SMOOTH); + + /* draw inside radius cylinder */ + glBegin(GL_QUAD_STRIP); + for (i = 0; i <= teeth; i++) { + angle = i * 2.0 * M_PI / teeth; + glNormal3f(-cos(angle), -sin(angle), 0.0); + glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5); + glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5); + } + glEnd(); +} + + +static void +do_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); + + 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, 4.2, 0.0); + glRotatef(-2.0 * angle - 25.0, 0.0, 0.0, 1.0); + glCallList(gear3); + glPopMatrix(); + + glPopMatrix(); +} + + + +/* new window size or exposure */ +static void +reshape(int width, int height) +{ + glViewport(0, 0, (GLint) width, (GLint) height); + + if (stereo) { + GLfloat w; + + asp = (GLfloat) height / (GLfloat) width; + w = fix_point * (1.0 / 5.0); + + left = -5.0 * ((w - 0.5 * eyesep) / fix_point); + right = 5.0 * ((w + 0.5 * eyesep) / fix_point); + } else { + GLfloat h = (GLfloat) height / (GLfloat) width; + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glFrustum(-1.0, 1.0, -h, h, 5.0, 60.0); + } + + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTranslatef(0.0, 0.0, -40.0); +} + + + +static void +init(void) +{ + 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); + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + glEnable(GL_DEPTH_TEST); + + /* make the gears */ + gear1 = glGenLists(1); + glNewList(gear1, GL_COMPILE); + glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, red); + gear(1.0, 4.0, 1.0, 20, 0.7); + glEndList(); + + gear2 = glGenLists(1); + glNewList(gear2, GL_COMPILE); + glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, green); + gear(0.5, 2.0, 2.0, 10, 0.7); + glEndList(); + + gear3 = glGenLists(1); + glNewList(gear3, GL_COMPILE); + glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, blue); + gear(1.3, 2.0, 0.5, 10, 0.7); + glEndList(); + + glEnable(GL_NORMALIZE); +} + + +static void +draw( Display *dpy, Window win ) +{ + GLXContext ctx; + + ctx = glXCreateContext( dpy, visinfo, NULL, True ); + if (!ctx) { + printf("Error: glXCreateContext failed\n"); + exit(1); + } + + glXMakeCurrent(dpy, win, ctx); + + init(); + + if (stereo) { + /* First left eye. */ + glDrawBuffer(GL_BACK_LEFT); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glFrustum(left, right, -asp, asp, 5.0, 60.0); + + glMatrixMode(GL_MODELVIEW); + + glPushMatrix(); + glTranslated(+0.5 * eyesep, 0.0, 0.0); + do_draw(); + glPopMatrix(); + + /* Then right eye. */ + glDrawBuffer(GL_BACK_RIGHT); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glFrustum(-right, -left, -asp, asp, 5.0, 60.0); + + glMatrixMode(GL_MODELVIEW); + + glPushMatrix(); + glTranslated(-0.5 * eyesep, 0.0, 0.0); + do_draw(); + glPopMatrix(); + } else + do_draw(); + + glXSwapBuffers(dpy, win); + glXDestroyContext(dpy, ctx); +} + + +/* + * Create an RGB, double-buffered window. + * Return the window and context handles. + */ +static void +make_window( Display *dpy, const char *name, + int x, int y, int width, int height, + Window *winRet) +{ + int attribs[] = { GLX_RGBA, + GLX_RED_SIZE, 1, + GLX_GREEN_SIZE, 1, + GLX_BLUE_SIZE, 1, + GLX_DOUBLEBUFFER, + GLX_DEPTH_SIZE, 1, + None }; + int stereoAttribs[] = { GLX_RGBA, + GLX_RED_SIZE, 1, + GLX_GREEN_SIZE, 1, + GLX_BLUE_SIZE, 1, + GLX_DOUBLEBUFFER, + GLX_DEPTH_SIZE, 1, + GLX_STEREO, + None }; + int scrnum; + XSetWindowAttributes attr; + unsigned long mask; + Window root; + Window win; + + scrnum = DefaultScreen( dpy ); + root = RootWindow( dpy, scrnum ); + + if (fullscreen) { + x = 0; y = 0; + width = DisplayWidth( dpy, scrnum ); + height = DisplayHeight( dpy, scrnum ); + } + + if (stereo) + visinfo = glXChooseVisual( dpy, scrnum, stereoAttribs ); + else + visinfo = glXChooseVisual( dpy, scrnum, attribs ); + if (!visinfo) { + if (stereo) { + printf("Error: couldn't get an RGB, " + "Double-buffered, Stereo visual\n"); + } else + printf("Error: couldn't get an RGB, Double-buffered visual\n"); + exit(1); + } + + /* window attributes */ + attr.background_pixel = 0; + attr.border_pixel = 0; + attr.colormap = XCreateColormap( dpy, root, visinfo->visual, AllocNone); + attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask; + attr.override_redirect = fullscreen; + mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask | CWOverrideRedirect; + + win = XCreateWindow( dpy, root, x, y, width, height, + 0, visinfo->depth, InputOutput, + visinfo->visual, mask, &attr ); + + /* set hints and properties */ + { + XSizeHints sizehints; + sizehints.x = x; + sizehints.y = y; + sizehints.width = width; + sizehints.height = height; + sizehints.flags = USSize | USPosition; + XSetNormalHints(dpy, win, &sizehints); + XSetStandardProperties(dpy, win, name, name, + None, (char **)NULL, 0, &sizehints); + } + + *winRet = win; +} + + +static void +event_loop(Display *dpy) +{ + Window win; + make_window(dpy, "glxgears", 0, 0, 300, 300, &win); + XMapWindow(dpy, win); + + + while (1) { + while (XPending(dpy) > 0) { + XEvent event; + XNextEvent(dpy, &event); + switch (event.type) { + case Expose: + /* we'll redraw below */ + break; + case ConfigureNotify: + reshape(event.xconfigure.width, event.xconfigure.height); + break; + case KeyPress: + { + char buffer[10]; + int r, code; + code = XLookupKeysym(&event.xkey, 0); + if (code == XK_Left) { + view_roty += 5.0; + } + else if (code == XK_Right) { + view_roty -= 5.0; + } + else if (code == XK_Up) { + view_rotx += 5.0; + } + else if (code == XK_Down) { + view_rotx -= 5.0; + } + else { + r = XLookupString(&event.xkey, buffer, sizeof(buffer), + NULL, NULL); + if (buffer[0] == 27) { + /* escape */ + return; + } + } + } + } + } + + { + static int frames = 0; + static double tRot0 = -1.0, tRate0 = -1.0; + double dt, t = current_time(); + if (tRot0 < 0.0) + tRot0 = t; + dt = t - tRot0; + tRot0 = t; + + /* advance rotation for next frame */ + angle += 70.0 * dt; /* 70 degrees per second */ + if (angle > 3600.0) + angle -= 3600.0; + + draw( dpy, win ); + + frames++; + + if (tRate0 < 0.0) + tRate0 = t; + + if (t - tRate0 >= 1.0) { + GLfloat seconds = t - tRate0; + GLfloat fps = frames / seconds; + printf("%d frames in %3.1f seconds = %6.3f FPS\n", frames, seconds, + fps); + tRate0 = t; + + XDestroyWindow(dpy, win); + make_window(dpy, "glxgears", (int)(fps * 100) % 100, (int)(fps * 100) % 100, 300, 300, &win); + XMapWindow(dpy, win); + + frames = 0; + } + } + } +} + + + +int +main(int argc, char *argv[]) +{ + Display *dpy; + char *dpyName = NULL; + GLboolean printInfo = GL_FALSE; + int i; + + for (i = 1; i < argc; i++) { + if (strcmp(argv[i], "-display") == 0) { + dpyName = argv[i+1]; + i++; + } + else if (strcmp(argv[i], "-info") == 0) { + printInfo = GL_TRUE; + } + else if (strcmp(argv[i], "-stereo") == 0) { + stereo = GL_TRUE; + } + else if (strcmp(argv[i], "-fullscreen") == 0) { + fullscreen = GL_TRUE; + } + else + printf("Warrning: unknown parameter: %s\n", argv[i]); + } + + dpy = XOpenDisplay(dpyName); + if (!dpy) { + printf("Error: couldn't open display %s\n", + dpyName ? dpyName : getenv("DISPLAY")); + return -1; + } + + + if (printInfo) { + 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)); + } + + + event_loop(dpy); + + XCloseDisplay(dpy); + + return 0; +} diff --git a/progs/xdemos/glxdemo.c b/progs/xdemos/glxdemo.c new file mode 100644 index 00000000000..37df64ebee8 --- /dev/null +++ b/progs/xdemos/glxdemo.c @@ -0,0 +1,127 @@ + + +/* + * A demonstration of using the GLX functions. This program is in the + * public domain. + * + * Brian Paul + */ + +#include +#include +#include +#include + + + +static void redraw( Display *dpy, Window w ) +{ + printf("Redraw event\n"); + + glClear( GL_COLOR_BUFFER_BIT ); + + glColor3f( 1.0, 1.0, 0.0 ); + glRectf( -0.8, -0.8, 0.8, 0.8 ); + + glXSwapBuffers( dpy, w ); +} + + + +static void resize( unsigned int width, unsigned int height ) +{ + printf("Resize event\n"); + glViewport( 0, 0, width, height ); + glMatrixMode( GL_PROJECTION ); + glLoadIdentity(); + glOrtho( -1.0, 1.0, -1.0, 1.0, -1.0, 1.0 ); +} + + + +static Window make_rgb_db_window( Display *dpy, + unsigned int width, unsigned int height ) +{ + 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; + Window win; + GLXContext ctx; + XVisualInfo *visinfo; + + scrnum = DefaultScreen( dpy ); + root = RootWindow( dpy, scrnum ); + + visinfo = glXChooseVisual( dpy, scrnum, attrib ); + if (!visinfo) { + printf("Error: couldn't get an RGB, Double-buffered visual\n"); + exit(1); + } + + /* window attributes */ + attr.background_pixel = 0; + attr.border_pixel = 0; + 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 ); + + ctx = glXCreateContext( dpy, visinfo, NULL, True ); + if (!ctx) { + printf("Error: glXCreateContext failed\n"); + exit(1); + } + + glXMakeCurrent( dpy, win, ctx ); + + return win; +} + + +static void event_loop( Display *dpy ) +{ + XEvent event; + + while (1) { + XNextEvent( dpy, &event ); + + switch (event.type) { + case Expose: + redraw( dpy, event.xany.window ); + break; + case ConfigureNotify: + resize( event.xconfigure.width, event.xconfigure.height ); + break; + } + } +} + + + +int main( int argc, char *argv[] ) +{ + Display *dpy; + Window win; + + dpy = XOpenDisplay(NULL); + + win = make_rgb_db_window( dpy, 300, 300 ); + + glShadeModel( GL_FLAT ); + glClearColor( 0.5, 0.5, 0.5, 1.0 ); + + XMapWindow( dpy, win ); + + event_loop( dpy ); + return 0; +} diff --git a/progs/xdemos/glxgears.c b/progs/xdemos/glxgears.c new file mode 100644 index 00000000000..75d63e51a2e --- /dev/null +++ b/progs/xdemos/glxgears.c @@ -0,0 +1,621 @@ +/* + * Copyright (C) 1999-2001 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 port of the infamous "gears" demo to straight GLX (i.e. no GLUT) + * Port by Brian Paul 23 March 2001 + * + * Command line options: + * -info print GL implementation information + * -stereo use stereo enabled GLX visual + * + */ + + +#include +#include +#include +#include +#include +#include +#include +#include + + +#define BENCHMARK + +#ifdef BENCHMARK + +/* XXX this probably isn't very portable */ + +#include +#include + +/* return current time (in seconds) */ +static double +current_time(void) +{ + struct timeval tv; +#ifdef __VMS + (void) gettimeofday(&tv, NULL ); +#else + struct timezone tz; + (void) gettimeofday(&tv, &tz); +#endif + return (double) tv.tv_sec + tv.tv_usec / 1000000.0; +} + +#else /*BENCHMARK*/ + +/* dummy */ +static double +current_time(void) +{ + /* update this function for other platforms! */ + static double t = 0.0; + static int warn = 1; + if (warn) { + fprintf(stderr, "Warning: current_time() not implemented!!\n"); + warn = 0; + } + return t += 1.0; +} + +#endif /*BENCHMARK*/ + + + +#ifndef M_PI +#define M_PI 3.14159265 +#endif + + +static GLfloat view_rotx = 20.0, view_roty = 30.0, view_rotz = 0.0; +static GLint gear1, gear2, gear3; +static GLfloat angle = 0.0; + +static GLboolean fullscreen = GL_FALSE; /* Create a single fullscreen window */ +static GLboolean stereo = GL_FALSE; /* Enable stereo. */ +static GLfloat eyesep = 5.0; /* Eye separation. */ +static GLfloat fix_point = 40.0; /* Fixation point distance. */ +static GLfloat left, right, asp; /* Stereo frustum params. */ + + +/* + * + * Draw a gear wheel. You'll probably want to call this function when + * building a display list since we do a lot of trig here. + * + * Input: inner_radius - radius of hole at center + * outer_radius - radius at center of teeth + * width - width of gear + * teeth - number of teeth + * tooth_depth - depth of tooth + */ +static void +gear(GLfloat inner_radius, GLfloat outer_radius, GLfloat width, + GLint teeth, GLfloat tooth_depth) +{ + GLint i; + GLfloat r0, r1, r2; + GLfloat angle, da; + GLfloat u, v, len; + + r0 = inner_radius; + r1 = outer_radius - tooth_depth / 2.0; + r2 = outer_radius + tooth_depth / 2.0; + + da = 2.0 * M_PI / teeth / 4.0; + + glShadeModel(GL_FLAT); + + glNormal3f(0.0, 0.0, 1.0); + + /* draw front face */ + glBegin(GL_QUAD_STRIP); + for (i = 0; i <= teeth; i++) { + angle = i * 2.0 * M_PI / teeth; + glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5); + glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5); + if (i < teeth) { + glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5); + glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), + width * 0.5); + } + } + glEnd(); + + /* draw front sides of teeth */ + glBegin(GL_QUADS); + da = 2.0 * M_PI / teeth / 4.0; + for (i = 0; i < teeth; i++) { + angle = i * 2.0 * M_PI / teeth; + + glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5); + glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), width * 0.5); + glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), + width * 0.5); + glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), + width * 0.5); + } + glEnd(); + + glNormal3f(0.0, 0.0, -1.0); + + /* draw back face */ + glBegin(GL_QUAD_STRIP); + for (i = 0; i <= teeth; i++) { + angle = i * 2.0 * M_PI / teeth; + glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5); + glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5); + if (i < teeth) { + glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), + -width * 0.5); + glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5); + } + } + glEnd(); + + /* draw back sides of teeth */ + glBegin(GL_QUADS); + da = 2.0 * M_PI / teeth / 4.0; + for (i = 0; i < teeth; i++) { + angle = i * 2.0 * M_PI / teeth; + + glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), + -width * 0.5); + glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), + -width * 0.5); + glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), -width * 0.5); + glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5); + } + glEnd(); + + /* draw outward faces of teeth */ + glBegin(GL_QUAD_STRIP); + for (i = 0; i < teeth; i++) { + angle = i * 2.0 * M_PI / teeth; + + glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5); + glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5); + u = r2 * cos(angle + da) - r1 * cos(angle); + v = r2 * sin(angle + da) - r1 * sin(angle); + len = sqrt(u * u + v * v); + u /= len; + v /= len; + glNormal3f(v, -u, 0.0); + glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), width * 0.5); + glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), -width * 0.5); + glNormal3f(cos(angle), sin(angle), 0.0); + glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), + width * 0.5); + glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), + -width * 0.5); + u = r1 * cos(angle + 3 * da) - r2 * cos(angle + 2 * da); + v = r1 * sin(angle + 3 * da) - r2 * sin(angle + 2 * da); + glNormal3f(v, -u, 0.0); + glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), + width * 0.5); + glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), + -width * 0.5); + glNormal3f(cos(angle), sin(angle), 0.0); + } + + glVertex3f(r1 * cos(0), r1 * sin(0), width * 0.5); + glVertex3f(r1 * cos(0), r1 * sin(0), -width * 0.5); + + glEnd(); + + glShadeModel(GL_SMOOTH); + + /* draw inside radius cylinder */ + glBegin(GL_QUAD_STRIP); + for (i = 0; i <= teeth; i++) { + angle = i * 2.0 * M_PI / teeth; + glNormal3f(-cos(angle), -sin(angle), 0.0); + glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5); + glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5); + } + glEnd(); +} + + +static void +do_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); + + 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, 4.2, 0.0); + glRotatef(-2.0 * angle - 25.0, 0.0, 0.0, 1.0); + glCallList(gear3); + glPopMatrix(); + + glPopMatrix(); +} + +static void +draw(void) +{ + if (stereo) { + /* First left eye. */ + glDrawBuffer(GL_BACK_LEFT); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glFrustum(left, right, -asp, asp, 5.0, 60.0); + + glMatrixMode(GL_MODELVIEW); + + glPushMatrix(); + glTranslated(+0.5 * eyesep, 0.0, 0.0); + do_draw(); + glPopMatrix(); + + /* Then right eye. */ + glDrawBuffer(GL_BACK_RIGHT); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glFrustum(-right, -left, -asp, asp, 5.0, 60.0); + + glMatrixMode(GL_MODELVIEW); + + glPushMatrix(); + glTranslated(-0.5 * eyesep, 0.0, 0.0); + do_draw(); + glPopMatrix(); + } else + do_draw(); +} + + +/* new window size or exposure */ +static void +reshape(int width, int height) +{ + glViewport(0, 0, (GLint) width, (GLint) height); + + if (stereo) { + GLfloat w; + + asp = (GLfloat) height / (GLfloat) width; + w = fix_point * (1.0 / 5.0); + + left = -5.0 * ((w - 0.5 * eyesep) / fix_point); + right = 5.0 * ((w + 0.5 * eyesep) / fix_point); + } else { + GLfloat h = (GLfloat) height / (GLfloat) width; + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glFrustum(-1.0, 1.0, -h, h, 5.0, 60.0); + } + + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTranslatef(0.0, 0.0, -40.0); +} + + + +static void +init(void) +{ + 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); + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + glEnable(GL_DEPTH_TEST); + + /* make the gears */ + gear1 = glGenLists(1); + glNewList(gear1, GL_COMPILE); + glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, red); + gear(1.0, 4.0, 1.0, 20, 0.7); + glEndList(); + + gear2 = glGenLists(1); + glNewList(gear2, GL_COMPILE); + glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, green); + gear(0.5, 2.0, 2.0, 10, 0.7); + glEndList(); + + gear3 = glGenLists(1); + glNewList(gear3, GL_COMPILE); + glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, blue); + gear(1.3, 2.0, 0.5, 10, 0.7); + glEndList(); + + glEnable(GL_NORMALIZE); +} + + +/* + * Create an RGB, double-buffered window. + * Return the window and context handles. + */ +static void +make_window( Display *dpy, const char *name, + int x, int y, int width, int height, + Window *winRet, GLXContext *ctxRet) +{ + int attribs[] = { GLX_RGBA, + GLX_RED_SIZE, 1, + GLX_GREEN_SIZE, 1, + GLX_BLUE_SIZE, 1, + GLX_DOUBLEBUFFER, + GLX_DEPTH_SIZE, 1, + None }; + int stereoAttribs[] = { GLX_RGBA, + GLX_RED_SIZE, 1, + GLX_GREEN_SIZE, 1, + GLX_BLUE_SIZE, 1, + GLX_DOUBLEBUFFER, + GLX_DEPTH_SIZE, 1, + GLX_STEREO, + None }; + int scrnum; + XSetWindowAttributes attr; + unsigned long mask; + Window root; + Window win; + GLXContext ctx; + XVisualInfo *visinfo; + + scrnum = DefaultScreen( dpy ); + root = RootWindow( dpy, scrnum ); + + if (fullscreen) { + x = 0; y = 0; + width = DisplayWidth( dpy, scrnum ); + height = DisplayHeight( dpy, scrnum ); + } + + if (stereo) + visinfo = glXChooseVisual( dpy, scrnum, stereoAttribs ); + else + visinfo = glXChooseVisual( dpy, scrnum, attribs ); + if (!visinfo) { + if (stereo) { + printf("Error: couldn't get an RGB, " + "Double-buffered, Stereo visual\n"); + } else + printf("Error: couldn't get an RGB, Double-buffered visual\n"); + exit(1); + } + + /* window attributes */ + attr.background_pixel = 0; + attr.border_pixel = 0; + attr.colormap = XCreateColormap( dpy, root, visinfo->visual, AllocNone); + attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask; + attr.override_redirect = fullscreen; + mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask | CWOverrideRedirect; + + win = XCreateWindow( dpy, root, 0, 0, width, height, + 0, visinfo->depth, InputOutput, + visinfo->visual, mask, &attr ); + + /* set hints and properties */ + { + XSizeHints sizehints; + sizehints.x = x; + sizehints.y = y; + 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) { + printf("Error: glXCreateContext failed\n"); + exit(1); + } + + XFree(visinfo); + + *winRet = win; + *ctxRet = ctx; +} + + +static void +event_loop(Display *dpy, Window win) +{ + while (1) { + while (XPending(dpy) > 0) { + XEvent event; + XNextEvent(dpy, &event); + switch (event.type) { + case Expose: + /* we'll redraw below */ + break; + case ConfigureNotify: + reshape(event.xconfigure.width, event.xconfigure.height); + break; + case KeyPress: + { + char buffer[10]; + int r, code; + code = XLookupKeysym(&event.xkey, 0); + if (code == XK_Left) { + view_roty += 5.0; + } + else if (code == XK_Right) { + view_roty -= 5.0; + } + else if (code == XK_Up) { + view_rotx += 5.0; + } + else if (code == XK_Down) { + view_rotx -= 5.0; + } + else { + r = XLookupString(&event.xkey, buffer, sizeof(buffer), + NULL, NULL); + if (buffer[0] == 27) { + /* escape */ + return; + } + } + } + } + } + + { + static int frames = 0; + static double tRot0 = -1.0, tRate0 = -1.0; + double dt, t = current_time(); + if (tRot0 < 0.0) + tRot0 = t; + dt = t - tRot0; + tRot0 = t; + + /* advance rotation for next frame */ + angle += 70.0 * dt; /* 70 degrees per second */ + if (angle > 3600.0) + angle -= 3600.0; + + draw(); + glXSwapBuffers(dpy, win); + + frames++; + + if (tRate0 < 0.0) + tRate0 = t; + if (t - tRate0 >= 5.0) { + GLfloat seconds = t - tRate0; + GLfloat fps = frames / seconds; + printf("%d frames in %3.1f seconds = %6.3f FPS\n", frames, seconds, + fps); + tRate0 = t; + frames = 0; + } + } + } +} + + +static void +usage(void) +{ + printf("Usage:\n"); + printf(" -display set the display to run on\n"); + printf(" -stereo run in stereo mode\n"); + printf(" -fullscreen run in fullscreen mode\n"); + printf(" -info display OpenGL renderer info\n"); +} + + +int +main(int argc, char *argv[]) +{ + const int winWidth = 300, winHeight = 300; + Display *dpy; + Window win; + GLXContext ctx; + char *dpyName = NULL; + GLboolean printInfo = GL_FALSE; + int i; + + for (i = 1; i < argc; i++) { + if (strcmp(argv[i], "-display") == 0) { + dpyName = argv[i+1]; + i++; + } + else if (strcmp(argv[i], "-info") == 0) { + printInfo = GL_TRUE; + } + else if (strcmp(argv[i], "-stereo") == 0) { + stereo = GL_TRUE; + } + else if (strcmp(argv[i], "-fullscreen") == 0) { + fullscreen = GL_TRUE; + } + else { + usage(); + return -1; + } + } + + dpy = XOpenDisplay(dpyName); + if (!dpy) { + printf("Error: couldn't open display %s\n", + dpyName ? dpyName : getenv("DISPLAY")); + return -1; + } + + make_window(dpy, "glxgears", 0, 0, winWidth, winHeight, &win, &ctx); + XMapWindow(dpy, win); + glXMakeCurrent(dpy, win, ctx); + + if (printInfo) { + 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)); + } + + init(); + + /* Set initial projection/viewing transformation. + * We can't be sure we'll get a ConfigureNotify event when the window + * first appears. + */ + reshape(winWidth, winHeight); + + event_loop(dpy, win); + + glDeleteLists(gear1, 1); + glDeleteLists(gear2, 1); + glDeleteLists(gear3, 1); + glXDestroyContext(dpy, ctx); + XDestroyWindow(dpy, win); + XCloseDisplay(dpy); + + return 0; +} diff --git a/progs/xdemos/glxgears_fbconfig.c b/progs/xdemos/glxgears_fbconfig.c new file mode 100644 index 00000000000..acbadd21ac5 --- /dev/null +++ b/progs/xdemos/glxgears_fbconfig.c @@ -0,0 +1,602 @@ +/* + * Copyright (C) 1999-2001 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. + */ + +/** + * \file glxgears_fbconfig.c + * Yet-another-version of gears. Originally ported to GLX by Brian Paul on + * 23 March 2001. Modified to use fbconfigs by Ian Romanick on 10 Feb 2004. + * + * Command line options: + * -info print GL implementation information + * + * \author Brian Paul + * \author Ian Romanick + */ + + +#define GLX_GLXEXT_PROTOTYPES + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "pbutil.h" + +/* I had to use the SGIX versions of these because for some reason glxext.h + * doesn't define the core versions if GLX_VERSION_1_3 is defined, and glx.h + * doesn't define them at all. One or both header files is clearly broken. + */ +static PFNGLXCHOOSEFBCONFIGSGIXPROC choose_fbconfig = NULL; +static PFNGLXGETVISUALFROMFBCONFIGSGIXPROC get_visual_from_fbconfig = NULL; +static PFNGLXCREATECONTEXTWITHCONFIGSGIXPROC create_new_context = NULL; + +#define BENCHMARK + +#ifdef BENCHMARK + +/* XXX this probably isn't very portable */ + +#include +#include + +/* return current time (in seconds) */ +static int +current_time(void) +{ + struct timeval tv; +#ifdef __VMS + (void) gettimeofday(&tv, NULL ); +#else + struct timezone tz; + (void) gettimeofday(&tv, &tz); +#endif + return (int) tv.tv_sec; +} + +#else /*BENCHMARK*/ + +/* dummy */ +static int +current_time(void) +{ + return 0; +} + +#endif /*BENCHMARK*/ + + + +#ifndef M_PI +#define M_PI 3.14159265 +#endif + + +static GLfloat view_rotx = 20.0, view_roty = 30.0, view_rotz = 0.0; +static GLint gear1, gear2, gear3; +static GLfloat angle = 0.0; + + +/* + * + * Draw a gear wheel. You'll probably want to call this function when + * building a display list since we do a lot of trig here. + * + * Input: inner_radius - radius of hole at center + * outer_radius - radius at center of teeth + * width - width of gear + * teeth - number of teeth + * tooth_depth - depth of tooth + */ +static void +gear(GLfloat inner_radius, GLfloat outer_radius, GLfloat width, + GLint teeth, GLfloat tooth_depth) +{ + GLint i; + GLfloat r0, r1, r2; + GLfloat angle, da; + GLfloat u, v, len; + + r0 = inner_radius; + r1 = outer_radius - tooth_depth / 2.0; + r2 = outer_radius + tooth_depth / 2.0; + + da = 2.0 * M_PI / teeth / 4.0; + + glShadeModel(GL_FLAT); + + glNormal3f(0.0, 0.0, 1.0); + + /* draw front face */ + glBegin(GL_QUAD_STRIP); + for (i = 0; i <= teeth; i++) { + angle = i * 2.0 * M_PI / teeth; + glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5); + glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5); + if (i < teeth) { + glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5); + glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), + width * 0.5); + } + } + glEnd(); + + /* draw front sides of teeth */ + glBegin(GL_QUADS); + da = 2.0 * M_PI / teeth / 4.0; + for (i = 0; i < teeth; i++) { + angle = i * 2.0 * M_PI / teeth; + + glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5); + glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), width * 0.5); + glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), + width * 0.5); + glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), + width * 0.5); + } + glEnd(); + + glNormal3f(0.0, 0.0, -1.0); + + /* draw back face */ + glBegin(GL_QUAD_STRIP); + for (i = 0; i <= teeth; i++) { + angle = i * 2.0 * M_PI / teeth; + glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5); + glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5); + if (i < teeth) { + glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), + -width * 0.5); + glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5); + } + } + glEnd(); + + /* draw back sides of teeth */ + glBegin(GL_QUADS); + da = 2.0 * M_PI / teeth / 4.0; + for (i = 0; i < teeth; i++) { + angle = i * 2.0 * M_PI / teeth; + + glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), + -width * 0.5); + glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), + -width * 0.5); + glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), -width * 0.5); + glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5); + } + glEnd(); + + /* draw outward faces of teeth */ + glBegin(GL_QUAD_STRIP); + for (i = 0; i < teeth; i++) { + angle = i * 2.0 * M_PI / teeth; + + glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5); + glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5); + u = r2 * cos(angle + da) - r1 * cos(angle); + v = r2 * sin(angle + da) - r1 * sin(angle); + len = sqrt(u * u + v * v); + u /= len; + v /= len; + glNormal3f(v, -u, 0.0); + glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), width * 0.5); + glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), -width * 0.5); + glNormal3f(cos(angle), sin(angle), 0.0); + glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), + width * 0.5); + glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), + -width * 0.5); + u = r1 * cos(angle + 3 * da) - r2 * cos(angle + 2 * da); + v = r1 * sin(angle + 3 * da) - r2 * sin(angle + 2 * da); + glNormal3f(v, -u, 0.0); + glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), + width * 0.5); + glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), + -width * 0.5); + glNormal3f(cos(angle), sin(angle), 0.0); + } + + glVertex3f(r1 * cos(0), r1 * sin(0), width * 0.5); + glVertex3f(r1 * cos(0), r1 * sin(0), -width * 0.5); + + glEnd(); + + glShadeModel(GL_SMOOTH); + + /* draw inside radius cylinder */ + glBegin(GL_QUAD_STRIP); + for (i = 0; i <= teeth; i++) { + angle = i * 2.0 * M_PI / teeth; + glNormal3f(-cos(angle), -sin(angle), 0.0); + glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5); + glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5); + } + glEnd(); +} + + +static void +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); + + 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, 4.2, 0.0); + glRotatef(-2.0 * angle - 25.0, 0.0, 0.0, 1.0); + glCallList(gear3); + glPopMatrix(); + + glPopMatrix(); +} + + +/* new window size or exposure */ +static void +reshape(int width, int height) +{ + GLfloat h = (GLfloat) height / (GLfloat) width; + + glViewport(0, 0, (GLint) width, (GLint) height); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glFrustum(-1.0, 1.0, -h, h, 5.0, 60.0); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTranslatef(0.0, 0.0, -40.0); +} + + +static void +init(void) +{ + 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); + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + glEnable(GL_DEPTH_TEST); + + /* make the gears */ + gear1 = glGenLists(1); + glNewList(gear1, GL_COMPILE); + glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, red); + gear(1.0, 4.0, 1.0, 20, 0.7); + glEndList(); + + gear2 = glGenLists(1); + glNewList(gear2, GL_COMPILE); + glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, green); + gear(0.5, 2.0, 2.0, 10, 0.7); + glEndList(); + + gear3 = glGenLists(1); + glNewList(gear3, GL_COMPILE); + glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, blue); + gear(1.3, 2.0, 0.5, 10, 0.7); + glEndList(); + + glEnable(GL_NORMALIZE); +} + + +/** + * Initialize fbconfig related function pointers. + */ +static void +init_fbconfig_functions(Display *dpy, int scrnum) +{ + const char * glx_extensions; + const char * match; + static const char ext_name[] = "GLX_SGIX_fbconfig"; + const size_t len = strlen( ext_name ); + int major; + int minor; + GLboolean ext_version_supported; + GLboolean glx_1_3_supported; + + + /* Determine if GLX 1.3 or greater is supported. + */ + glXQueryVersion(dpy, & major, & minor); + glx_1_3_supported = (major == 1) && (minor >= 3); + + /* Determine if GLX_SGIX_fbconfig is supported. + */ + glx_extensions = glXQueryExtensionsString(dpy, scrnum); + match = strstr( glx_extensions, ext_name ); + + ext_version_supported = (match != NULL) + && ((match[len] == '\0') || (match[len] == ' ')); + + printf( "GLX 1.3 is %ssupported.\n", + (glx_1_3_supported) ? "" : "not " ); + printf( "%s is %ssupported.\n", + ext_name, (ext_version_supported) ? "" : "not " ); + + if ( glx_1_3_supported ) { + choose_fbconfig = (PFNGLXCHOOSEFBCONFIGSGIXPROC) glXGetProcAddressARB( + (GLubyte *) "glXChooseFBConfig"); + get_visual_from_fbconfig = (PFNGLXGETVISUALFROMFBCONFIGSGIXPROC) glXGetProcAddressARB( + (GLubyte *) "glXGetVisualFromFBConfig"); + create_new_context = (PFNGLXCREATECONTEXTWITHCONFIGSGIXPROC) glXGetProcAddressARB( + (GLubyte *) "glXCreateNewContext"); + } + else if ( ext_version_supported ) { + choose_fbconfig = (PFNGLXCHOOSEFBCONFIGSGIXPROC) glXGetProcAddressARB( + (GLubyte *) "glXChooseFBConfigSGIX"); + get_visual_from_fbconfig = (PFNGLXGETVISUALFROMFBCONFIGSGIXPROC) glXGetProcAddressARB( + (GLubyte *) "glXGetVisualFromFBConfigSGIX"); + create_new_context = (PFNGLXCREATECONTEXTWITHCONFIGSGIXPROC) glXGetProcAddressARB( + (GLubyte *) "glXCreateContextWithConfigSGIX"); + } + else { + printf( "This demo requires either GLX 1.3 or %s be supported.\n", + ext_name ); + exit(1); + } + + if ( choose_fbconfig == NULL ) { + printf( "glXChooseFBConfig not found!\n" ); + exit(1); + } + + if ( get_visual_from_fbconfig == NULL ) { + printf( "glXGetVisualFromFBConfig not found!\n" ); + exit(1); + } + + if ( create_new_context == NULL ) { + printf( "glXCreateNewContext not found!\n" ); + exit(1); + } +} + + +/* + * Create an RGB, double-buffered window. + * Return the window and context handles. + */ +static void +make_window( Display *dpy, const char *name, + int x, int y, int width, int height, + Window *winRet, GLXContext *ctxRet) +{ + int attrib[] = { GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT, + GLX_RENDER_TYPE, GLX_RGBA_BIT, + GLX_RED_SIZE, 1, + GLX_GREEN_SIZE, 1, + GLX_BLUE_SIZE, 1, + GLX_DOUBLEBUFFER, GL_TRUE, + GLX_DEPTH_SIZE, 1, + None }; + GLXFBConfig * fbconfig; + int num_configs; + int scrnum; + int i; + XSetWindowAttributes attr; + unsigned long mask; + Window root; + Window win; + GLXContext ctx; + XVisualInfo *visinfo; + + scrnum = DefaultScreen( dpy ); + root = RootWindow( dpy, scrnum ); + + init_fbconfig_functions(dpy, scrnum); + fbconfig = (*choose_fbconfig)(dpy, scrnum, attrib, & num_configs); + if (fbconfig == NULL) { + printf("Error: couldn't get an RGB, Double-buffered visual\n"); + exit(1); + } + + printf("\nThe following fbconfigs meet the requirements. The first one " + "will be used.\n\n"); + for ( i = 0 ; i < num_configs ; i++ ) { + PrintFBConfigInfo(dpy, scrnum, fbconfig[i], GL_TRUE); + } + + /* window attributes */ + visinfo = (*get_visual_from_fbconfig)(dpy, fbconfig[0]); + assert(visinfo != NULL); + 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 ); + + /* set hints and properties */ + { + XSizeHints sizehints; + sizehints.x = x; + sizehints.y = y; + 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 = (*create_new_context)(dpy, fbconfig[0], GLX_RGBA_TYPE, NULL, GL_TRUE); + if (!ctx) { + printf("Error: glXCreateNewContext failed\n"); + exit(1); + } + + XFree(fbconfig); + + *winRet = win; + *ctxRet = ctx; +} + + +static void +event_loop(Display *dpy, Window win) +{ + while (1) { + while (XPending(dpy) > 0) { + XEvent event; + XNextEvent(dpy, &event); + switch (event.type) { + case Expose: + /* we'll redraw below */ + break; + case ConfigureNotify: + reshape(event.xconfigure.width, event.xconfigure.height); + break; + case KeyPress: + { + char buffer[10]; + int r, code; + code = XLookupKeysym(&event.xkey, 0); + if (code == XK_Left) { + view_roty += 5.0; + } + else if (code == XK_Right) { + view_roty -= 5.0; + } + else if (code == XK_Up) { + view_rotx += 5.0; + } + else if (code == XK_Down) { + view_rotx -= 5.0; + } + else { + r = XLookupString(&event.xkey, buffer, sizeof(buffer), + NULL, NULL); + if (buffer[0] == 27) { + /* escape */ + return; + } + } + } + } + } + + /* next frame */ + angle += 2.0; + + draw(); + glXSwapBuffers(dpy, win); + + /* calc framerate */ + { + static int t0 = -1; + static int frames = 0; + int t = current_time(); + + if (t0 < 0) + t0 = t; + + frames++; + + if (t - t0 >= 5.0) { + GLfloat seconds = t - t0; + GLfloat fps = frames / seconds; + printf("%d frames in %3.1f seconds = %6.3f FPS\n", frames, seconds, + fps); + t0 = t; + frames = 0; + } + } + } +} + + +int +main(int argc, char *argv[]) +{ + Display *dpy; + Window win; + GLXContext ctx; + const char *dpyName = NULL; + GLboolean printInfo = GL_FALSE; + int i; + + for (i = 1; i < argc; i++) { + if (strcmp(argv[i], "-display") == 0) { + dpyName = argv[i+1]; + i++; + } + else if (strcmp(argv[i], "-info") == 0) { + printInfo = GL_TRUE; + } + } + + dpy = XOpenDisplay(dpyName); + if (!dpy) { + printf("Error: couldn't open display %s\n", dpyName); + return -1; + } + + make_window(dpy, "glxgears", 0, 0, 300, 300, &win, &ctx); + XMapWindow(dpy, win); + glXMakeCurrent(dpy, win, ctx); + + if (printInfo) { + 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)); + } + + init(); + + event_loop(dpy, win); + + glXDestroyContext(dpy, ctx); + XDestroyWindow(dpy, win); + XCloseDisplay(dpy); + + return 0; +} diff --git a/progs/xdemos/glxheads.c b/progs/xdemos/glxheads.c new file mode 100644 index 00000000000..0145a70e91c --- /dev/null +++ b/progs/xdemos/glxheads.c @@ -0,0 +1,286 @@ + +/* + * 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 +#include +#include +#include +#include +#include + + + +/* + * 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 NULL; + } + + /* 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: %p\n", (void *) h->Dpy); + printf(" Window: 0x%x\n", (int) h->Win); + printf(" Context: 0x%lx\n", (long) 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; +} diff --git a/progs/xdemos/glxinfo.c b/progs/xdemos/glxinfo.c new file mode 100644 index 00000000000..fdd1c0523f6 --- /dev/null +++ b/progs/xdemos/glxinfo.c @@ -0,0 +1,956 @@ +/* + * Copyright (C) 1999-2006 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 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 + * -b only print ID of "best" visual on screen 0 + * -i use indirect rendering connection only + * -l print interesting OpenGL limits (added 5 Sep 2002) + * + * Brian Paul 26 January 2000 + */ + +#define GLX_GLXEXT_PROTOTYPES + +#include +#include +#include +#include +#include +#include +#include + + +#ifndef GLX_NONE_EXT +#define GLX_NONE_EXT 0x8000 +#endif + +#ifndef GLX_TRANSPARENT_RGB +#define GLX_TRANSPARENT_RGB 0x8008 +#endif + + +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 transparentType; + int transparentRedValue; + int transparentGreenValue; + int transparentBlueValue; + int transparentAlphaValue; + int transparentIndexValue; + 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) +{ + const char *indentString = " "; + const int indent = 4; + const int max = 79; + int width, i, j; + + if (!ext || !ext[0]) + return; + + 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"); +} + + +static void +print_display_info(Display *dpy) +{ + printf("name of display: %s\n", DisplayString(dpy)); +} + + +/** + * Print interesting limits for vertex/fragment programs. + */ +static void +print_program_limits(GLenum target) +{ +#if defined(GL_ARB_vertex_program) || defined(GL_ARB_fragment_program) + struct token_name { + GLenum token; + const char *name; + }; + static const struct token_name limits[] = { + { GL_MAX_PROGRAM_INSTRUCTIONS_ARB, "GL_MAX_PROGRAM_INSTRUCTIONS_ARB" }, + { GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB, "GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB" }, + { GL_MAX_PROGRAM_TEMPORARIES_ARB, "GL_MAX_PROGRAM_TEMPORARIES_ARB" }, + { GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB, "GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB" }, + { GL_MAX_PROGRAM_PARAMETERS_ARB, "GL_MAX_PROGRAM_PARAMETERS_ARB" }, + { GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB, "GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB" }, + { GL_MAX_PROGRAM_ATTRIBS_ARB, "GL_MAX_PROGRAM_ATTRIBS_ARB" }, + { GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB, "GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB" }, + { GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB, "GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB" }, + { GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB, "GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB" }, + { GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB, "GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB" }, + { GL_MAX_PROGRAM_ENV_PARAMETERS_ARB, "GL_MAX_PROGRAM_ENV_PARAMETERS_ARB" }, + { GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB, "GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB" }, + { GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB, "GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB" }, + { GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB, "GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB" }, + { GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB, "GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB" }, + { GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB, "GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB" }, + { GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB, "GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB" }, + { (GLenum) 0, NULL } + }; + PFNGLGETPROGRAMIVARBPROC GetProgramivARB_func = (PFNGLGETPROGRAMIVARBPROC) + glXGetProcAddressARB((GLubyte *) "glGetProgramivARB"); + GLint max[1]; + int i; + + if (target == GL_VERTEX_PROGRAM_ARB) { + printf(" GL_VERTEX_PROGRAM_ARB:\n"); + } + else if (target == GL_FRAGMENT_PROGRAM_ARB) { + printf(" GL_FRAGMENT_PROGRAM_ARB:\n"); + } + else { + return; /* something's wrong */ + } + + for (i = 0; limits[i].token; i++) { + GetProgramivARB_func(target, limits[i].token, max); + if (glGetError() == GL_NO_ERROR) { + printf(" %s = %d\n", limits[i].name, max[0]); + } + } +#endif /* GL_ARB_vertex_program / GL_ARB_fragment_program */ +} + + +/** + * Print interesting limits for vertex/fragment shaders. + */ +static void +print_shader_limits(GLenum target) +{ + struct token_name { + GLenum token; + const char *name; + }; +#if defined(GL_ARB_vertex_shader) + static const struct token_name vertex_limits[] = { + { GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB, "GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB" }, + { GL_MAX_VARYING_FLOATS_ARB, "GL_MAX_VARYING_FLOATS_ARB" }, + { GL_MAX_VERTEX_ATTRIBS_ARB, "GL_MAX_VERTEX_ATTRIBS_ARB" }, + { GL_MAX_TEXTURE_IMAGE_UNITS_ARB, "GL_MAX_TEXTURE_IMAGE_UNITS_ARB" }, + { GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB, "GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB" }, + { GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB, "GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB" }, + { GL_MAX_TEXTURE_COORDS_ARB, "GL_MAX_TEXTURE_COORDS_ARB" }, + { (GLenum) 0, NULL } + }; +#endif +#if defined(GL_ARB_fragment_shader) + static const struct token_name fragment_limits[] = { + { GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB, "GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB" }, + { GL_MAX_TEXTURE_COORDS_ARB, "GL_MAX_TEXTURE_COORDS_ARB" }, + { GL_MAX_TEXTURE_IMAGE_UNITS_ARB, "GL_MAX_TEXTURE_IMAGE_UNITS_ARB" }, + { (GLenum) 0, NULL } + }; +#endif + GLint max[1]; + int i; + +#if defined(GL_ARB_vertex_shader) + if (target == GL_VERTEX_SHADER_ARB) { + printf(" GL_VERTEX_SHADER_ARB:\n"); + for (i = 0; vertex_limits[i].token; i++) { + glGetIntegerv(vertex_limits[i].token, max); + if (glGetError() == GL_NO_ERROR) { + printf(" %s = %d\n", vertex_limits[i].name, max[0]); + } + } + } +#endif +#if defined(GL_ARB_fragment_shader) + if (target == GL_FRAGMENT_SHADER_ARB) { + printf(" GL_FRAGMENT_SHADER_ARB:\n"); + for (i = 0; fragment_limits[i].token; i++) { + glGetIntegerv(fragment_limits[i].token, max); + if (glGetError() == GL_NO_ERROR) { + printf(" %s = %d\n", fragment_limits[i].name, max[0]); + } + } + } +#endif +} + + +/** + * Print interesting OpenGL implementation limits. + */ +static void +print_limits(const char *extensions) +{ + struct token_name { + GLuint count; + GLenum token; + const char *name; + }; + static const struct token_name limits[] = { + { 1, GL_MAX_ATTRIB_STACK_DEPTH, "GL_MAX_ATTRIB_STACK_DEPTH" }, + { 1, GL_MAX_CLIENT_ATTRIB_STACK_DEPTH, "GL_MAX_CLIENT_ATTRIB_STACK_DEPTH" }, + { 1, GL_MAX_CLIP_PLANES, "GL_MAX_CLIP_PLANES" }, + { 1, GL_MAX_COLOR_MATRIX_STACK_DEPTH, "GL_MAX_COLOR_MATRIX_STACK_DEPTH" }, + { 1, GL_MAX_ELEMENTS_VERTICES, "GL_MAX_ELEMENTS_VERTICES" }, + { 1, GL_MAX_ELEMENTS_INDICES, "GL_MAX_ELEMENTS_INDICES" }, + { 1, GL_MAX_EVAL_ORDER, "GL_MAX_EVAL_ORDER" }, + { 1, GL_MAX_LIGHTS, "GL_MAX_LIGHTS" }, + { 1, GL_MAX_LIST_NESTING, "GL_MAX_LIST_NESTING" }, + { 1, GL_MAX_MODELVIEW_STACK_DEPTH, "GL_MAX_MODELVIEW_STACK_DEPTH" }, + { 1, GL_MAX_NAME_STACK_DEPTH, "GL_MAX_NAME_STACK_DEPTH" }, + { 1, GL_MAX_PIXEL_MAP_TABLE, "GL_MAX_PIXEL_MAP_TABLE" }, + { 1, GL_MAX_PROJECTION_STACK_DEPTH, "GL_MAX_PROJECTION_STACK_DEPTH" }, + { 1, GL_MAX_TEXTURE_STACK_DEPTH, "GL_MAX_TEXTURE_STACK_DEPTH" }, + { 1, GL_MAX_TEXTURE_SIZE, "GL_MAX_TEXTURE_SIZE" }, + { 1, GL_MAX_3D_TEXTURE_SIZE, "GL_MAX_3D_TEXTURE_SIZE" }, + { 2, GL_MAX_VIEWPORT_DIMS, "GL_MAX_VIEWPORT_DIMS" }, + { 2, GL_ALIASED_LINE_WIDTH_RANGE, "GL_ALIASED_LINE_WIDTH_RANGE" }, + { 2, GL_SMOOTH_LINE_WIDTH_RANGE, "GL_SMOOTH_LINE_WIDTH_RANGE" }, + { 2, GL_ALIASED_POINT_SIZE_RANGE, "GL_ALIASED_POINT_SIZE_RANGE" }, + { 2, GL_SMOOTH_POINT_SIZE_RANGE, "GL_SMOOTH_POINT_SIZE_RANGE" }, +#if defined(GL_ARB_texture_cube_map) + { 1, GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB, "GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB" }, +#endif +#if defined(GLX_NV_texture_rectangle) + { 1, GL_MAX_RECTANGLE_TEXTURE_SIZE_NV, "GL_MAX_RECTANGLE_TEXTURE_SIZE_NV" }, +#endif +#if defined(GL_ARB_texture_compression) + { 1, GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB, "GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB" }, +#endif +#if defined(GL_ARB_multitexture) + { 1, GL_MAX_TEXTURE_UNITS_ARB, "GL_MAX_TEXTURE_UNITS_ARB" }, +#endif +#if defined(GL_EXT_texture_lod_bias) + { 1, GL_MAX_TEXTURE_LOD_BIAS_EXT, "GL_MAX_TEXTURE_LOD_BIAS_EXT" }, +#endif +#if defined(GL_EXT_texture_filter_anisotropic) + { 1, GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, "GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT" }, +#endif +#if defined(GL_ARB_draw_buffers) + { 1, GL_MAX_DRAW_BUFFERS_ARB, "GL_MAX_DRAW_BUFFERS_ARB" }, +#endif + { 0, (GLenum) 0, NULL } + }; + GLint i, max[2]; + + printf("OpenGL limits:\n"); + for (i = 0; limits[i].count; i++) { + glGetIntegerv(limits[i].token, max); + if (glGetError() == GL_NO_ERROR) { + if (limits[i].count == 1) + printf(" %s = %d\n", limits[i].name, max[0]); + else /* XXX fix if we ever query something with more than 2 values */ + printf(" %s = %d, %d\n", limits[i].name, max[0], max[1]); + } + } + + /* these don't fit into the above mechanism, unfortunately */ + glGetConvolutionParameteriv(GL_CONVOLUTION_2D, GL_MAX_CONVOLUTION_WIDTH, max); + glGetConvolutionParameteriv(GL_CONVOLUTION_2D, GL_MAX_CONVOLUTION_HEIGHT, max+1); + if (glGetError() == GL_NONE) { + printf(" GL_MAX_CONVOLUTION_WIDTH/HEIGHT = %d, %d\n", max[0], max[1]); + } + +#if defined(GL_ARB_vertex_program) + if (strstr(extensions, "GL_ARB_vertex_program")) { + print_program_limits(GL_VERTEX_PROGRAM_ARB); + } +#endif +#if defined(GL_ARB_fragment_program) + if (strstr(extensions, "GL_ARB_fragment_program")) { + print_program_limits(GL_FRAGMENT_PROGRAM_ARB); + } +#endif +#if defined(GL_ARB_vertex_shader) + if (strstr(extensions, "GL_ARB_vertex_shader")) { + print_shader_limits(GL_VERTEX_SHADER_ARB); + } +#endif +#if defined(GL_ARB_fragment_shader) + if (strstr(extensions, "GL_ARB_fragment_shader")) { + print_shader_limits(GL_FRAGMENT_SHADER_ARB); + } +#endif +} + + +static void +print_screen_info(Display *dpy, int scrnum, Bool allowDirect, GLboolean limits) +{ + 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 }; + + XSetWindowAttributes attr; + unsigned long mask; + Window root; + GLXContext ctx; + 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; + } + } + + attr.background_pixel = 0; + attr.border_pixel = 0; + 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); + + ctx = glXCreateContext( dpy, visinfo, NULL, allowDirect ); + if (!ctx) { + fprintf(stderr, "Error: glXCreateContext failed\n"); + XFree(visinfo); + 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); + int glxVersionMajor; + int glxVersionMinor; + char *displayName = NULL; + char *colon = NULL, *period = NULL; + + if (! glXQueryVersion( dpy, & glxVersionMajor, & glxVersionMinor )) { + fprintf(stderr, "Error: glXQueryVersion failed\n"); + exit(1); + } + + /* Strip the screen number from the display name, if present. */ + if (!(displayName = (char *) malloc(strlen(DisplayString(dpy)) + 1))) { + fprintf(stderr, "Error: malloc() failed\n"); + exit(1); + } + strcpy(displayName, DisplayString(dpy)); + colon = strrchr(displayName, ':'); + if (colon) { + period = strchr(colon, '.'); + if (period) + *period = '\0'; + } + printf("display: %s screen: %d\n", displayName, scrnum); + free(displayName); + 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 version: %u.%u\n", glxVersionMajor, glxVersionMinor); + 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); + if (limits) + print_limits(glExtensions); + } + else { + fprintf(stderr, "Error: glXMakeCurrent failed\n"); + } + + glXDestroyContext(dpy, ctx); + XFree(visinfo); + 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); + + /* get transparent pixel stuff */ + glXGetConfig(dpy, vInfo,GLX_TRANSPARENT_TYPE, &attribs->transparentType); + if (attribs->transparentType == GLX_TRANSPARENT_RGB) { + glXGetConfig(dpy, vInfo, GLX_TRANSPARENT_RED_VALUE, &attribs->transparentRedValue); + glXGetConfig(dpy, vInfo, GLX_TRANSPARENT_GREEN_VALUE, &attribs->transparentGreenValue); + glXGetConfig(dpy, vInfo, GLX_TRANSPARENT_BLUE_VALUE, &attribs->transparentBlueValue); + glXGetConfig(dpy, vInfo, GLX_TRANSPARENT_ALPHA_VALUE, &attribs->transparentAlphaValue); + } + else if (attribs->transparentType == GLX_TRANSPARENT_INDEX) { + glXGetConfig(dpy, vInfo, GLX_TRANSPARENT_INDEX_VALUE, &attribs->transparentIndexValue); + } + + /* multisample attribs */ +#ifdef GLX_ARB_multisample + if (ext && strstr(ext, "GLX_ARB_multisample") == 0) { + glXGetConfig(dpy, vInfo, GLX_SAMPLE_BUFFERS_ARB, &attribs->numMultisample); + glXGetConfig(dpy, vInfo, GLX_SAMPLES_ARB, &attribs->numSamples); + } +#endif + else { + 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 + if (attribs->transparentType == GLX_NONE) { + printf(" Opaque.\n"); + } + else if (attribs->transparentType == GLX_TRANSPARENT_RGB) { + printf(" Transparent RGB: Red=%d Green=%d Blue=%d Alpha=%d\n",attribs->transparentRedValue,attribs->transparentGreenValue,attribs->transparentBlueValue,attribs->transparentAlphaValue); + } + else if (attribs->transparentType == GLX_TRANSPARENT_INDEX) { + printf(" Transparent index=%d\n",attribs->transparentIndexValue); + } +} + + +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 = NULL; +#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"; +#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->transparentType != GLX_NONE, + 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->transparentType != GLX_NONE, + 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 theTemplate; + XVisualInfo *visuals; + int numVisuals; + long mask; + int i; + + /* get list of all visuals on this screen */ + theTemplate.screen = scrnum; + mask = VisualScreenMask; + visuals = XGetVisualInfo(dpy, mask, &theTemplate, &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); +} + + +/* + * Stand-alone Mesa doesn't really implement the GLX protocol so it + * doesn't really know the GLX attributes associated with an X visual. + * The first time a visual is presented to Mesa's pseudo-GLX it + * attaches ancilliary buffers to it (like depth and stencil). + * But that usually only works if glXChooseVisual is used. + * This function calls glXChooseVisual() to sort of "prime the pump" + * for Mesa's GLX so that the visuals that get reported actually + * reflect what applications will see. + * This has no effect when using true GLX. + */ +static void +mesa_hack(Display *dpy, int scrnum) +{ + static int attribs[] = { + GLX_RGBA, + GLX_RED_SIZE, 1, + GLX_GREEN_SIZE, 1, + GLX_BLUE_SIZE, 1, + GLX_DEPTH_SIZE, 1, + GLX_STENCIL_SIZE, 1, + GLX_ACCUM_RED_SIZE, 1, + GLX_ACCUM_GREEN_SIZE, 1, + GLX_ACCUM_BLUE_SIZE, 1, + GLX_ACCUM_ALPHA_SIZE, 1, + GLX_DOUBLEBUFFER, + None + }; + XVisualInfo *visinfo; + + visinfo = glXChooseVisual(dpy, scrnum, attribs); + if (visinfo) + XFree(visinfo); +} + + +/* + * Examine all visuals to find the so-called best one. + * We prefer deepest RGBA buffer with depth, stencil and accum + * that has no caveats. + */ +static int +find_best_visual(Display *dpy, int scrnum) +{ + XVisualInfo theTemplate; + XVisualInfo *visuals; + int numVisuals; + long mask; + int i; + struct visual_attribs bestVis; + + /* get list of all visuals on this screen */ + theTemplate.screen = scrnum; + mask = VisualScreenMask; + visuals = XGetVisualInfo(dpy, mask, &theTemplate, &numVisuals); + + /* init bestVis with first visual info */ + get_visual_attribs(dpy, &visuals[0], &bestVis); + + /* try to find a "better" visual */ + for (i = 1; i < numVisuals; i++) { + struct visual_attribs vis; + + get_visual_attribs(dpy, &visuals[i], &vis); + + /* always skip visuals with caveats */ + if (vis.visualCaveat != GLX_NONE_EXT) + continue; + + /* see if this vis is better than bestVis */ + if ((!bestVis.supportsGL && vis.supportsGL) || + (bestVis.visualCaveat != GLX_NONE_EXT) || + (!bestVis.rgba && vis.rgba) || + (!bestVis.doubleBuffer && vis.doubleBuffer) || + (bestVis.redSize < vis.redSize) || + (bestVis.greenSize < vis.greenSize) || + (bestVis.blueSize < vis.blueSize) || + (bestVis.alphaSize < vis.alphaSize) || + (bestVis.depthSize < vis.depthSize) || + (bestVis.stencilSize < vis.stencilSize) || + (bestVis.accumRedSize < vis.accumRedSize)) { + /* found a better visual */ + bestVis = vis; + } + } + + XFree(visuals); + + return bestVis.id; +} + + +static void +usage(void) +{ + printf("Usage: glxinfo [-v] [-t] [-h] [-i] [-b] [-display ]\n"); + printf("\t-v: Print visuals info in verbose form.\n"); + printf("\t-t: Print verbose table.\n"); + printf("\t-display : Print GLX visuals on specified server.\n"); + printf("\t-h: This information.\n"); + printf("\t-i: Force an indirect rendering context.\n"); + printf("\t-b: Find the 'best' visual and print it's number.\n"); + printf("\t-l: Print interesting OpenGL limits.\n"); +} + + +int +main(int argc, char *argv[]) +{ + char *displayName = NULL; + Display *dpy; + int numScreens, scrnum; + InfoMode mode = Normal; + GLboolean findBest = GL_FALSE; + GLboolean limits = GL_FALSE; + Bool allowDirect = True; + 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; + } + else if (strcmp(argv[i], "-b") == 0) { + findBest = GL_TRUE; + } + else if (strcmp(argv[i], "-i") == 0) { + allowDirect = False; + } + else if (strcmp(argv[i], "-l") == 0) { + limits = GL_TRUE; + } + else if (strcmp(argv[i], "-h") == 0) { + usage(); + return 0; + } + else { + printf("Unknown option `%s'\n", argv[i]); + usage(); + return 0; + } + } + + dpy = XOpenDisplay(displayName); + if (!dpy) { + fprintf(stderr, "Error: unable to open display %s\n", displayName); + return -1; + } + + if (findBest) { + int b; + mesa_hack(dpy, 0); + b = find_best_visual(dpy, 0); + printf("%d\n", b); + } + else { + numScreens = ScreenCount(dpy); + print_display_info(dpy); + for (scrnum = 0; scrnum < numScreens; scrnum++) { + mesa_hack(dpy, scrnum); + print_screen_info(dpy, scrnum, allowDirect, limits); + printf("\n"); + print_visual_info(dpy, scrnum, mode); + if (scrnum + 1 < numScreens) + printf("\n\n"); + } + } + + XCloseDisplay(dpy); + + return 0; +} diff --git a/progs/xdemos/glxpbdemo.c b/progs/xdemos/glxpbdemo.c new file mode 100644 index 00000000000..91fd30dcaa6 --- /dev/null +++ b/progs/xdemos/glxpbdemo.c @@ -0,0 +1,430 @@ + +/* + * This program demonstrates how to do "off-screen" rendering using + * the GLX pixel buffer extension. + * + * Written by Brian Paul for the "OpenGL and Window System Integration" + * course presented at SIGGRAPH '97. Updated on 5 October 2002. + * + * Updated on 31 January 2004 to use native GLX by + * Andrew P. Lentvorski, Jr. + * + * Usage: + * glxpbdemo width height imgfile + * Where: + * width is the width, in pixels, of the image to generate. + * height is the height, in pixels, of the image to generate. + * imgfile is the name of the PPM image file to write. + * + * + * This demo draws 3-D boxes with random orientation. + * + * On machines such as the SGI Indigo you may have to reconfigure your + * display/X server to enable pbuffers. Look in the /usr/gfx/ucode/MGRAS/vof/ + * directory for display configurations with the _pbuf suffix. Use + * setmon -x to configure your X server and display for pbuffers. + * + * O2 systems seem to support pbuffers well. + * + */ + +#include +#include +#include +#include +#include + +/* Some ugly global vars */ +static GLXFBConfig gFBconfig = 0; +static Display *gDpy = NULL; +static int gScreen = 0; +static GLXPbuffer gPBuffer = 0; +static int gWidth, gHeight; + + +/* + * Test for appropriate version of GLX to run this program + * Input: dpy - the X display + * screen - screen number + * Return: 0 = GLX not available. + * 1 = GLX available. + */ +static int +RuntimeQueryGLXVersion(Display *dpy, int screen) +{ +#if defined(GLX_VERSION_1_3) || defined(GLX_VERSION_1_4) + char *glxversion; + + glxversion = (char *) glXGetClientString(dpy, GLX_VERSION); + if (!(strstr(glxversion, "1.3") || strstr(glxversion, "1.4"))) + return 0; + + glxversion = (char *) glXQueryServerString(dpy, screen, GLX_VERSION); + if (!(strstr(glxversion, "1.3") || strstr(glxversion, "1.4"))) + return 0; + + return 1; +#else + return 0; +#endif +} + + + +/* + * Create the pbuffer and return a GLXPbuffer handle. + */ +static GLXPbuffer +MakePbuffer( Display *dpy, int screen, int width, int height ) +{ + GLXFBConfig *fbConfigs; + GLXFBConfig chosenFBConfig; + GLXPbuffer pBuffer = None; + + int nConfigs; + int fbconfigid; + + int fbAttribs[] = { + GLX_RENDER_TYPE, GLX_RGBA_BIT, + GLX_DEPTH_SIZE, 1, + GLX_DRAWABLE_TYPE, GLX_PIXMAP_BIT | GLX_PBUFFER_BIT, + None + }; + + int pbAttribs[] = { + GLX_PBUFFER_WIDTH, 0, + GLX_PBUFFER_HEIGHT, 0, + GLX_LARGEST_PBUFFER, False, + GLX_PRESERVED_CONTENTS, False, + None + }; + + pbAttribs[1] = width; + pbAttribs[3] = height; + + fbConfigs = glXChooseFBConfig(dpy, screen, fbAttribs, &nConfigs); + + if (0 == nConfigs || !fbConfigs) { + printf("Error: glxChooseFBConfig failed\n"); + XCloseDisplay(dpy); + return 0; + } + + chosenFBConfig = fbConfigs[0]; + + glXGetFBConfigAttrib(dpy, chosenFBConfig, GLX_FBCONFIG_ID, &fbconfigid); + printf("Chose 0x%x as fbconfigid\n", fbconfigid); + + /* Create the pbuffer using first fbConfig in the list that works. */ + pBuffer = glXCreatePbuffer(dpy, chosenFBConfig, pbAttribs); + + if (pBuffer) { + gFBconfig = chosenFBConfig; + gWidth = width; + gHeight = height; + } + + XFree(fbConfigs); + + return pBuffer; +} + + + +/* + * Do all the X / GLX setup stuff. + */ +static int +Setup(int width, int height) +{ +#if defined(GLX_VERSION_1_3) || defined(GLX_VERSION_1_4) + GLXContext glCtx; + + /* Open the X display */ + gDpy = XOpenDisplay(NULL); + if (!gDpy) { + printf("Error: couldn't open default X display.\n"); + return 0; + } + + /* Get default screen */ + gScreen = DefaultScreen(gDpy); + + /* Test that GLX is available */ + if (!RuntimeQueryGLXVersion(gDpy, gScreen)) { + printf("Error: GLX 1.3 or 1.4 not available\n"); + XCloseDisplay(gDpy); + return 0; + } + + /* Create Pbuffer */ + gPBuffer = MakePbuffer( gDpy, gScreen, width, height ); + if (gPBuffer==None) { + printf("Error: couldn't create pbuffer\n"); + XCloseDisplay(gDpy); + return 0; + } + + /* Create GLX context */ + glCtx = glXCreateNewContext(gDpy, gFBconfig, GLX_RGBA_TYPE, NULL, True); + if (glCtx) { + if (!glXIsDirect(gDpy, glCtx)) { + printf("Warning: using indirect GLXContext\n"); + } + } + else { + printf("Error: Couldn't create GLXContext\n"); + XCloseDisplay(gDpy); + return 0; + } + + /* Bind context to pbuffer */ + if (!glXMakeCurrent(gDpy, gPBuffer, glCtx)) { + printf("Error: glXMakeCurrent failed\n"); + XCloseDisplay(gDpy); + return 0; + } + + return 1; /* Success!! */ +#else + printf("Error: GLX version 1.3 or 1.4 not available at compile time\n"); + return 0; +#endif +} + + + +/* One-time GL setup */ +static void +InitGL(void) +{ + static GLfloat pos[4] = {0.0, 0.0, 10.0, 0.0}; + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + glLightfv(GL_LIGHT0, GL_POSITION, pos); + glEnable(GL_NORMALIZE); + glEnable(GL_DEPTH_TEST); + glEnable(GL_CULL_FACE); + + glViewport(0, 0, gWidth, gHeight); + 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 ); + +} + + +/* Return random float in [0,1] */ +static float +Random(void) +{ + int i = rand(); + return (float) (i % 1000) / 1000.0; +} + + +static void +RandomColor(void) +{ + GLfloat c[4]; + c[0] = Random(); + c[1] = Random(); + c[2] = Random(); + c[3] = 1.0; + glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, c); +} + + +/* This function borrowed from Mark Kilgard's GLUT */ +static void +drawBox(GLfloat x0, GLfloat x1, GLfloat y0, GLfloat y1, + GLfloat z0, GLfloat z1, GLenum type) +{ + static GLfloat n[6][3] = + { + {-1.0, 0.0, 0.0}, + {0.0, 1.0, 0.0}, + {1.0, 0.0, 0.0}, + {0.0, -1.0, 0.0}, + {0.0, 0.0, 1.0}, + {0.0, 0.0, -1.0} + }; + static GLint faces[6][4] = + { + {0, 1, 2, 3}, + {3, 2, 6, 7}, + {7, 6, 5, 4}, + {4, 5, 1, 0}, + {5, 6, 2, 1}, + {7, 4, 0, 3} + }; + GLfloat v[8][3], tmp; + GLint i; + + if (x0 > x1) { + tmp = x0; + x0 = x1; + x1 = tmp; + } + if (y0 > y1) { + tmp = y0; + y0 = y1; + y1 = tmp; + } + if (z0 > z1) { + tmp = z0; + z0 = z1; + z1 = tmp; + } + v[0][0] = v[1][0] = v[2][0] = v[3][0] = x0; + v[4][0] = v[5][0] = v[6][0] = v[7][0] = x1; + v[0][1] = v[1][1] = v[4][1] = v[5][1] = y0; + v[2][1] = v[3][1] = v[6][1] = v[7][1] = y1; + v[0][2] = v[3][2] = v[4][2] = v[7][2] = z0; + v[1][2] = v[2][2] = v[5][2] = v[6][2] = z1; + + for (i = 0; i < 6; i++) { + glBegin(type); + glNormal3fv(&n[i][0]); + glVertex3fv(&v[faces[i][0]][0]); + glVertex3fv(&v[faces[i][1]][0]); + glVertex3fv(&v[faces[i][2]][0]); + glVertex3fv(&v[faces[i][3]][0]); + glEnd(); + } +} + + + +/* Render a scene */ +static void +Render(void) +{ + int NumBoxes = 100; + int i; + + InitGL(); + glClearColor(0.2, 0.2, 0.9, 0.0); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + for (i=0;i +#define GLX_GLXEXT_PROTOTYPES +#include +#include +#include +#include + + +static GLXContext ctx; +static XVisualInfo *visinfo; +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 scrnum; + XSetWindowAttributes attr; + unsigned long mask; + Window root; + Window win; + + scrnum = DefaultScreen( dpy ); + root = RootWindow( dpy, scrnum ); + + visinfo = glXChooseVisual( dpy, scrnum, (int *) sbAttrib ); + if (!visinfo) { + visinfo = glXChooseVisual( dpy, scrnum, (int *) dbAttrib ); + if (!visinfo) { + printf("Error: couldn't get an RGB visual\n"); + exit(1); + } + } + + /* window attributes */ + attr.background_pixel = 0; + attr.border_pixel = 0; + /* TODO: share root colormap if possible */ + 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 ); + + /* 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"); + + return win; +} + + +static GLXPixmap make_pixmap( Display *dpy, Window win, + unsigned int width, unsigned int height, + Pixmap *pixmap) +{ + 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 ); + + /* + * IMPORTANT: + * Use the glXCreateGLXPixmapMESA funtion when using Mesa because + * Mesa needs to know the colormap associated with a pixmap in order + * to render correctly. This is because Mesa allows RGB rendering + * 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 ); + } +#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; +} + + + +static void event_loop( Display *dpy, GLXPixmap pm ) +{ + XEvent event; + + while (1) { + XNextEvent( dpy, &event ); + + switch (event.type) { + case Expose: + printf("Redraw\n"); + /* copy the image from GLXPixmap to window */ + XCopyArea( dpy, pm, event.xany.window, /* src, dest */ + gc, 0, 0, 300, 300, /* gc, src pos, size */ + 0, 0 ); /* dest pos */ + break; + case ConfigureNotify: + /* nothing */ + break; + } + } +} + + + +int main( int argc, char *argv[] ) +{ + Display *dpy; + Window win; + Pixmap pm; + GLXPixmap glxpm; + + dpy = XOpenDisplay(NULL); + + win = make_rgb_window( dpy, 300, 300 ); + glxpm = make_pixmap( dpy, win, 300, 300, &pm ); + + glXMakeCurrent( dpy, glxpm, ctx ); + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + /* Render an image into the pixmap */ + glShadeModel( GL_FLAT ); + glClearColor( 0.5, 0.5, 0.5, 1.0 ); + glClear( GL_COLOR_BUFFER_BIT ); + glViewport( 0, 0, 300, 300 ); + glOrtho( -1.0, 1.0, -1.0, 1.0, -1.0, 1.0 ); + glColor3f( 0.0, 1.0, 1.0 ); + glRectf( -0.75, -0.75, 0.75, 0.75 ); + glFlush(); + + XMapWindow( dpy, win ); + + event_loop( dpy, pm ); + return 0; +} diff --git a/progs/xdemos/glxswapcontrol.c b/progs/xdemos/glxswapcontrol.c new file mode 100644 index 00000000000..0ed5ebe4722 --- /dev/null +++ b/progs/xdemos/glxswapcontrol.c @@ -0,0 +1,824 @@ +/* + * Copyright (C) 1999-2001 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 port of the infamous "gears" demo to straight GLX (i.e. no GLUT) + * Port by Brian Paul 23 March 2001 + * + * Modified by Ian Romanick 09 April 2003 to support + * GLX_{MESA,SGI}_swap_control and GLX_OML_sync_control. + * + * Command line options: + * -display Name of the display to use. + * -info print GL implementation information + * -swap N Attempt to set the swap interval to 1/N second + * -forcegetrate Get the display refresh rate even if the required GLX + * extension is not supported. + */ + + +#include +#include +#include +#include +#include +#include +#ifndef __VMS +/*# include */ +#endif +# define GLX_GLXEXT_PROTOTYPES +#include +#include + +#ifndef GLX_MESA_swap_control +typedef GLint ( * PFNGLXSWAPINTERVALMESAPROC) (unsigned interval); +typedef GLint ( * PFNGLXGETSWAPINTERVALMESAPROC) ( void ); +#endif + +#if !defined( GLX_OML_sync_control ) && defined( _STDINT_H ) +#define GLX_OML_sync_control 1 +typedef Bool ( * PFNGLXGETMSCRATEOMLPROC) (Display *dpy, GLXDrawable drawable, int32_t *numerator, int32_t *denominator); +#endif + +#ifndef GLX_MESA_swap_frame_usage +#define GLX_MESA_swap_frame_usage 1 +typedef int ( * PFNGLXGETFRAMEUSAGEMESAPROC) (Display *dpy, GLXDrawable drawable, float * usage ); +#endif + +#define BENCHMARK + +PFNGLXGETFRAMEUSAGEMESAPROC get_frame_usage = NULL; + +#ifdef BENCHMARK + +/* XXX this probably isn't very portable */ + +#include +#include + +#define NUL '\0' + +/* return current time (in seconds) */ +static int +current_time(void) +{ + struct timeval tv; +#ifdef __VMS + (void) gettimeofday(&tv, NULL ); +#else + struct timezone tz; + (void) gettimeofday(&tv, &tz); +#endif + return (int) tv.tv_sec; +} + +#else /*BENCHMARK*/ + +/* dummy */ +static int +current_time(void) +{ + return 0; +} + +#endif /*BENCHMARK*/ + + + +#ifndef M_PI +#define M_PI 3.14159265 +#endif + + +static GLfloat view_rotx = 20.0, view_roty = 30.0, view_rotz = 0.0; +static GLint gear1, gear2, gear3; +static GLfloat angle = 0.0; + +static GLboolean has_OML_sync_control = GL_FALSE; +static GLboolean has_SGI_swap_control = GL_FALSE; +static GLboolean has_MESA_swap_control = GL_FALSE; +static GLboolean has_MESA_swap_frame_usage = GL_FALSE; + +static char ** extension_table = NULL; +static unsigned num_extensions; + +static GLboolean use_ztrick = GL_FALSE; +static GLfloat aspect; + +/* + * + * Draw a gear wheel. You'll probably want to call this function when + * building a display list since we do a lot of trig here. + * + * Input: inner_radius - radius of hole at center + * outer_radius - radius at center of teeth + * width - width of gear + * teeth - number of teeth + * tooth_depth - depth of tooth + */ +static void +gear(GLfloat inner_radius, GLfloat outer_radius, GLfloat width, + GLint teeth, GLfloat tooth_depth) +{ + GLint i; + GLfloat r0, r1, r2; + GLfloat angle, da; + GLfloat u, v, len; + + r0 = inner_radius; + r1 = outer_radius - tooth_depth / 2.0; + r2 = outer_radius + tooth_depth / 2.0; + + da = 2.0 * M_PI / teeth / 4.0; + + glShadeModel(GL_FLAT); + + glNormal3f(0.0, 0.0, 1.0); + + /* draw front face */ + glBegin(GL_QUAD_STRIP); + for (i = 0; i <= teeth; i++) { + angle = i * 2.0 * M_PI / teeth; + glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5); + glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5); + if (i < teeth) { + glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5); + glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), + width * 0.5); + } + } + glEnd(); + + /* draw front sides of teeth */ + glBegin(GL_QUADS); + da = 2.0 * M_PI / teeth / 4.0; + for (i = 0; i < teeth; i++) { + angle = i * 2.0 * M_PI / teeth; + + glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5); + glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), width * 0.5); + glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), + width * 0.5); + glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), + width * 0.5); + } + glEnd(); + + glNormal3f(0.0, 0.0, -1.0); + + /* draw back face */ + glBegin(GL_QUAD_STRIP); + for (i = 0; i <= teeth; i++) { + angle = i * 2.0 * M_PI / teeth; + glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5); + glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5); + if (i < teeth) { + glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), + -width * 0.5); + glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5); + } + } + glEnd(); + + /* draw back sides of teeth */ + glBegin(GL_QUADS); + da = 2.0 * M_PI / teeth / 4.0; + for (i = 0; i < teeth; i++) { + angle = i * 2.0 * M_PI / teeth; + + glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), + -width * 0.5); + glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), + -width * 0.5); + glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), -width * 0.5); + glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5); + } + glEnd(); + + /* draw outward faces of teeth */ + glBegin(GL_QUAD_STRIP); + for (i = 0; i < teeth; i++) { + angle = i * 2.0 * M_PI / teeth; + + glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5); + glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5); + u = r2 * cos(angle + da) - r1 * cos(angle); + v = r2 * sin(angle + da) - r1 * sin(angle); + len = sqrt(u * u + v * v); + u /= len; + v /= len; + glNormal3f(v, -u, 0.0); + glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), width * 0.5); + glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), -width * 0.5); + glNormal3f(cos(angle), sin(angle), 0.0); + glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), + width * 0.5); + glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), + -width * 0.5); + u = r1 * cos(angle + 3 * da) - r2 * cos(angle + 2 * da); + v = r1 * sin(angle + 3 * da) - r2 * sin(angle + 2 * da); + glNormal3f(v, -u, 0.0); + glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), + width * 0.5); + glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), + -width * 0.5); + glNormal3f(cos(angle), sin(angle), 0.0); + } + + glVertex3f(r1 * cos(0), r1 * sin(0), width * 0.5); + glVertex3f(r1 * cos(0), r1 * sin(0), -width * 0.5); + + glEnd(); + + glShadeModel(GL_SMOOTH); + + /* draw inside radius cylinder */ + glBegin(GL_QUAD_STRIP); + for (i = 0; i <= teeth; i++) { + angle = i * 2.0 * M_PI / teeth; + glNormal3f(-cos(angle), -sin(angle), 0.0); + glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5); + glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5); + } + glEnd(); +} + + +static void +draw(void) +{ + if ( use_ztrick ) { + static GLboolean flip = GL_FALSE; + static const GLfloat vert[4][3] = { + { -1, -1, -0.999 }, + { 1, -1, -0.999 }, + { 1, 1, -0.999 }, + { -1, 1, -0.999 } + }; + static const GLfloat col[4][3] = { + { 1.0, 0.6, 0.0 }, + { 1.0, 0.6, 0.0 }, + { 0.0, 0.0, 0.0 }, + { 0.0, 0.0, 0.0 }, + }; + + if ( flip ) { + glDepthRange(0, 0.5); + glDepthFunc(GL_LEQUAL); + } + else { + glDepthRange(1.0, 0.4999); + glDepthFunc(GL_GEQUAL); + } + + flip = !flip; + + /* The famous Quake "Z trick" only works when the whole screen is + * re-drawn each frame. + */ + + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-1, 1, -1, 1, -1, 1); + glDisable(GL_LIGHTING); + glShadeModel(GL_SMOOTH); + + glEnable( GL_VERTEX_ARRAY ); + glEnable( GL_COLOR_ARRAY ); + glVertexPointer( 3, GL_FLOAT, 0, vert ); + glColorPointer( 3, GL_FLOAT, 0, col ); + glDrawArrays( GL_POLYGON, 0, 4 ); + glDisable( GL_COLOR_ARRAY ); + glDisable( GL_VERTEX_ARRAY ); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glFrustum(-1.0, 1.0, -aspect, aspect, 5.0, 60.0); + + glEnable(GL_LIGHTING); + + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTranslatef(0.0, 0.0, -40.0); + } + else { + 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); + + 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, 4.2, 0.0); + glRotatef(-2.0 * angle - 25.0, 0.0, 0.0, 1.0); + glCallList(gear3); + glPopMatrix(); + + glPopMatrix(); +} + + +/* new window size or exposure */ +static void +reshape(int width, int height) +{ + aspect = (GLfloat) height / (GLfloat) width; + + + glViewport(0, 0, (GLint) width, (GLint) height); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + + glFrustum(-1.0, 1.0, -aspect, aspect, 5.0, 60.0); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTranslatef(0.0, 0.0, -40.0); +} + + +static void +init(void) +{ + 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); + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + glEnable(GL_DEPTH_TEST); + + /* make the gears */ + gear1 = glGenLists(1); + glNewList(gear1, GL_COMPILE); + glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, red); + gear(1.0, 4.0, 1.0, 20, 0.7); + glEndList(); + + gear2 = glGenLists(1); + glNewList(gear2, GL_COMPILE); + glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, green); + gear(0.5, 2.0, 2.0, 10, 0.7); + glEndList(); + + gear3 = glGenLists(1); + glNewList(gear3, GL_COMPILE); + glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, blue); + gear(1.3, 2.0, 0.5, 10, 0.7); + glEndList(); + + glEnable(GL_NORMALIZE); +} + + +/* + * Create an RGB, double-buffered window. + * Return the window and context handles. + */ +static void +make_window( Display *dpy, const char *name, + int x, int y, int width, int height, + Window *winRet, GLXContext *ctxRet) +{ + int attrib[] = { GLX_RGBA, + GLX_RED_SIZE, 1, + GLX_GREEN_SIZE, 1, + GLX_BLUE_SIZE, 1, + GLX_DOUBLEBUFFER, + GLX_DEPTH_SIZE, 1, + None }; + int scrnum; + XSetWindowAttributes attr; + unsigned long mask; + Window root; + Window win; + GLXContext ctx; + XVisualInfo *visinfo; + + scrnum = DefaultScreen( dpy ); + root = RootWindow( dpy, scrnum ); + + visinfo = glXChooseVisual( dpy, scrnum, attrib ); + if (!visinfo) { + printf("Error: couldn't get an RGB, Double-buffered visual\n"); + exit(1); + } + + /* 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 ); + + /* set hints and properties */ + { + XSizeHints sizehints; + sizehints.x = x; + sizehints.y = y; + 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) { + printf("Error: glXCreateContext failed\n"); + exit(1); + } + + XFree(visinfo); + + *winRet = win; + *ctxRet = ctx; +} + + +static void +event_loop(Display *dpy, Window win) +{ + float frame_usage = 0.0; + + while (1) { + while (XPending(dpy) > 0) { + XEvent event; + XNextEvent(dpy, &event); + switch (event.type) { + case Expose: + /* we'll redraw below */ + break; + case ConfigureNotify: + reshape(event.xconfigure.width, event.xconfigure.height); + break; + case KeyPress: + { + char buffer[10]; + int r, code; + code = XLookupKeysym(&event.xkey, 0); + if (code == XK_Left) { + view_roty += 5.0; + } + else if (code == XK_Right) { + view_roty -= 5.0; + } + else if (code == XK_Up) { + view_rotx += 5.0; + } + else if (code == XK_Down) { + view_rotx -= 5.0; + } + else { + r = XLookupString(&event.xkey, buffer, sizeof(buffer), + NULL, NULL); + if (buffer[0] == 27) { + /* escape */ + return; + } + } + } + } + } + + /* next frame */ + angle += 2.0; + + draw(); + if ( get_frame_usage != NULL ) { + GLfloat temp; + + (*get_frame_usage)( dpy, win, & temp ); + frame_usage += temp; + } + + glXSwapBuffers(dpy, win); + + /* calc framerate */ + { + static int t0 = -1; + static int frames = 0; + int t = current_time(); + + if (t0 < 0) + t0 = t; + + frames++; + + if (t - t0 >= 5.0) { + GLfloat seconds = t - t0; + GLfloat fps = frames / seconds; + if ( get_frame_usage != NULL ) { + printf("%d frames in %3.1f seconds = %6.3f FPS (%3.1f%% usage)\n", + frames, seconds, fps, + (frame_usage * 100.0) / (float) frames ); + } + else { + printf("%d frames in %3.1f seconds = %6.3f FPS\n", + frames, seconds, fps); + } + + t0 = t; + frames = 0; + frame_usage = 0.0; + } + } + } +} + + +/** + * Display the refresh rate of the display using the GLX_OML_sync_control + * extension. + */ + +static void +show_refresh_rate( Display * dpy ) +{ +#if defined(GLX_OML_sync_control) && defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) + PFNGLXGETMSCRATEOMLPROC get_msc_rate; + int32_t n; + int32_t d; + + get_msc_rate = (PFNGLXGETMSCRATEOMLPROC) glXGetProcAddressARB( (const GLubyte *) "glXGetMscRateOML" ); + if ( get_msc_rate != NULL ) { + (*get_msc_rate)( dpy, glXGetCurrentDrawable(), &n, &d ); + printf( "refresh rate: %.1fHz\n", (float) n / d ); + return; + } +#endif + printf( "glXGetMscRateOML not supported.\n" ); +} + + +/** + * Fill in the table of extension strings from a supplied extensions string + * (as returned by glXQueryExtensionsString). + * + * \param string String of GLX extensions. + * \sa is_extension_supported + */ + +static void +make_extension_table( const char * string ) +{ + char ** string_tab; + unsigned num_strings; + unsigned base; + unsigned idx; + unsigned i; + + /* Count the number of spaces in the string. That gives a base-line + * figure for the number of extension in the string. + */ + + num_strings = 1; + for ( i = 0 ; string[i] != NUL ; i++ ) { + if ( string[i] == ' ' ) { + num_strings++; + } + } + + string_tab = (char **) malloc( sizeof( char * ) * num_strings ); + if ( string_tab == NULL ) { + return; + } + + base = 0; + idx = 0; + + while ( string[ base ] != NUL ) { + /* Determine the length of the next extension string. + */ + + for ( i = 0 + ; (string[ base + i ] != NUL) && (string[ base + i ] != ' ') + ; i++ ) { + /* empty */ ; + } + + if ( i > 0 ) { + /* If the string was non-zero length, add it to the table. We + * can get zero length strings if there is a space at the end of + * the string or if there are two (or more) spaces next to each + * other in the string. + */ + + string_tab[ idx ] = malloc( sizeof( char ) * (i + 1) ); + if ( string_tab[ idx ] == NULL ) { + return; + } + + (void) memcpy( string_tab[ idx ], & string[ base ], i ); + string_tab[ idx ][i] = NUL; + idx++; + } + + + /* Skip to the start of the next extension string. + */ + + for ( base += i + ; (string[ base ] == ' ') && (string[ base ] != NUL) + ; base++ ) { + /* empty */ ; + } + } + + extension_table = string_tab; + num_extensions = idx; +} + + +/** + * Determine of an extension is supported. The extension string table + * must have already be initialized by calling \c make_extension_table. + * + * \praram ext Extension to be tested. + * \return GL_TRUE of the extension is supported, GL_FALSE otherwise. + * \sa make_extension_table + */ + +static GLboolean +is_extension_supported( const char * ext ) +{ + unsigned i; + + for ( i = 0 ; i < num_extensions ; i++ ) { + if ( strcmp( ext, extension_table[i] ) == 0 ) { + return GL_TRUE; + } + } + + return GL_FALSE; +} + + +int +main(int argc, char *argv[]) +{ + Display *dpy; + Window win; + GLXContext ctx; + char *dpyName = ":0"; + int swap_interval = 1; + GLboolean do_swap_interval = GL_FALSE; + GLboolean force_get_rate = GL_FALSE; + GLboolean printInfo = GL_FALSE; + int i; + PFNGLXSWAPINTERVALMESAPROC set_swap_interval = NULL; + PFNGLXGETSWAPINTERVALMESAPROC get_swap_interval = NULL; + + + for (i = 1; i < argc; i++) { + if (strcmp(argv[i], "-display") == 0 && i + 1 < argc) { + dpyName = argv[i+1]; + i++; + } + else if (strcmp(argv[i], "-info") == 0) { + printInfo = GL_TRUE; + } + else if (strcmp(argv[i], "-swap") == 0 && i + 1 < argc) { + swap_interval = atoi( argv[i+1] ); + do_swap_interval = GL_TRUE; + i++; + } + else if (strcmp(argv[i], "-forcegetrate") == 0) { + /* This option was put in because some DRI drivers don't support the + * full GLX_OML_sync_control extension, but they do support + * glXGetMscRateOML. + */ + force_get_rate = GL_TRUE; + } + else if (strcmp(argv[i], "-ztrick") == 0) { + use_ztrick = GL_TRUE; + } + else if (strcmp(argv[i], "-help") == 0) { + printf("Usage:\n"); + printf(" gears [options]\n"); + printf("Options:\n"); + printf(" -help Print this information\n"); + printf(" -display displayName Specify X display\n"); + printf(" -info Display GL information\n"); + printf(" -swap N Swap no more than once per N vertical refreshes\n"); + printf(" -forcegetrate Try to use glXGetMscRateOML function\n"); + return 0; + } + } + + dpy = XOpenDisplay(dpyName); + if (!dpy) { + printf("Error: couldn't open display %s\n", dpyName); + return -1; + } + + make_window(dpy, "glxgears", 0, 0, 300, 300, &win, &ctx); + XMapWindow(dpy, win); + glXMakeCurrent(dpy, win, ctx); + + make_extension_table( (char *) glXQueryExtensionsString(dpy,DefaultScreen(dpy)) ); + has_OML_sync_control = is_extension_supported( "GLX_OML_sync_control" ); + has_SGI_swap_control = is_extension_supported( "GLX_SGI_swap_control" ); + has_MESA_swap_control = is_extension_supported( "GLX_MESA_swap_control" ); + has_MESA_swap_frame_usage = is_extension_supported( "GLX_MESA_swap_frame_usage" ); + + if ( has_MESA_swap_control ) { + set_swap_interval = (PFNGLXSWAPINTERVALMESAPROC) glXGetProcAddressARB( (const GLubyte *) "glXSwapIntervalMESA" ); + get_swap_interval = (PFNGLXGETSWAPINTERVALMESAPROC) glXGetProcAddressARB( (const GLubyte *) "glXGetSwapIntervalMESA" ); + } + else if ( has_SGI_swap_control ) { + set_swap_interval = (PFNGLXSWAPINTERVALMESAPROC) glXGetProcAddressARB( (const GLubyte *) "glXSwapIntervalSGI" ); + } + + + if ( has_MESA_swap_frame_usage ) { + get_frame_usage = (PFNGLXGETFRAMEUSAGEMESAPROC) glXGetProcAddressARB( (const GLubyte *) "glXGetFrameUsageMESA" ); + } + + + if (printInfo) { + 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 ( has_OML_sync_control || force_get_rate ) { + show_refresh_rate( dpy ); + } + + if ( get_swap_interval != NULL ) { + printf("Default swap interval = %d\n", (*get_swap_interval)() ); + } + } + + if ( do_swap_interval ) { + if ( set_swap_interval != NULL ) { + if ( ((swap_interval == 0) && !has_MESA_swap_control) + || (swap_interval < 0) ) { + printf( "Swap interval must be non-negative or greater than zero " + "if GLX_MESA_swap_control is not supported.\n" ); + } + else { + (*set_swap_interval)( swap_interval ); + } + + if ( printInfo && (get_swap_interval != NULL) ) { + printf("Current swap interval = %d\n", (*get_swap_interval)() ); + } + } + else { + printf("Unable to set swap-interval. Neither GLX_SGI_swap_control " + "nor GLX_MESA_swap_control are supported.\n" ); + } + } + + init(); + + event_loop(dpy, win); + + glXDestroyContext(dpy, ctx); + XDestroyWindow(dpy, win); + XCloseDisplay(dpy); + + return 0; +} diff --git a/progs/xdemos/manywin.c b/progs/xdemos/manywin.c new file mode 100644 index 00000000000..c9cca751341 --- /dev/null +++ b/progs/xdemos/manywin.c @@ -0,0 +1,393 @@ +/* + * Create N GLX windows/contexts and render to them in round-robin order. + * Also, have the contexts share all texture objects. + * Press 'd' to delete a texture, 'u' to unbind it. + * + * 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 +#include +#include +#include +#include +#include +#include +#include + + +/* + * 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 GLboolean SwapSeparate = GL_TRUE; +static GLuint TexObj = 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); + } + + if (NumHeads == 0) { + ctx = glXCreateContext(dpy, visinfo, NULL, True); + } + else { + /* share textures & dlists with 0th context */ + printf("sharing\n"); + ctx = glXCreateContext(dpy, visinfo, Heads[0].Context, 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 NULL; + } + + if (NumHeads == 0) { + /* create texture object now */ + static const GLubyte checker[2][2][4] = { + { {255, 255, 255, 255}, { 0, 0, 0, 255} }, + { { 0, 0, 0, 0}, {255, 255, 255, 255} } + }; + glGenTextures(1, &TexObj); + assert(TexObj); + glBindTexture(GL_TEXTURE_2D, TexObj); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGB, + GL_UNSIGNED_BYTE, checker); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + } + else { + /* bind 0th context's texture in this context too */ + assert(TexObj); + glBindTexture(GL_TEXTURE_2D, TexObj); + } + glEnable(GL_TEXTURE_2D); + + /* 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 +DestroyHeads(void) +{ + int i; + for (i = 0; i < NumHeads; i++) { + XDestroyWindow(Heads[i].Dpy, Heads[i].Win); + glXDestroyContext(Heads[i].Dpy, Heads[i].Context); + XCloseDisplay(Heads[i].Dpy); + } +} + + +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); + glTexCoord2f(0.5, 1.0); glVertex2f(0, 0.8); + glTexCoord2f(0.0, 0.0); glVertex2f(-0.8, -0.7); + glTexCoord2f(1.0, 0.0); glVertex2f(0.8, -0.7); + glEnd(); + glPopMatrix(); + + if (!SwapSeparate) + glXSwapBuffers(h->Dpy, h->Win); +} + + +static void +Swap(struct head *h) +{ + 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); + if (SwapSeparate) + Swap(h); + break; + case ConfigureNotify: + Resize(h, event.xconfigure.width, event.xconfigure.height); + break; + case KeyPress: + { + char buf[100]; + KeySym keySym; + XComposeStatus stat; + XLookupString(&event.xkey, buf, sizeof(buf), &keySym, &stat); + switch (keySym) { + case XK_Escape: + exit(0); + break; + case XK_d: + case XK_D: + printf("Delete Texture in window %d\n", i); + glXMakeCurrent(h->Dpy, h->Win, h->Context); + glDeleteTextures(1, &TexObj); + break; + case XK_u: + case XK_U: + printf("Unbind Texture in window %d\n", i); + glXMakeCurrent(h->Dpy, h->Win, h->Context); + glBindTexture(GL_TEXTURE_2D, 0); + break; + } + } + break; + default: + /*no-op*/ ; + } + } + else { + printf("window mismatch\n"); + } + } + } + + /* redraw all windows */ + for (i = 0; i < NumHeads; i++) { + Redraw(&Heads[i]); + } + /* swapbuffers on all windows, if not already done */ + if (SwapSeparate) { + for (i = 0; i < NumHeads; i++) { + Swap(&Heads[i]); + } + } + usleep(1); + } +} + + + +static void +PrintInfo(const struct head *h) +{ + printf("Name: %s\n", h->DisplayName); + printf(" Display: %p\n", (void *) h->Dpy); + printf(" Window: 0x%x\n", (int) h->Win); + printf(" Context: 0x%lx\n", (long) 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[]) +{ + char *dpyName = NULL; + int i; + + if (argc == 1) { + printf("manywin: open N simultaneous glx windows\n"); + printf("Usage:\n"); + printf(" manywin [-s] numWindows\n"); + printf("Options:\n"); + printf(" -s = swap immediately after drawing (see src code)\n"); + printf("Example:\n"); + printf(" manywin 10\n"); + return 0; + } + else { + int n = 3; + for (i = 1; i < argc; i++) { + if (strcmp(argv[i], "-s") == 0) { + SwapSeparate = GL_FALSE; + } + else if (strcmp(argv[i], "-display") == 0 && i < argc) { + dpyName = argv[i+1]; + i++; + } + else { + n = atoi(argv[i]); + } + } + if (n < 1) + n = 1; + + printf("%d windows\n", n); + for (i = 0; i < n; i++) { + char name[100]; + struct head *h; + sprintf(name, "%d", i); + h = AddHead(dpyName, name); + if (h) { + PrintInfo(h); + } + } + } + + EventLoop(); + DestroyHeads(); + return 0; +} diff --git a/progs/xdemos/offset.c b/progs/xdemos/offset.c new file mode 100644 index 00000000000..3e92e68daa7 --- /dev/null +++ b/progs/xdemos/offset.c @@ -0,0 +1,323 @@ +/**************************************************************************** +Copyright 1995 by Silicon Graphics Incorporated, Mountain View, California. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of Silicon Graphics not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO +EVENT SHALL SILICON GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR +CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF +USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. + +****************************************************************************/ + +/* + * Derived from code written by Kurt Akeley, November 1992 + * + * Uses PolygonOffset to draw hidden-line images. PolygonOffset + * shifts the z values of polygons an amount that is + * proportional to their slope in screen z. This keeps + * the lines, which are drawn without displacement, from + * interacting with their respective polygons, and + * thus eliminates line dropouts. + * + * The left image shows an ordinary antialiased wireframe image. + * The center image shows an antialiased hidden-line image without + * PolygonOffset. + * The right image shows an antialiased hidden-line image using + * PolygonOffset to reduce artifacts. + * + * Drag with a mouse button pressed to rotate the models. + * Press the escape key to exit. + */ + +/* + * Modified for OpenGL 1.1 glPolygonOffset() conventions + */ + + +#include +#include +#include +#include +#include +#include + +#undef GL_EXT_polygon_offset /* use GL 1.1 version instead of extension */ + + +#ifndef EXIT_FAILURE +# define EXIT_FAILURE 1 +#endif +#ifndef EXIT_SUCCESS +# define EXIT_SUCCESS 0 +#endif + +#define MAXQUAD 6 + +typedef float Vertex[3]; + +typedef Vertex Quad[4]; + +/* data to define the six faces of a unit cube */ +Quad quads[MAXQUAD] = { + { {0,0,0}, {1,0,0}, {1,1,0}, {0,1,0} }, + { {0,0,1}, {1,0,1}, {1,1,1}, {0,1,1} }, + { {0,0,0}, {1,0,0}, {1,0,1}, {0,0,1} }, + { {0,1,0}, {1,1,0}, {1,1,1}, {0,1,1} }, + { {0,0,0}, {0,0,1}, {0,1,1}, {0,1,0} }, + { {1,0,0}, {1,0,1}, {1,1,1}, {1,1,0} } +}; + +#define WIREFRAME 0 +#define HIDDEN_LINE 1 + +static void error(const char* prog, const char* msg); +static void cubes(int mx, int my, int mode); +static void fill(Quad quad); +static void outline(Quad quad); +static void draw_hidden(Quad quad, int mode); +static void process_input(Display *dpy, Window win); +static int query_extension(char* extName); + +static int attributeList[] = { GLX_RGBA, GLX_RED_SIZE, 1, GLX_GREEN_SIZE, 1, + GLX_BLUE_SIZE, 1, GLX_DOUBLEBUFFER, GLX_DEPTH_SIZE, 1, None }; + +static int dimension = 3; + +int main(int argc, char** argv) { + Display *dpy; + XVisualInfo *vi; + XSetWindowAttributes swa; + Window win; + GLXContext cx; + + dpy = XOpenDisplay(0); + if (!dpy) error(argv[0], "can't open display"); + + vi = glXChooseVisual(dpy, DefaultScreen(dpy), attributeList); + if (!vi) error(argv[0], "no suitable visual"); + + cx = glXCreateContext(dpy, vi, 0, GL_TRUE); + + swa.colormap = XCreateColormap(dpy, RootWindow(dpy, vi->screen), + vi->visual, AllocNone); + + swa.border_pixel = 0; + swa.event_mask = ExposureMask | StructureNotifyMask | KeyPressMask | + ButtonPressMask | ButtonMotionMask; + win = XCreateWindow(dpy, RootWindow(dpy, vi->screen), 0, 0, 900, 300, + 0, vi->depth, InputOutput, vi->visual, + CWBorderPixel|CWColormap|CWEventMask, &swa); + XStoreName(dpy, win, "hiddenline"); + XMapWindow(dpy, win); + + glXMakeCurrent(dpy, win, cx); + + /* check for the polygon offset extension */ +#ifndef GL_VERSION_1_1 + if (!query_extension("GL_EXT_polygon_offset")) + error(argv[0], "polygon_offset extension is not available"); +#else + (void) query_extension; +#endif + + /* set up viewing parameters */ + glMatrixMode(GL_PROJECTION); + gluPerspective(20, 1, 0.1, 20); + glMatrixMode(GL_MODELVIEW); + glTranslatef(0, 0, -15); + + /* set other relevant state information */ + glEnable(GL_DEPTH_TEST); + +#ifdef GL_EXT_polygon_offset + printf("using 1.0 offset extension\n"); + glPolygonOffsetEXT( 1.0, 0.00001 ); +#else + printf("using 1.1 offset\n"); + glPolygonOffset( 1.0, 0.5 ); +#endif + + glShadeModel( GL_FLAT ); + glDisable( GL_DITHER ); + + /* process events until the user presses ESC */ + while (1) process_input(dpy, win); + + return 0; +} + +static void +draw_scene(int mx, int my) { + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + glPushMatrix(); + glTranslatef(-1.7, 0.0, 0.0); + cubes(mx, my, WIREFRAME); + glPopMatrix(); + + glPushMatrix(); + cubes(mx, my, HIDDEN_LINE); + glPopMatrix(); + + glPushMatrix(); + glTranslatef(1.7, 0.0, 0.0); +#ifdef GL_EXT_polygon_offset + glEnable(GL_POLYGON_OFFSET_EXT); +#else + glEnable(GL_POLYGON_OFFSET_FILL); +#endif + cubes(mx, my, HIDDEN_LINE); +#ifdef GL_EXT_polygon_offset + glDisable(GL_POLYGON_OFFSET_EXT); +#else + glDisable(GL_POLYGON_OFFSET_FILL); +#endif + glPopMatrix(); +} + + +static void +cubes(int mx, int my, int mode) { + int x, y, z, i; + + /* track the mouse */ + glRotatef(mx / 2.0, 0, 1, 0); + glRotatef(my / 2.0, 1, 0, 0); + + /* draw the lines as hidden polygons */ + glTranslatef(-0.5, -0.5, -0.5); + glScalef(1.0/dimension, 1.0/dimension, 1.0/dimension); + for (z = 0; z < dimension; z++) { + for (y = 0; y < dimension; y++) { + for (x = 0; x < dimension; x++) { + glPushMatrix(); + glTranslatef(x, y, z); + glScalef(0.8, 0.8, 0.8); + for (i = 0; i < MAXQUAD; i++) + draw_hidden(quads[i], mode); + glPopMatrix(); + } + } + } +} + +static void +fill(Quad quad) { + /* draw a filled polygon */ + glBegin(GL_QUADS); + glVertex3fv(quad[0]); + glVertex3fv(quad[1]); + glVertex3fv(quad[2]); + glVertex3fv(quad[3]); + glEnd(); +} + +static void +outline(Quad quad) { + /* draw an outlined polygon */ + glBegin(GL_LINE_LOOP); + glVertex3fv(quad[0]); + glVertex3fv(quad[1]); + glVertex3fv(quad[2]); + glVertex3fv(quad[3]); + glEnd(); +} + +static void +draw_hidden(Quad quad, int mode) { + if (mode == HIDDEN_LINE) { + glColor3f(0, 0, 0); + fill(quad); + } + + /* draw the outline using white, optionally fill the interior with black */ + glColor3f(1, 1, 1); + outline(quad); +} + +static void +process_input(Display *dpy, Window win) { + XEvent event; + static int prevx, prevy; + static int deltax = 90, deltay = 40; + + do { + char buf[31]; + KeySym keysym; + + XNextEvent(dpy, &event); + switch(event.type) { + case Expose: + break; + case ConfigureNotify: { + /* this approach preserves a 1:1 viewport aspect ratio */ + int vX, vY, vW, vH; + int eW = event.xconfigure.width, eH = event.xconfigure.height; + if (eW >= eH) { + vX = 0; + vY = (eH - eW) >> 1; + vW = vH = eW; + } else { + vX = (eW - eH) >> 1; + vY = 0; + vW = vH = eH; + } + glViewport(vX, vY, vW, vH); + } + break; + case KeyPress: + (void) XLookupString(&event.xkey, buf, sizeof(buf), &keysym, NULL); + switch (keysym) { + case XK_Escape: + exit(EXIT_SUCCESS); + default: + break; + } + case ButtonPress: + prevx = event.xbutton.x; + prevy = event.xbutton.y; + break; + case MotionNotify: + deltax += (event.xbutton.x - prevx); prevx = event.xbutton.x; + deltay += (event.xbutton.y - prevy); prevy = event.xbutton.y; + break; + default: + break; + } + } while (XPending(dpy)); + + draw_scene(deltax, deltay); + glXSwapBuffers(dpy, win); +} + +static void +error(const char *prog, const char *msg) { + fprintf(stderr, "%s: %s\n", prog, msg); + exit(EXIT_FAILURE); +} + +static int +query_extension(char* extName) { + char *p = (char *) glGetString(GL_EXTENSIONS); + char *end = p + strlen(p); + while (p < end) { + int n = strcspn(p, " "); + if ((strlen(extName) == n) && (strncmp(extName, p, n) == 0)) + return GL_TRUE; + p += (n + 1); + } + return GL_FALSE; +} + diff --git a/progs/xdemos/opencloseopen.c b/progs/xdemos/opencloseopen.c new file mode 100644 index 00000000000..2e4de24c71d --- /dev/null +++ b/progs/xdemos/opencloseopen.c @@ -0,0 +1,189 @@ +/* + * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. + * (C) Copyright IBM Corporation 2003 + * + * 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 +#include +#include +#include +#include +#include +#include + +/** \file opencloseopen.c + * Simple test for Mesa bug #508473. Create a window and rendering context. + * Draw a single frame. Close the window, destroy the context, and close + * the display. Re-open the display, create a new window and context. This + * should work, but, at least as of Mesa 5.1, it segfaults. See the bug + * report for more details. + * + * Most of the code here was lifed from various other Mesa xdemos. + */ + +static void +draw(void) +{ + glViewport(0, 0, 300, 300); + 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 */ + glLoadIdentity(); + glColor3f(0.3, 0.3, 1.0); + glPushMatrix(); + glRotatef(0, 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();} + + +/* + * Create an RGB, double-buffered window. + * Return the window and context handles. + */ +static void +make_window( const char * dpyName, const char *name, + int x, int y, int width, int height, + Display **dpyRet, Window *winRet, GLXContext *ctxRet) +{ + 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; + Window win; + GLXContext ctx; + XVisualInfo *visinfo; + Display *dpy; + + dpy = XOpenDisplay(dpyName); + if (!dpy) { + printf("Error: couldn't open display %s\n", dpyName); + exit(1); + } + + *dpyRet = dpy; + scrnum = DefaultScreen( dpy ); + root = RootWindow( dpy, scrnum ); + + visinfo = glXChooseVisual( dpy, scrnum, attrib ); + if (!visinfo) { + printf("Error: couldn't get an RGB, Double-buffered visual\n"); + exit(1); + } + + /* 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 ); + + /* set hints and properties */ + { + XSizeHints sizehints; + sizehints.x = x; + sizehints.y = y; + 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) { + printf("Error: glXCreateContext failed\n"); + exit(1); + } + + XFree(visinfo); + + *winRet = win; + *ctxRet = ctx; +} + + +static void +destroy_window( Display *dpy, Window win, GLXContext ctx ) +{ + glXMakeCurrent(dpy, None, NULL); + glXDestroyContext(dpy, ctx); + XDestroyWindow(dpy, win); + XCloseDisplay(dpy); +} + + +int +main(int argc, char *argv[]) +{ + Display *dpy; + Window win; + GLXContext ctx; + char *dpyName = ":0"; + int i; + + for (i = 1; i < argc; i++) { + if (strcmp(argv[i], "-display") == 0) { + dpyName = argv[i+1]; + i++; + } + } + + printf("If this program segfaults, then Mesa bug #508473 is probably " + "back.\n"); + make_window(dpyName, "Open-close-open", 0, 0, 300, 300, &dpy, &win, &ctx); + XMapWindow(dpy, win); + glXMakeCurrent(dpy, win, ctx); + + draw(); + glXSwapBuffers(dpy, win); + sleep(2); + + destroy_window(dpy, win, ctx); + + make_window(dpyName, "Open-close-open", 0, 0, 300, 300, &dpy, &win, &ctx); + XMapWindow(dpy, win); + glXMakeCurrent(dpy, win, ctx); + destroy_window(dpy, win, ctx); + + return 0; +} diff --git a/progs/xdemos/overlay.c b/progs/xdemos/overlay.c new file mode 100644 index 00000000000..4c425b64d46 --- /dev/null +++ b/progs/xdemos/overlay.c @@ -0,0 +1,245 @@ +/* + * GLX overlay test/demo. + * + * Brian Paul + * 18 July 2005 + */ + +#include +#include +#include +#include +#include +#include + +static int WinWidth = 300, WinHeight = 300; +static Window NormalWindow = 0; +static Window OverlayWindow = 0; +static GLXContext NormalContext = 0; +static GLXContext OverlayContext = 0; +static GLboolean RGBOverlay = GL_FALSE; +static GLfloat Angle = 0.0; + + +static void +RedrawNormal(Display *dpy) +{ + glXMakeCurrent(dpy, NormalWindow, NormalContext); + glViewport(0, 0, WinWidth, WinHeight); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0); + glMatrixMode(GL_MODELVIEW); + glClearColor(0.5, 0.5, 0.5, 1.0); + glClear(GL_COLOR_BUFFER_BIT); + glColor3f(1.0, 1.0, 0.0); + glPushMatrix(); + glRotatef(Angle, 0, 0, 1); + glRectf(-0.8, -0.8, 0.8, 0.8); + glPopMatrix(); + glXSwapBuffers(dpy, NormalWindow); +} + + +static void +RedrawOverlay(Display *dpy) +{ + glXMakeCurrent(dpy, OverlayWindow, OverlayContext); + glViewport(0, 0, WinWidth, WinHeight); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0); + glMatrixMode(GL_MODELVIEW); + glClear(GL_COLOR_BUFFER_BIT); + if (RGBOverlay) { + glColor3f(0.0, 1.0, 1.0); + } + else { + glIndexi(2); + } + glBegin(GL_LINES); + glVertex2f(-1, -1); + glVertex2f(1, 1); + glVertex2f(1, -1); + glVertex2f(-1, 1); + glEnd(); + glXSwapBuffers(dpy, OverlayWindow); +} + + +static Window +MakeWindow(Display *dpy, XVisualInfo *visinfo, Window parent, + unsigned int width, unsigned int height) +{ + int scrnum; + XSetWindowAttributes attr; + unsigned long mask; + Window root; + Window win; + + scrnum = DefaultScreen(dpy); + 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, parent, 0, 0, width, height, + 0, visinfo->depth, InputOutput, + visinfo->visual, mask, &attr); + return win; +} + + +static void +MakeNormalWindow(Display *dpy) +{ + int attrib[] = { GLX_RGBA, + GLX_RED_SIZE, 1, + GLX_GREEN_SIZE, 1, + GLX_BLUE_SIZE, 1, + GLX_DOUBLEBUFFER, + None }; + int scrnum; + Window root; + XVisualInfo *visinfo; + + scrnum = DefaultScreen(dpy); + root = RootWindow(dpy, scrnum); + + visinfo = glXChooseVisual(dpy, scrnum, attrib); + if (!visinfo) { + printf("Error: couldn't get an RGB, Double-buffered visual\n"); + exit(1); + } + + NormalWindow = MakeWindow(dpy, visinfo, root, WinWidth, WinHeight); + assert(NormalWindow); + + NormalContext = glXCreateContext(dpy, visinfo, NULL, True); + assert(NormalContext); +} + + +static void +MakeOverlayWindow(Display *dpy) +{ + int rgbAttribs[] = { + GLX_RGBA, + GLX_RED_SIZE, 1, + GLX_GREEN_SIZE, 1, + GLX_BLUE_SIZE, 1, + GLX_DOUBLEBUFFER, + GLX_LEVEL, 1, + None + }; + int indexAttribs[] = { + /*GLX_RGBA, leave this out */ + GLX_RED_SIZE, 1, + GLX_GREEN_SIZE, 1, + GLX_BLUE_SIZE, 1, + GLX_DOUBLEBUFFER, + GLX_LEVEL, 1, + None + }; + int scrnum; + Window root; + XVisualInfo *visinfo; + + scrnum = DefaultScreen(dpy); + root = RootWindow(dpy, scrnum); + + visinfo = glXChooseVisual(dpy, scrnum, rgbAttribs); + if (visinfo) { + printf("Found RGB overlay visual 0x%x\n", (int) visinfo->visualid); + RGBOverlay = GL_TRUE; + } + else { + visinfo = glXChooseVisual(dpy, scrnum, indexAttribs); + if (visinfo) { + printf("Found Color Index overlay visual 0x%x\n", + (int) visinfo->visualid); + /* XXX setup the colormap entries! */ + } + else { + printf("Error: couldn't get an overlay visual!\n"); + exit(1); + } + } + + OverlayWindow = MakeWindow(dpy, visinfo, NormalWindow, WinWidth, WinHeight); + assert(OverlayWindow); + + OverlayContext = glXCreateContext(dpy, visinfo, NULL, True); + assert(OverlayContext); +} + + +static void +EventLoop(Display *dpy) +{ + XEvent event; + + while (1) { + XNextEvent(dpy, &event); + + switch (event.type) { + case Expose: + RedrawNormal(dpy); + RedrawOverlay(dpy); + break; + case ConfigureNotify: + WinWidth = event.xconfigure.width; + WinHeight = event.xconfigure.height; + if (event.xconfigure.window == NormalWindow) + XResizeWindow(dpy, OverlayWindow, WinWidth, WinHeight); + break; + case KeyPress: + { + char buffer[10]; + int r, code; + code = XLookupKeysym(&event.xkey, 0); + r = XLookupString(&event.xkey, buffer, sizeof(buffer), + NULL, NULL); + if (buffer[0] == 27) { + /* escape */ + return; + } + else if (buffer[0] == ' ') { + Angle += 5.0; + RedrawNormal(dpy); + } + } + break; + default: + ; /* nothing */ + } + } +} + + +int +main(int argc, char *argv[]) +{ + Display *dpy = XOpenDisplay(NULL); + + assert(dpy); + + MakeNormalWindow(dpy); + MakeOverlayWindow(dpy); + + XMapWindow(dpy, NormalWindow); + XMapWindow(dpy, OverlayWindow); + + EventLoop(dpy); + + glXDestroyContext(dpy, OverlayContext); + glXDestroyContext(dpy, NormalContext); + XDestroyWindow(dpy, OverlayWindow); + XDestroyWindow(dpy, NormalWindow); + + return 0; +} diff --git a/progs/xdemos/pbdemo.c b/progs/xdemos/pbdemo.c new file mode 100644 index 00000000000..efdfdfa4522 --- /dev/null +++ b/progs/xdemos/pbdemo.c @@ -0,0 +1,478 @@ + +/* + * This program demonstrates how to do "off-screen" rendering using + * the GLX pixel buffer extension. + * + * Written by Brian Paul for the "OpenGL and Window System Integration" + * course presented at SIGGRAPH '97. Updated on 5 October 2002. + * + * Usage: + * pbuffers width height imgfile + * Where: + * width is the width, in pixels, of the image to generate. + * height is the height, in pixels, of the image to generate. + * imgfile is the name of the PPM image file to write. + * + * + * This demo draws 3-D boxes with random orientation. A pbuffer with + * a depth (Z) buffer is prefered but if such a pbuffer can't be created + * we use a non-depth-buffered config. + * + * On machines such as the SGI Indigo you may have to reconfigure your + * display/X server to enable pbuffers. Look in the /usr/gfx/ucode/MGRAS/vof/ + * directory for display configurationswith the _pbuf suffix. Use + * setmon -x to configure your X server and display for pbuffers. + * + * O2 systems seem to support pbuffers well. + * + * IR systems (at least 1RM systems) don't have single-buffered, RGBA, + * Z-buffered pbuffer configs. BUT, they DO have DOUBLE-buffered, RGBA, + * Z-buffered pbuffers. Note how we try four different fbconfig attribute + * lists below! + */ + + +#include +#include +#include +#include +#include +#include "pbutil.h" + + +/* Some ugly global vars */ +static Display *gDpy = NULL; +static int gScreen = 0; +static FBCONFIG gFBconfig = 0; +static PBUFFER gPBuffer = 0; +static int gWidth, gHeight; +static GLXContext glCtx; + + + +/* + * Create the pbuffer and return a GLXPbuffer handle. + * + * We loop over a list of fbconfigs trying to create + * a pixel buffer. We return the first pixel buffer which we successfully + * create. + */ +static PBUFFER +MakePbuffer( Display *dpy, int screen, int width, int height ) +{ +#define NUM_FB_CONFIGS 4 + const char fbString[NUM_FB_CONFIGS][100] = { + "Single Buffered, depth buffer", + "Double Buffered, depth buffer", + "Single Buffered, no depth buffer", + "Double Buffered, no depth buffer" + }; + int fbAttribs[NUM_FB_CONFIGS][100] = { + { + /* Single buffered, with depth buffer */ + GLX_RENDER_TYPE, GLX_RGBA_BIT, + GLX_DRAWABLE_TYPE, GLX_PBUFFER_BIT, + GLX_RED_SIZE, 1, + GLX_GREEN_SIZE, 1, + GLX_BLUE_SIZE, 1, + GLX_DEPTH_SIZE, 1, + GLX_DOUBLEBUFFER, 0, + GLX_STENCIL_SIZE, 0, + None + }, + { + /* Double buffered, with depth buffer */ + GLX_RENDER_TYPE, GLX_RGBA_BIT, + GLX_DRAWABLE_TYPE, GLX_PBUFFER_BIT, + GLX_RED_SIZE, 1, + GLX_GREEN_SIZE, 1, + GLX_BLUE_SIZE, 1, + GLX_DEPTH_SIZE, 1, + GLX_DOUBLEBUFFER, 1, + GLX_STENCIL_SIZE, 0, + None + }, + { + /* Single bufferd, without depth buffer */ + GLX_RENDER_TYPE, GLX_RGBA_BIT, + GLX_DRAWABLE_TYPE, GLX_PBUFFER_BIT, + GLX_RED_SIZE, 1, + GLX_GREEN_SIZE, 1, + GLX_BLUE_SIZE, 1, + GLX_DEPTH_SIZE, 0, + GLX_DOUBLEBUFFER, 0, + GLX_STENCIL_SIZE, 0, + None + }, + { + /* Double bufferd, without depth buffer */ + GLX_RENDER_TYPE, GLX_RGBA_BIT, + GLX_DRAWABLE_TYPE, GLX_PBUFFER_BIT, + GLX_RED_SIZE, 1, + GLX_GREEN_SIZE, 1, + GLX_BLUE_SIZE, 1, + GLX_DEPTH_SIZE, 0, + GLX_DOUBLEBUFFER, 1, + GLX_STENCIL_SIZE, 0, + None + } + }; + Bool largest = True; + Bool preserve = False; + FBCONFIG *fbConfigs; + PBUFFER pBuffer = None; + int nConfigs; + int i; + int attempt; + + for (attempt=0; attempt x1) { + tmp = x0; + x0 = x1; + x1 = tmp; + } + if (y0 > y1) { + tmp = y0; + y0 = y1; + y1 = tmp; + } + if (z0 > z1) { + tmp = z0; + z0 = z1; + z1 = tmp; + } + v[0][0] = v[1][0] = v[2][0] = v[3][0] = x0; + v[4][0] = v[5][0] = v[6][0] = v[7][0] = x1; + v[0][1] = v[1][1] = v[4][1] = v[5][1] = y0; + v[2][1] = v[3][1] = v[6][1] = v[7][1] = y1; + v[0][2] = v[3][2] = v[4][2] = v[7][2] = z0; + v[1][2] = v[2][2] = v[5][2] = v[6][2] = z1; + + for (i = 0; i < 6; i++) { + glBegin(type); + glNormal3fv(&n[i][0]); + glVertex3fv(&v[faces[i][0]][0]); + glVertex3fv(&v[faces[i][1]][0]); + glVertex3fv(&v[faces[i][2]][0]); + glVertex3fv(&v[faces[i][3]][0]); + glEnd(); + } +} + + + +/* Render a scene */ +static void +Render(void) +{ + int NumBoxes = 100; + int i; + + glClearColor(0.2, 0.2, 0.9, 0.0); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + for (i=0;i +#include +#include +#include "pbutil.h" + + + + +static void +PrintConfigs(Display *dpy, int screen, Bool horizFormat) +{ + FBCONFIG *fbConfigs; + int nConfigs; + int i; + + fbConfigs = GetAllFBConfigs(dpy, screen, &nConfigs); + if (!nConfigs || !fbConfigs) { + printf("Error: glxGetFBConfigs failed\n"); + return; + } + + printf("Number of fbconfigs: %d\n", nConfigs); + + if (horizFormat) { + printf(" ID VisualType Depth Lvl RGB CI DB Stereo R G B A"); + printf(" Z S AR AG AB AA MSbufs MSnum Pbuffer Float\n"); + } + + /* Print config info */ + for (i = 0; i < nConfigs; i++) { + PrintFBConfigInfo(dpy, screen, fbConfigs[i], horizFormat); + } + + /* free the list */ + XFree(fbConfigs); +} + + + +static void +PrintUsage(void) +{ + printf("Options:\n"); + printf(" -display specify X display name\n"); + printf(" -t print in tabular format\n"); + printf(" -v print in verbose format\n"); + printf(" -help print this information\n"); +} + + +int +main(int argc, char *argv[]) +{ + Display *dpy; + int scrn; + char *dpyName = NULL; + Bool horizFormat = True; + int i; + + for (i=1; i +#include +#include "pbutil.h" + + +/** + * Test if we pixel buffers are available for a particular X screen. + * Input: dpy - the X display + * screen - screen number + * Return: 0 = pixel buffers not available. + * 1 = pixel buffers are available via GLX 1.3. + * 2 = pixel buffers are available via GLX_SGIX_fbconfig/pbuffer. + */ +int +QueryPbuffers(Display *dpy, int screen) +{ +#if defined(GLX_VERSION_1_3) + { + /* GLX 1.3 supports pbuffers */ + int glxVersionMajor, glxVersionMinor; + if (!glXQueryVersion(dpy, &glxVersionMajor, &glxVersionMinor)) { + /* GLX not available! */ + return 0; + } + if (glxVersionMajor * 100 + glxVersionMinor >= 103) { + return 1; + } + /* fall-through */ + } +#endif + +#if defined(GLX_SGIX_fbconfig) && defined(GLX_SGIX_pbuffer) + /* Try the SGIX extensions */ + { + char *extensions; + extensions = (char *) glXQueryServerString(dpy, screen, GLX_EXTENSIONS); + if (!extensions || + !strstr(extensions,"GLX_SGIX_fbconfig") || + !strstr(extensions,"GLX_SGIX_pbuffer")) { + return 0; + } + return 2; + } +#endif + + return 0; +} + + + +FBCONFIG * +ChooseFBConfig(Display *dpy, int screen, const int attribs[], int *nConfigs) +{ + int pbSupport = QueryPbuffers(dpy, screen); +#if defined(GLX_VERSION_1_3) + if (pbSupport == 1) { + return glXChooseFBConfig(dpy, screen, attribs, nConfigs); + } +#endif +#if defined(GLX_SGIX_fbconfig) && defined(GLX_SGIX_pbuffer) + if (pbSupport == 2) { + return glXChooseFBConfigSGIX(dpy, screen, (int *) attribs, nConfigs); + } +#endif + return NULL; +} + + +FBCONFIG * +GetAllFBConfigs(Display *dpy, int screen, int *nConfigs) +{ + int pbSupport = QueryPbuffers(dpy, screen); +#if defined(GLX_VERSION_1_3) + if (pbSupport == 1) { + return glXGetFBConfigs(dpy, screen, nConfigs); + } +#endif +#if defined(GLX_SGIX_fbconfig) && defined(GLX_SGIX_pbuffer) + if (pbSupport == 2) { + /* The GLX_SGIX_fbconfig extensions says to pass NULL to get list + * of all available configurations. + */ + return glXChooseFBConfigSGIX(dpy, screen, NULL, nConfigs); + } +#endif + return NULL; +} + + +XVisualInfo * +GetVisualFromFBConfig(Display *dpy, int screen, FBCONFIG config) +{ + int pbSupport = QueryPbuffers(dpy, screen); +#if defined(GLX_VERSION_1_3) + if (pbSupport == 1) { + return glXGetVisualFromFBConfig(dpy, config); + } +#endif +#if defined(GLX_SGIX_fbconfig) && defined(GLX_SGIX_pbuffer) + if (pbSupport == 2) { + return glXGetVisualFromFBConfigSGIX(dpy, config); + } +#endif + return NULL; +} + + +/** + * Either use glXGetFBConfigAttrib() or glXGetFBConfigAttribSGIX() + * to query an fbconfig attribute. + */ +static int +GetFBConfigAttrib(Display *dpy, int screen, +#if defined(GLX_VERSION_1_3) + const GLXFBConfig config, +#elif defined(GLX_SGIX_fbconfig) + const GLXFBConfigSGIX config, +#endif + int attrib + ) +{ + int pbSupport = QueryPbuffers(dpy, screen); + int value = 0; + +#if defined(GLX_VERSION_1_3) + if (pbSupport == 1) { + /* ok */ + if (glXGetFBConfigAttrib(dpy, config, attrib, &value) != 0) { + value = 0; + } + return value; + } + /* fall-through */ +#endif + +#if defined(GLX_SGIX_fbconfig) && defined(GLX_SGIX_pbuffer) + if (pbSupport == 2) { + if (glXGetFBConfigAttribSGIX(dpy, config, attrib, &value) != 0) { + value = 0; + } + return value; + } +#endif + + return value; +} + + + +/** + * Print parameters for a GLXFBConfig to stdout. + * Input: dpy - the X display + * screen - the X screen number + * fbConfig - the fbconfig handle + * horizFormat - if true, print in horizontal format + */ +void +PrintFBConfigInfo(Display *dpy, int screen, FBCONFIG config, Bool horizFormat) +{ + PBUFFER pBuffer; + int width=2, height=2; + int bufferSize, level, doubleBuffer, stereo, auxBuffers; + int redSize, greenSize, blueSize, alphaSize; + int depthSize, stencilSize; + int accumRedSize, accumBlueSize, accumGreenSize, accumAlphaSize; + int sampleBuffers, samples; + int drawableType, renderType, xRenderable, xVisual, id; + int maxWidth, maxHeight, maxPixels; + int optWidth, optHeight; + int floatComponents = 0; + + /* do queries using the GLX 1.3 tokens (same as the SGIX tokens) */ + bufferSize = GetFBConfigAttrib(dpy, screen, config, GLX_BUFFER_SIZE); + level = GetFBConfigAttrib(dpy, screen, config, GLX_LEVEL); + doubleBuffer = GetFBConfigAttrib(dpy, screen, config, GLX_DOUBLEBUFFER); + stereo = GetFBConfigAttrib(dpy, screen, config, GLX_STEREO); + auxBuffers = GetFBConfigAttrib(dpy, screen, config, GLX_AUX_BUFFERS); + redSize = GetFBConfigAttrib(dpy, screen, config, GLX_RED_SIZE); + greenSize = GetFBConfigAttrib(dpy, screen, config, GLX_GREEN_SIZE); + blueSize = GetFBConfigAttrib(dpy, screen, config, GLX_BLUE_SIZE); + alphaSize = GetFBConfigAttrib(dpy, screen, config, GLX_ALPHA_SIZE); + depthSize = GetFBConfigAttrib(dpy, screen, config, GLX_DEPTH_SIZE); + stencilSize = GetFBConfigAttrib(dpy, screen, config, GLX_STENCIL_SIZE); + accumRedSize = GetFBConfigAttrib(dpy, screen, config, GLX_ACCUM_RED_SIZE); + accumGreenSize = GetFBConfigAttrib(dpy, screen, config, GLX_ACCUM_GREEN_SIZE); + accumBlueSize = GetFBConfigAttrib(dpy, screen, config, GLX_ACCUM_BLUE_SIZE); + accumAlphaSize = GetFBConfigAttrib(dpy, screen, config, GLX_ACCUM_ALPHA_SIZE); + sampleBuffers = GetFBConfigAttrib(dpy, screen, config, GLX_SAMPLE_BUFFERS); + samples = GetFBConfigAttrib(dpy, screen, config, GLX_SAMPLES); + drawableType = GetFBConfigAttrib(dpy, screen, config, GLX_DRAWABLE_TYPE); + renderType = GetFBConfigAttrib(dpy, screen, config, GLX_RENDER_TYPE); + xRenderable = GetFBConfigAttrib(dpy, screen, config, GLX_X_RENDERABLE); + xVisual = GetFBConfigAttrib(dpy, screen, config, GLX_X_VISUAL_TYPE); + if (!xRenderable || !(drawableType & GLX_WINDOW_BIT_SGIX)) + xVisual = -1; + + id = GetFBConfigAttrib(dpy, screen, config, GLX_FBCONFIG_ID); + maxWidth = GetFBConfigAttrib(dpy, screen, config, GLX_MAX_PBUFFER_WIDTH); + maxHeight = GetFBConfigAttrib(dpy, screen, config, GLX_MAX_PBUFFER_HEIGHT); + maxPixels = GetFBConfigAttrib(dpy, screen, config, GLX_MAX_PBUFFER_PIXELS); +#if defined(GLX_SGIX_pbuffer) + optWidth = GetFBConfigAttrib(dpy, screen, config, GLX_OPTIMAL_PBUFFER_WIDTH_SGIX); + optHeight = GetFBConfigAttrib(dpy, screen, config, GLX_OPTIMAL_PBUFFER_HEIGHT_SGIX); +#else + optWidth = optHeight = 0; +#endif +#if defined(GLX_NV_float_buffer) + floatComponents = GetFBConfigAttrib(dpy, screen, config, GLX_FLOAT_COMPONENTS_NV); +#endif + + /* See if we can create a pbuffer with this config */ + pBuffer = CreatePbuffer(dpy, screen, config, width, height, False, False); + + if (horizFormat) { + printf("0x%-9x ", id); + if (xVisual==GLX_STATIC_GRAY) printf("StaticGray "); + else if (xVisual==GLX_GRAY_SCALE) printf("GrayScale "); + else if (xVisual==GLX_STATIC_COLOR) printf("StaticColor "); + else if (xVisual==GLX_PSEUDO_COLOR) printf("PseudoColor "); + else if (xVisual==GLX_TRUE_COLOR) printf("TrueColor "); + else if (xVisual==GLX_DIRECT_COLOR) printf("DirectColor "); + else printf(" -none- "); + printf(" %3d %3d %s %s %s %2s ", bufferSize, level, + (renderType & GLX_RGBA_BIT_SGIX) ? "y" : ".", + (renderType & GLX_COLOR_INDEX_BIT_SGIX) ? "y" : ".", + doubleBuffer ? "y" : ".", + stereo ? "y" : "."); + printf("%2d %2d %2d %2d ", redSize, greenSize, blueSize, alphaSize); + printf("%2d %2d ", depthSize, stencilSize); + printf("%2d %2d %2d %2d", accumRedSize, accumGreenSize, accumBlueSize, + accumAlphaSize); + printf(" %2d %2d", sampleBuffers, samples); + printf(" %s %c", pBuffer ? "y" : ".", + ".y"[floatComponents]); + printf("\n"); + } + else { + printf("Id 0x%x\n", id); + printf(" Buffer Size: %d\n", bufferSize); + printf(" Level: %d\n", level); + printf(" Double Buffer: %s\n", doubleBuffer ? "yes" : "no"); + printf(" Stereo: %s\n", stereo ? "yes" : "no"); + printf(" Aux Buffers: %d\n", auxBuffers); + printf(" Red Size: %d\n", redSize); + printf(" Green Size: %d\n", greenSize); + printf(" Blue Size: %d\n", blueSize); + printf(" Alpha Size: %d\n", alphaSize); + printf(" Depth Size: %d\n", depthSize); + printf(" Stencil Size: %d\n", stencilSize); + printf(" Accum Red Size: %d\n", accumRedSize); + printf(" Accum Green Size: %d\n", accumGreenSize); + printf(" Accum Blue Size: %d\n", accumBlueSize); + printf(" Accum Alpha Size: %d\n", accumAlphaSize); + printf(" Sample Buffers: %d\n", sampleBuffers); + printf(" Samples/Pixel: %d\n", samples); + printf(" Drawable Types: "); + if (drawableType & GLX_WINDOW_BIT) printf("Window "); + if (drawableType & GLX_PIXMAP_BIT) printf("Pixmap "); + if (drawableType & GLX_PBUFFER_BIT) printf("PBuffer"); + printf("\n"); + printf(" Render Types: "); + if (renderType & GLX_RGBA_BIT_SGIX) printf("RGBA "); + if (renderType & GLX_COLOR_INDEX_BIT_SGIX) printf("CI "); + printf("\n"); + printf(" X Renderable: %s\n", xRenderable ? "yes" : "no"); + + printf(" Pbuffer: %s\n", pBuffer ? "yes" : "no"); + printf(" Max Pbuffer width: %d\n", maxWidth); + printf(" Max Pbuffer height: %d\n", maxHeight); + printf(" Max Pbuffer pixels: %d\n", maxPixels); + printf(" Optimum Pbuffer width: %d\n", optWidth); + printf(" Optimum Pbuffer height: %d\n", optHeight); + + printf(" Float Components: %s\n", floatComponents ? "yes" : "no"); + } + + if (pBuffer) { + DestroyPbuffer(dpy, screen, pBuffer); + } +} + + + +GLXContext +CreateContext(Display *dpy, int screen, FBCONFIG config) +{ + int pbSupport = QueryPbuffers(dpy, screen); +#if defined(GLX_VERSION_1_3) + if (pbSupport == 1) { + /* GLX 1.3 */ + GLXContext c; + c = glXCreateNewContext(dpy, config, GLX_RGBA_TYPE, NULL, True); + if (!c) { + /* try indirect */ + c = glXCreateNewContext(dpy, config, GLX_RGBA_TYPE, NULL, False); + } + return c; + } +#endif +#if defined(GLX_SGIX_fbconfig) && defined(GLX_SGIX_pbuffer) + if (pbSupport == 2) { + GLXContext c; + c = glXCreateContextWithConfigSGIX(dpy, config, GLX_RGBA_TYPE_SGIX, NULL, True); + if (!c) { + c = glXCreateContextWithConfigSGIX(dpy, config, GLX_RGBA_TYPE_SGIX, NULL, False); + } + return c; + } +#endif + return 0; +} + + +void +DestroyContext(Display *dpy, GLXContext ctx) +{ + glXDestroyContext(dpy, ctx); +} + + +/* This is only used by CreatePbuffer() */ +static int XErrorFlag = 0; +static int HandleXError(Display *dpy, XErrorEvent *event) +{ + XErrorFlag = 1; + return 0; +} + + +/** + * Create a Pbuffer. Use an X error handler to deal with potential + * BadAlloc errors. + * + * Input: dpy - the X display + * fbConfig - an FBConfig as returned by glXChooseFBConfigSGIX(). + * width, height - size of pixel buffer to request, in pixels. + * pbAttribs - list of optional pixel buffer attributes + * Return: a Pbuffer or None. + */ +PBUFFER +CreatePbuffer(Display *dpy, int screen, FBCONFIG config, + int width, int height, Bool largest, Bool preserve) +{ + int (*oldHandler)(Display *, XErrorEvent *); + PBUFFER pBuffer = None; + int pbSupport = QueryPbuffers(dpy, screen); + + /* Catch X protocol errors with our own error handler */ + oldHandler = XSetErrorHandler(HandleXError); + XErrorFlag = 0; + +#if defined(GLX_VERSION_1_3) + if (pbSupport == 1) { + /* GLX 1.3 */ + int attribs[100], i = 0; + attribs[i++] = GLX_PBUFFER_WIDTH; + attribs[i++] = width; + attribs[i++] = GLX_PBUFFER_HEIGHT; + attribs[i++] = height; + attribs[i++] = GLX_PRESERVED_CONTENTS; + attribs[i++] = preserve; + attribs[i++] = GLX_LARGEST_PBUFFER; + attribs[i++] = largest; + attribs[i++] = 0; + pBuffer = glXCreatePbuffer(dpy, config, attribs); + } + else +#endif +#if defined(GLX_SGIX_fbconfig) && defined(GLX_SGIX_pbuffer) + if (pbSupport == 2) { + int attribs[100], i = 0; + attribs[i++] = GLX_PRESERVED_CONTENTS; + attribs[i++] = preserve; + attribs[i++] = GLX_LARGEST_PBUFFER; + attribs[i++] = largest; + attribs[i++] = 0; + pBuffer = glXCreateGLXPbufferSGIX(dpy, config, width, height, attribs); + } + else +#endif + { + pBuffer = None; + } + + /* Restore original X error handler */ + (void) XSetErrorHandler(oldHandler); + + /* Return pbuffer (may be None) */ + if (!XErrorFlag && pBuffer != None) { + /*printf("config %d worked!\n", i);*/ + return pBuffer; + } + else { + return None; + } +} + + +void +DestroyPbuffer(Display *dpy, int screen, PBUFFER pbuffer) +{ + int pbSupport = QueryPbuffers(dpy, screen); +#if defined(GLX_VERSION_1_3) + if (pbSupport == 1) { + glXDestroyPbuffer(dpy, pbuffer); + return; + } +#endif +#if defined(GLX_SGIX_fbconfig) && defined(GLX_SGIX_pbuffer) + if (pbSupport == 2) { + glXDestroyGLXPbufferSGIX(dpy, pbuffer); + return; + } +#endif +} diff --git a/progs/xdemos/pbutil.h b/progs/xdemos/pbutil.h new file mode 100644 index 00000000000..e95b2565a23 --- /dev/null +++ b/progs/xdemos/pbutil.h @@ -0,0 +1,66 @@ +/* + * OpenGL pbuffers utility functions. + * + * Brian Paul + * April 1997 + */ + + +#ifndef PBUTIL_H +#define PBUTIL_H + + +#define GLX_GLXEXT_PROTOTYPES +#include + + +#if defined(GLX_VERSION_1_3) +#define PBUFFER GLXPbuffer +#define FBCONFIG GLXFBConfig +#elif defined(GLX_SGIX_fbconfig) && defined(GLX_SGIX_pbuffer) +#define PBUFFER GLXPbufferSGIX +#define FBCONFIG GLXFBConfigSGIX +#else +#define PBUFFER int +#define FBCONFIG int +#endif + + +extern int +QueryPbuffers(Display *dpy, int screen); + + +extern void +PrintFBConfigInfo(Display *dpy, int screen, FBCONFIG config, Bool horizFormat); + + +extern FBCONFIG * +ChooseFBConfig(Display *dpy, int screen, const int attribs[], int *nConfigs); + + +extern FBCONFIG * +GetAllFBConfigs(Display *dpy, int screen, int *nConfigs); + + +extern XVisualInfo * +GetVisualFromFBConfig(Display *dpy, int screen, FBCONFIG config); + + +extern GLXContext +CreateContext(Display *dpy, int screen, FBCONFIG config); + + +extern void +DestroyContext(Display *dpy, GLXContext ctx); + + +extern PBUFFER +CreatePbuffer(Display *dpy, int screen, FBCONFIG config, + int width, int height, Bool preserve, Bool largest); + + +extern void +DestroyPbuffer(Display *dpy, int screen, PBUFFER pbuffer); + + +#endif /*PBUTIL_H*/ diff --git a/progs/xdemos/shape.c b/progs/xdemos/shape.c new file mode 100644 index 00000000000..dbbc0b4ff72 --- /dev/null +++ b/progs/xdemos/shape.c @@ -0,0 +1,394 @@ + +/* + * Example of using the X "shape" extension with OpenGL: render a spinning + * cube inside of a non-rectangular window. + * + * Press ESC to exit. Press up/down to change window shape. + * + * To compile add "shape" to the PROGS list in Makefile. + * + * Brian Paul + * June 16, 1997 + * + * This program is in the public domain. + */ + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifndef PI +#define PI 3.1415926 +#endif + + +static int Width=500, Height=500; + +static float Xangle = 0.0, Yangle = 0.0; +static int Redraw = 0; +static int Sides = 5; +static int MinSides = 3; +static int MaxSides = 20; + + +/* return current time (in seconds) */ +static double +current_time(void) +{ + struct timeval tv; +#ifdef __VMS + (void) gettimeofday(&tv, NULL ); +#else + struct timezone tz; + (void) gettimeofday(&tv, &tz); +#endif + return (double) tv.tv_sec + tv.tv_usec / 1000000.0; +} + + +/* + * Draw the OpenGL stuff and do a SwapBuffers. + */ +static void display(Display *dpy, Window win) +{ + float scale = 1.7; + + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + glPushMatrix(); + + glScalef(scale, scale, scale); + 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); + glVertex3f( 1.0, -1.0, -1.0); + glVertex3f( 1.0, 1.0, -1.0); + glVertex3f(-1.0, 1.0, -1.0); + glEnd(); + + glBegin(GL_LINE_LOOP); + glVertex3f(-1.0, -1.0, 1.0); + glVertex3f( 1.0, -1.0, 1.0); + glVertex3f( 1.0, 1.0, 1.0); + glVertex3f(-1.0, 1.0, 1.0); + glEnd(); + + glBegin(GL_LINES); + glVertex3f(-1.0, -1.0, -1.0); glVertex3f(-1.0, -1.0, 1.0); + glVertex3f( 1.0, -1.0, -1.0); glVertex3f( 1.0, -1.0, 1.0); + glVertex3f( 1.0, 1.0, -1.0); glVertex3f( 1.0, 1.0, 1.0); + 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); +} + + +/* + * This is called when we have to recompute the window shape bitmask. + * We just generate an n-sided regular polygon here but any other shape + * would be possible. + */ +static void make_shape_mask(Display *dpy, Window win, int width, int height, + int sides) +{ + Pixmap shapeMask; + XGCValues xgcv; + GC gc; + + /* allocate 1-bit deep pixmap and a GC */ + shapeMask = XCreatePixmap(dpy, win, width, height, 1); + gc = XCreateGC(dpy, shapeMask, 0, &xgcv); + + /* clear shapeMask to zeros */ + XSetForeground(dpy, gc, 0); + XFillRectangle(dpy, shapeMask, gc, 0, 0, width, height); + + /* draw mask */ + XSetForeground(dpy, gc, 1); + { + int cx = width / 2; + int cy = height / 2; + float angle = 0.0; + float step = 2.0 * PI / sides; + float radius = width / 2; + int i; + XPoint points[100]; + for (i=0;iMaxSides) Sides = MaxSides; + make_shape_mask(dpy, win, Width, Height, Sides); + break; + case XK_Down: + Sides--; + if (Sidesvisual); + if (!cmap) { + fprintf(stderr, "Couln't create colormap\n"); + return 1; + } + + winAttribs.border_pixel = 0; + winAttribs.colormap = cmap; + winAttribs.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask; + winAttribsMask = CWBorderPixel | CWColormap | CWEventMask; + win = XCreateWindow(dpy, root, 0, 0, Width, Height, 0, + 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"); + + event_loop(dpy, win); + + return 0; +} diff --git a/progs/xdemos/vgears.c b/progs/xdemos/vgears.c new file mode 100644 index 00000000000..13d030a8bef --- /dev/null +++ b/progs/xdemos/vgears.c @@ -0,0 +1,282 @@ +/* $ID$ */ + +/* + * Spinning gears demo for Linux SVGA/Mesa interface in 32K color mode. + * + * Compile with: gcc vgears.c -I../include -L../lib -lMesaGL -lX11 -lXext + * -lvga -lm -o vgears + * + * This program is in the public domain. + * Brian Paul, January 1996 + */ + + +#include +#include +#include "GL/svgamesa.h" +#include "GL/gl.h" + + +int width = 800, height = 600; + +SVGAMesaContext vmc; + + + +/* + * Draw a gear wheel. You'll probably want to call this function when + * building a display list since we do a lot of trig here. + * + * Input: inner_radius - radius of hole at center + * outer_radius - radius at center of teeth + * width - width of gear + * teeth - number of teeth + * tooth_depth - depth of tooth + */ +static void gear( GLfloat inner_radius, GLfloat outer_radius, GLfloat width, + GLint teeth, GLfloat tooth_depth ) +{ + GLint i; + GLfloat r0, r1, r2; + GLfloat angle, da; + GLfloat u, v, len; + + r0 = inner_radius; + r1 = outer_radius - tooth_depth/2.0; + r2 = outer_radius + tooth_depth/2.0; + + da = 2.0*M_PI / teeth / 4.0; + + glShadeModel( GL_FLAT ); + + glNormal3f( 0.0, 0.0, 1.0 ); + + /* draw front face */ + glBegin( GL_QUAD_STRIP ); + for (i=0;i<=teeth;i++) { + angle = i * 2.0*M_PI / teeth; + glVertex3f( r0*cos(angle), r0*sin(angle), width*0.5 ); + glVertex3f( r1*cos(angle), r1*sin(angle), width*0.5 ); + glVertex3f( r0*cos(angle), r0*sin(angle), width*0.5 ); + glVertex3f( r1*cos(angle+3*da), r1*sin(angle+3*da), width*0.5 ); + } + glEnd(); + + /* draw front sides of teeth */ + glBegin( GL_QUADS ); + da = 2.0*M_PI / teeth / 4.0; + for (i=0;iheight) { + GLfloat w = (GLfloat) width / (GLfloat) height; + glFrustum( -w, w, -1.0, 1.0, 5.0, 60.0 ); + } + else { + GLfloat h = (GLfloat) height / (GLfloat) width; + glFrustum( -1.0, 1.0, -h, h, 5.0, 60.0 ); + } + + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTranslatef( 0.0, 0.0, -40.0 ); +} + +void setup( void ) +{ + vga_init(); + + vga_setmode(G800x600x32K); +/* gl_setcontextvga(G800x600x32K);*/ + + vmc = SVGAMesaCreateContext(GL_TRUE); + SVGAMesaMakeCurrent( vmc ); +} + + +void end( void ) +{ + SVGAMesaDestroyContext( vmc ); + + vga_setmode( TEXT ); +} + + +int main( int argc, char *argv[] ) +{ + int i; + + setup(); + init(); + for (i=0;i<4;i++) { + draw(); /*SVGAMesaSwapBuffers();*/ + } + end(); + return 0; +} diff --git a/progs/xdemos/vindex.c b/progs/xdemos/vindex.c new file mode 100644 index 00000000000..991fce2a591 --- /dev/null +++ b/progs/xdemos/vindex.c @@ -0,0 +1,65 @@ + +/* + * Test Linux 8-bit SVGA/Mesa color index mode + * + * Compile with: gcc vindex.c -I../include -L../lib -lMesaGL -lX11 -lXext + * -lvga -lm -o vindex + * + * This program is in the public domain. + * Brian Paul, January 1996 + */ + + + +#include +#include "GL/svgamesa.h" +#include "GL/gl.h" + + + +static GLint width = 640, height = 480; + + + +static void display( void ) +{ + int i, j; + int w, h; + + glViewport( 0, 0, width, height ); + glMatrixMode( GL_PROJECTION ); + glLoadIdentity(); + glOrtho( 0.0, (GLfloat) width, 0.0, (GLfloat) height, -1.0, 1.0 ); + + glClear( GL_COLOR_BUFFER_BIT ); + + w = width / 16; + h = height / 16; + for (i=0;i<16;i++) { + for (j=0;j<16;j++) { + glIndexi( i*16+j ); + glRecti( i*w, j*h, i*w+w, j*h+h ); + } + } +} + + + +int main( int argc, char *argv[] ) +{ + SVGAMesaContext vmc; + int i; + + vga_init(); + vga_setmode( G640x480x256 ); + + vmc = SVGAMesaCreateContext( GL_FALSE ); + SVGAMesaMakeCurrent( vmc ); + + display(); + sleep(3); + + SVGAMesaDestroyContext( vmc ); + vga_setmode( TEXT ); + return 0; +} diff --git a/progs/xdemos/vtest.c b/progs/xdemos/vtest.c new file mode 100644 index 00000000000..e322fbc5c80 --- /dev/null +++ b/progs/xdemos/vtest.c @@ -0,0 +1,82 @@ + +/* + * Test SVGA/Mesa interface in 32K color mode. + * + * Compile with: gcc vtest.c -I../include -L../lib -lMesaGL -lX11 -lXext + * -lvga -lm -o vtest + * + * This program is in the public domain. + * Brian Paul, January 1996 + */ + + + +#include +#include "GL/svgamesa.h" +#include "GL/gl.h" + + +SVGAMesaContext vmc; + + + +void setup( void ) +{ + vga_init(); + + vga_setmode(G800x600x32K); +/* gl_setcontextvga(G800x600x32K);*/ + + vmc = SVGAMesaCreateContext( GL_FALSE ); /* single buffered */ + SVGAMesaMakeCurrent( vmc ); +} + + +void test( void ) +{ + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho( -1.0, 1.0, -1.0, 1.0, -1.0, 1.0 ); + glMatrixMode(GL_MODELVIEW); + + glClear( GL_COLOR_BUFFER_BIT ); + + glBegin( GL_LINES ); + glColor3f( 1.0, 0.0, 0.0 ); + glVertex2f( -0.5, 0.5 ); + glVertex2f( 0.5, 0.5 ); + glColor3f( 0.0, 1.0, 0.0 ); + glVertex2f( -0.5, 0.25 ); + glVertex2f( 0.5, 0.25 ); + glColor3f( 0.0, 0.0, 1.0 ); + glVertex2f( -0.5, 0.0 ); + glVertex2f( 0.5, 0.0 ); + glEnd(); + + glBegin( GL_POLYGON ); + glColor3f( 1.0, 0.0, 0.0 ); + glVertex2f( 0.0, 0.7 ); + glColor3f( 0.0, 1.0, 0.0 ); + glVertex2f( -0.5, -0.5 ); + glColor3f( 0.0, 0.0, 1.0 ); + glVertex2f( 0.5, -0.5 ); + glEnd(); + + sleep(3); +} + +void end( void ) +{ + SVGAMesaDestroyContext( vmc ); + + vga_setmode( TEXT ); +} + + +int main( int argc, char *argv[] ) +{ + setup(); + test(); + end(); + return 0; +} diff --git a/progs/xdemos/wincopy.c b/progs/xdemos/wincopy.c new file mode 100644 index 00000000000..3ec67dc6724 --- /dev/null +++ b/progs/xdemos/wincopy.c @@ -0,0 +1,329 @@ +/* + * Mesa 3-D graphics library + * Version: 6.1 + * + * Copyright (C) 1999-2004 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. + */ + + +#define GLX_GLXEXT_PROTOTYPES +#include +#include +#include +#include +#include +#include +#include + + +#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 GLboolean DrawFront = GL_FALSE; + +PFNGLXMAKECURRENTREADSGIPROC make_context_current = NULL; + +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 (! (*make_context_current)(Dpy, Win[0], Win[0], Context)) { + printf("glXMakeContextCurrent failed in Redraw()\n"); + return; + } + + Angle += 1.0; + + if (DrawFront) { + glDrawBuffer(GL_FRONT); + glReadBuffer(GL_FRONT); + } + else { + glDrawBuffer(GL_BACK); + glReadBuffer(GL_BACK); + } + + 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(); + + if (DrawFront) + glFinish(); + else + glXSwapBuffers(Dpy, Win[0]); + + + /* copy image from window 0 to window 1 */ + if (!(*make_context_current)(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 */ + glCopyPixels(0, 0, Width[0], Height[0], GL_COLOR); + + glPopMatrix(); + glMatrixMode(GL_MODELVIEW); + glPopMatrix(); + + if (DrawFront) + glFinish(); + else + glXSwapBuffers(Dpy, Win[1]); +} + + + +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: + { + char buf[100]; + KeySym keySym; + XComposeStatus stat; + XLookupString(&event.xkey, buf, sizeof(buf), &keySym, &stat); + if (keySym == XK_Escape) { + /* exit */ + return; + } + else if (buf[0] == 'f') { + DrawFront = !DrawFront; + printf("Drawing to %s buffer\n", + DrawFront ? "GL_FRONT" : "GL_BACK"); + } + } + break; + 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 }; + int major, minor; + + Dpy = XOpenDisplay(NULL); + if (!Dpy) { + printf("Couldn't open default display!\n"); + exit(1); + } + + ScrNum = DefaultScreen(Dpy); + + glXQueryVersion(Dpy, &major, &minor); + + if (major * 100 + minor >= 103) { + make_context_current = (PFNGLXMAKECURRENTREADSGIPROC) + glXGetProcAddressARB( (GLubyte *) "glXMakeContextCurrent" ); + } + else { + const char * const glxExtensions = glXQueryExtensionsString(Dpy, ScrNum); + const char * ext = strstr( glxExtensions, "GLX_SGI_make_current_read" ); + const size_t len = strlen( "GLX_SGI_make_current_read" ); + + if ( (ext != NULL) + && ((ext[len] == ' ') || (ext[len] == '\0')) ) { + make_context_current = (PFNGLXMAKECURRENTREADSGIPROC) + glXGetProcAddressARB( (GLubyte *) "glXMakeCurrentReadSGI" ); + } + } + + if (make_context_current == NULL) { + fprintf(stderr, "Sorry, this program requires either GLX 1.3 " + "or GLX_SGI_make_current_read.\n"); + exit(1); + } + + 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"); + + printf("Press Esc to exit\n"); + printf("Press 'f' to toggle front/back buffer drawing\n"); +} + + +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 */ diff --git a/progs/xdemos/xdemo.c b/progs/xdemos/xdemo.c new file mode 100644 index 00000000000..52039cb6424 --- /dev/null +++ b/progs/xdemos/xdemo.c @@ -0,0 +1,334 @@ + +/* + * Very simple demo of how to use the Mesa/X11 interface instead of the + * glx, tk or aux toolkits. I highly recommend using the GLX interface + * instead of the X/Mesa interface, however. + * + * This program is in the public domain. + * + * Brian Paul + */ + +#include +#include +#include +#include +#include +#include "GL/xmesa.h" +#include "GL/gl.h" + + + +static GLint Black, Red, Green, Blue; + + + +static void make_window( char *title, int color_flag ) +{ + int x = 10, y = 10, width = 400, height = 300; + Display *dpy; + int scr; + Window root, win; + Colormap cmap; + XColor xcolor; + int attr_flags; + XVisualInfo *visinfo; + XSetWindowAttributes attr; + XTextProperty tp; + XSizeHints sh; + XEvent e; + XMesaContext context; + XMesaVisual visual; + XMesaBuffer buffer; + + + /* + * Do the usual X things to make a window. + */ + + dpy = XOpenDisplay(NULL); + if (!dpy) { + printf("Couldn't open default display!\n"); + exit(1); + } + + scr = DefaultScreen(dpy); + root = RootWindow(dpy, scr); + + /* alloc visinfo struct */ + visinfo = (XVisualInfo *) malloc( sizeof(XVisualInfo) ); + + /* Get a visual and colormap */ + if (color_flag) { + /* Open TrueColor window */ + +/* + if (!XMatchVisualInfo( dpy, scr, 24, TrueColor, visinfo )) { + printf("Couldn't get 24-bit TrueColor visual!\n"); + exit(1); + } +*/ + if (!XMatchVisualInfo( dpy, scr, 8, PseudoColor, visinfo )) { + printf("Couldn't get 8-bit PseudoColor visual!\n"); + exit(1); + } + + cmap = XCreateColormap( dpy, root, visinfo->visual, AllocNone ); + Black = Red = Green = Blue = 0; + } + else { + /* Open color index window */ + + if (!XMatchVisualInfo( dpy, scr, 8, PseudoColor, visinfo )) { + printf("Couldn't get 8-bit PseudoColor visual\n"); + exit(1); + } + + cmap = XCreateColormap( dpy, root, visinfo->visual, AllocNone ); + + /* Allocate colors */ + xcolor.red = 0x0; + xcolor.green = 0x0; + xcolor.blue = 0x0; + xcolor.flags = DoRed | DoGreen | DoBlue; + if (!XAllocColor( dpy, cmap, &xcolor )) { + printf("Couldn't allocate black!\n"); + exit(1); + } + Black = xcolor.pixel; + + xcolor.red = 0xffff; + xcolor.green = 0x0; + xcolor.blue = 0x0; + xcolor.flags = DoRed | DoGreen | DoBlue; + if (!XAllocColor( dpy, cmap, &xcolor )) { + printf("Couldn't allocate red!\n"); + exit(1); + } + Red = xcolor.pixel; + + xcolor.red = 0x0; + xcolor.green = 0xffff; + xcolor.blue = 0x0; + xcolor.flags = DoRed | DoGreen | DoBlue; + if (!XAllocColor( dpy, cmap, &xcolor )) { + printf("Couldn't allocate green!\n"); + exit(1); + } + Green = xcolor.pixel; + + xcolor.red = 0x0; + xcolor.green = 0x0; + xcolor.blue = 0xffff; + xcolor.flags = DoRed | DoGreen | DoBlue; + if (!XAllocColor( dpy, cmap, &xcolor )) { + printf("Couldn't allocate blue!\n"); + exit(1); + } + Blue = xcolor.pixel; + } + + /* set window attributes */ + attr.colormap = cmap; + attr.event_mask = ExposureMask | StructureNotifyMask; + attr.border_pixel = BlackPixel( dpy, scr ); + attr.background_pixel = BlackPixel( dpy, scr ); + attr_flags = CWColormap | CWEventMask | CWBorderPixel | CWBackPixel; + + /* Create the window */ + win = XCreateWindow( dpy, root, x,y, width, height, 0, + visinfo->depth, InputOutput, + visinfo->visual, + attr_flags, &attr); + if (!win) { + printf("Couldn't open window!\n"); + exit(1); + } + + XStringListToTextProperty(&title, 1, &tp); + sh.flags = USPosition | USSize; + XSetWMProperties(dpy, win, &tp, &tp, 0, 0, &sh, 0, 0); + XMapWindow(dpy, win); + while (1) { + XNextEvent( dpy, &e ); + if (e.type == MapNotify && e.xmap.window == win) { + break; + } + } + + + /* + * Now do the special Mesa/Xlib stuff! + */ + + visual = XMesaCreateVisual( dpy, visinfo, + (GLboolean) color_flag, + GL_FALSE, /* alpha_flag */ + GL_FALSE, /* db_flag */ + GL_FALSE, /* stereo flag */ + GL_FALSE, /* ximage_flag */ + 0, /* depth size */ + 0, /* stencil size */ + 0,0,0,0, /* accum_size */ + 0, /* num samples */ + 0, /* level */ + 0 /* caveat */ + ); + if (!visual) { + printf("Couldn't create Mesa/X visual!\n"); + exit(1); + } + + /* Create a Mesa rendering context */ + context = XMesaCreateContext( visual, + NULL /* share_list */ + ); + if (!context) { + printf("Couldn't create Mesa/X context!\n"); + exit(1); + } + + buffer = XMesaCreateWindowBuffer( visual, win ); + if (!buffer) { + printf("Couldn't create Mesa/X buffer!\n"); + exit(1); + } + + + XMesaMakeCurrent( context, buffer ); + + /* Ready to render! */ +} + + + +static void draw_cube( void ) +{ + /* X faces */ + glIndexi( Red ); + glColor3f( 1.0, 0.0, 0.0 ); + glBegin( GL_POLYGON ); + glVertex3f( 1.0, 1.0, 1.0 ); + glVertex3f( 1.0, -1.0, 1.0 ); + glVertex3f( 1.0, -1.0, -1.0 ); + glVertex3f( 1.0, 1.0, -1.0 ); + glEnd(); + + glBegin( GL_POLYGON ); + glVertex3f( -1.0, 1.0, 1.0 ); + glVertex3f( -1.0, 1.0, -1.0 ); + glVertex3f( -1.0, -1.0, -1.0 ); + glVertex3f( -1.0, -1.0, 1.0 ); + glEnd(); + + /* Y faces */ + glIndexi( Green ); + glColor3f( 0.0, 1.0, 0.0 ); + glBegin( GL_POLYGON ); + glVertex3f( 1.0, 1.0, 1.0 ); + glVertex3f( 1.0, 1.0, -1.0 ); + glVertex3f( -1.0, 1.0, -1.0 ); + glVertex3f( -1.0, 1.0, 1.0 ); + glEnd(); + + glBegin( GL_POLYGON ); + glVertex3f( 1.0, -1.0, 1.0 ); + glVertex3f( -1.0, -1.0, 1.0 ); + glVertex3f( -1.0, -1.0, -1.0 ); + glVertex3f( 1.0, -1.0, -1.0 ); + glEnd(); + + /* Z faces */ + glIndexi( Blue ); + glColor3f( 0.0, 0.0, 1.0 ); + glBegin( GL_POLYGON ); + glVertex3f( 1.0, 1.0, 1.0 ); + glVertex3f( -1.0, 1.0, 1.0 ); + glVertex3f( -1.0, -1.0, 1.0 ); + glVertex3f( 1.0, -1.0, 1.0 ); + glEnd(); + + glBegin( GL_POLYGON ); + glVertex3f( 1.0, 1.0, -1.0 ); + glVertex3f( 1.0,-1.0, -1.0 ); + glVertex3f( -1.0,-1.0, -1.0 ); + glVertex3f( -1.0, 1.0, -1.0 ); + glEnd(); +} + + + + +static void display_loop( void ) +{ + GLfloat xrot, yrot, zrot; + + xrot = yrot = zrot = 0.0; + + glClearColor( 0.0, 0.0, 0.0, 0.0 ); + glClearIndex( Black ); + + glMatrixMode( GL_PROJECTION ); + glLoadIdentity(); + glFrustum( -1.0, 1.0, -1.0, 1.0, 1.0, 10.0 ); + glTranslatef( 0.0, 0.0, -5.0 ); + + glMatrixMode( GL_MODELVIEW ); + glLoadIdentity(); + + glCullFace( GL_BACK ); + glEnable( GL_CULL_FACE ); + + glShadeModel( GL_FLAT ); + + while (1) { + glClear( GL_COLOR_BUFFER_BIT ); + glPushMatrix(); + glRotatef( xrot, 1.0, 0.0, 0.0 ); + glRotatef( yrot, 0.0, 1.0, 0.0 ); + glRotatef( zrot, 0.0, 0.0, 1.0 ); + + draw_cube(); + + glPopMatrix(); + glFinish(); + + xrot += 10.0; + yrot += 7.0; + zrot -= 3.0; + } + +} + + + + +int main( int argc, char *argv[] ) +{ + int mode = 0; + + if (argc >= 2) + { + if (strcmp(argv[1],"-ci")==0) + mode = 0; + else if (strcmp(argv[1],"-rgb")==0) + mode = 1; + else + { + printf("Bad flag: %s\n", argv[1]); + printf("Specify -ci for 8-bit color index or -rgb for RGB mode\n"); + exit(1); + } + } + else + { + printf("Specify -ci for 8-bit color index or -rgb for RGB mode\n"); + printf("Defaulting to 8-bit color index\n"); + } + + make_window( argv[0], mode ); + + display_loop(); + return 0; +} + diff --git a/progs/xdemos/xfont.c b/progs/xdemos/xfont.c new file mode 100644 index 00000000000..2585aa6447c --- /dev/null +++ b/progs/xdemos/xfont.c @@ -0,0 +1,206 @@ + +/* + * Mesa 3-D graphics library + * + * 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. + */ + + +/* + * Example of using glXUseXFont(). + * 5 November 1999 + * Brian Paul + */ + + +#include +#include +#include +#include +#include + + +static const char *ProgramName = "xfont"; + +static const char *FontName = "fixed"; + +static GLuint FontBase = 0; + + + +static void redraw( Display *dpy, Window w ) +{ + static const char *text = "This is glXUseXFont()"; + + glClear( GL_COLOR_BUFFER_BIT ); + + /* triangle */ + glColor3f( 0.2, 0.2, 1.0 ); + glBegin(GL_TRIANGLES); + glVertex2f( 0, 0.8 ); + glVertex2f( -0.8, -0.7 ); + glVertex2f( 0.8, -0.7 ); + glEnd(); + + /* text */ + glColor3f( 1, 1, 1 ); + glRasterPos2f(-0.8, 0); + glListBase(FontBase); + glCallLists(strlen(text), GL_UNSIGNED_BYTE, (GLubyte *) text); + + glXSwapBuffers( dpy, w ); +} + + + +static void resize( unsigned int width, unsigned int height ) +{ + glViewport( 0, 0, width, height ); + glMatrixMode( GL_PROJECTION ); + glLoadIdentity(); + glOrtho( -1.0, 1.0, -1.0, 1.0, -1.0, 1.0 ); +} + + + +static void setup_font( Display *dpy ) +{ + XFontStruct *fontInfo; + Font id; + unsigned int first, last; + + fontInfo = XLoadQueryFont(dpy, FontName); + if (!fontInfo) { + printf("Error: font %s not found\n", FontName); + exit(0); + } + + id = fontInfo->fid; + first = fontInfo->min_char_or_byte2; + last = fontInfo->max_char_or_byte2; + + FontBase = glGenLists((GLuint) last + 1); + if (!FontBase) { + printf("Error: unable to allocate display lists\n"); + exit(0); + } + glXUseXFont(id, first, last - first + 1, FontBase + first); +} + +static Window make_rgb_db_window( Display *dpy, int xpos, int ypos, + unsigned int width, unsigned int height ) +{ + 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; + Window win; + GLXContext ctx; + XVisualInfo *visinfo; + + scrnum = DefaultScreen( dpy ); + root = RootWindow( dpy, scrnum ); + + visinfo = glXChooseVisual( dpy, scrnum, attrib ); + if (!visinfo) { + printf("Error: couldn't get an RGB, Double-buffered visual\n"); + exit(1); + } + + /* 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 ); + + { + 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, ProgramName, ProgramName, + None, (char **)NULL, 0, &sizehints); + } + + + ctx = glXCreateContext( dpy, visinfo, NULL, True ); + + glXMakeCurrent( dpy, win, ctx ); + + return win; +} + + +static void event_loop( Display *dpy ) +{ + XEvent event; + + while (1) { + XNextEvent( dpy, &event ); + + switch (event.type) { + case Expose: + redraw( dpy, event.xany.window ); + break; + case ConfigureNotify: + resize( event.xconfigure.width, event.xconfigure.height ); + break; + case KeyPress: + exit(0); + default: + ; /* no-op */ + } + } +} + + + +int main( int argc, char *argv[] ) +{ + Display *dpy; + Window win; + + dpy = XOpenDisplay(NULL); + + win = make_rgb_db_window( dpy, 0, 0, 300, 300 ); + setup_font( dpy ); + + glShadeModel( GL_FLAT ); + glClearColor( 0.5, 0.5, 1.0, 1.0 ); + + XMapWindow( dpy, win ); + + event_loop( dpy ); + return 0; +} diff --git a/progs/xdemos/xrotfontdemo.c b/progs/xdemos/xrotfontdemo.c new file mode 100644 index 00000000000..58cd0286cc6 --- /dev/null +++ b/progs/xdemos/xrotfontdemo.c @@ -0,0 +1,220 @@ +/* + * Mesa 3-D graphics library + * + * 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. + */ + + +/* + * Example of using glXUseRotatedXFontMESA(). + * 24 Jan 2004 + * Brian Paul + */ + + +#include +#include +#include +#include +#include +#include "xuserotfont.h" + + +static const char *ProgramName = "xfont"; + +static const char *FontName = "fixed"; + +static GLuint FontBase[4]; + + +static void redraw( Display *dpy, Window w ) +{ + static const char *text = " Rotated bitmap text"; + int i; + + glClear( GL_COLOR_BUFFER_BIT ); + + /* triangle */ + glColor3f( 0.2, 0.2, 1.0 ); + glBegin(GL_TRIANGLES); + glVertex2f( -0.8, 0.7 ); + glVertex2f( -0.8, -0.7 ); + glVertex2f( 0.8, 0.0 ); + glEnd(); + + /* marker */ + glColor3f( 0, 1, 0 ); + glBegin(GL_POINTS); + glVertex2f(0, 0); + glEnd(); + + /* text */ + glColor3f( 1, 1, 1 ); + + for (i = 0; i < 4; i++) { + glRasterPos2f(0, 0); + glListBase(FontBase[i]); + glCallLists(strlen(text), GL_UNSIGNED_BYTE, (GLubyte *) text); + } + + glXSwapBuffers( dpy, w ); +} + + + +static void resize( unsigned int width, unsigned int height ) +{ + glViewport( 0, 0, width, height ); + glMatrixMode( GL_PROJECTION ); + glLoadIdentity(); + glOrtho( -1.0, 1.0, -1.0, 1.0, -1.0, 1.0 ); +} + + + +static void setup_font( Display *dpy ) +{ + XFontStruct *fontInfo; + Font id; + unsigned int first, last; + int i; + + fontInfo = XLoadQueryFont(dpy, FontName); + if (!fontInfo) { + printf("Error: font %s not found\n", FontName); + exit(0); + } + + id = fontInfo->fid; + first = fontInfo->min_char_or_byte2; + last = fontInfo->max_char_or_byte2; + + for (i = 0; i < 4; i++) { + FontBase[i] = glGenLists((GLuint) last + 1); + if (!FontBase[i]) { + printf("Error: unable to allocate display lists\n"); + exit(0); + } + glXUseRotatedXFontMESA(id, first, last - first + 1, FontBase[i] + first, + i * 90); + } +} + + +static Window make_rgb_db_window( Display *dpy, int xpos, int ypos, + unsigned int width, unsigned int height ) +{ + 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; + Window win; + GLXContext ctx; + XVisualInfo *visinfo; + + scrnum = DefaultScreen( dpy ); + root = RootWindow( dpy, scrnum ); + + visinfo = glXChooseVisual( dpy, scrnum, attrib ); + if (!visinfo) { + printf("Error: couldn't get an RGB, Double-buffered visual\n"); + exit(1); + } + + /* 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 ); + + { + 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, ProgramName, ProgramName, + None, (char **)NULL, 0, &sizehints); + } + + + ctx = glXCreateContext( dpy, visinfo, NULL, True ); + + glXMakeCurrent( dpy, win, ctx ); + + return win; +} + + +static void event_loop( Display *dpy ) +{ + XEvent event; + + while (1) { + XNextEvent( dpy, &event ); + + switch (event.type) { + case Expose: + redraw( dpy, event.xany.window ); + break; + case ConfigureNotify: + resize( event.xconfigure.width, event.xconfigure.height ); + break; + case KeyPress: + exit(0); + default: + ; /* no-op */ + } + } +} + + + +int main( int argc, char *argv[] ) +{ + Display *dpy; + Window win; + + dpy = XOpenDisplay(NULL); + + win = make_rgb_db_window( dpy, 0, 0, 300, 300 ); + setup_font( dpy ); + + glShadeModel( GL_FLAT ); + glClearColor( 0.5, 0.5, 1.0, 1.0 ); + + XMapWindow( dpy, win ); + + event_loop( dpy ); + return 0; +} diff --git a/progs/xdemos/xuserotfont.c b/progs/xdemos/xuserotfont.c new file mode 100644 index 00000000000..adb849511d8 --- /dev/null +++ b/progs/xdemos/xuserotfont.c @@ -0,0 +1,399 @@ +/* + * Mesa 3-D graphics library + * Version: 6.1 + * + * Copyright (C) 1999-2004 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. + */ + + +/* \file xuserotfont.c + * + * A function like glXUseXFont() but takes a 0, 90, 180 or 270 degree + * rotation angle for rotated text display. + * + * Based on Mesa's glXUseXFont implementation written by Thorsten Ohl. + */ + +#include +#include +#include +#include +#include "xuserotfont.h" + + +/** + * Generate OpenGL-compatible bitmap by drawing an X character glyph + * to an off-screen pixmap, then getting the image and testing pixels. + * \param width bitmap width in pixels + * \param height bitmap height in pixels + */ +static void +fill_bitmap(Display *dpy, Pixmap pixmap, GC gc, + unsigned int bitmapWidth, unsigned int bitmapHeight, + unsigned int charWidth, unsigned int charHeight, + int xPos, int yPos, unsigned int c, GLubyte * bitmap, + int rotation) +{ + const int bytesPerRow = (bitmapWidth + 7) / 8; + XImage *image; + XChar2b char2b; + + /* clear pixmap to 0 */ + XSetForeground(dpy, gc, 0); + XFillRectangle(dpy, pixmap, gc, 0, 0, charWidth, charHeight); + + /* The glyph is drawn snug up against the left/top edges of the pixmap */ + XSetForeground(dpy, gc, 1); + char2b.byte1 = (c >> 8) & 0xff; + char2b.byte2 = (c & 0xff); + XDrawString16(dpy, pixmap, gc, xPos, yPos, &char2b, 1); + + /* initialize GL bitmap */ + memset(bitmap, 0, bytesPerRow * bitmapHeight); + + image = XGetImage(dpy, pixmap, 0, 0, charWidth, charHeight, 1, XYPixmap); + if (image) { + /* Set appropriate bits in the GL bitmap. + * Note: X11 and OpenGL are upside down wrt each other). + */ + unsigned int x, y; + if (rotation == 0) { + for (y = 0; y < charHeight; y++) { + for (x = 0; x < charWidth; x++) { + if (XGetPixel(image, x, y)) { + int y2 = bitmapHeight - y - 1; + bitmap[bytesPerRow * y2 + x / 8] |= (1 << (7 - (x % 8))); + } + } + } + } + else if (rotation == 90) { + for (y = 0; y < charHeight; y++) { + for (x = 0; x < charWidth; x++) { + if (XGetPixel(image, x, y)) { + int x2 = y; + int y2 = x; + bitmap[bytesPerRow * y2 + x2 / 8] |= (1 << (7 - (x2 % 8))); + } + } + } + } + else if (rotation == 180) { + for (y = 0; y < charHeight; y++) { + for (x = 0; x < charWidth; x++) { + if (XGetPixel(image, x, y)) { + int x2 = charWidth - x - 1; + bitmap[bytesPerRow * y + x2 / 8] |= (1 << (7 - (x2 % 8))); + } + } + } + } + else { + assert(rotation == 270); + for (y = 0; y < charHeight; y++) { + for (x = 0; x < charWidth; x++) { + if (XGetPixel(image, x, y)) { + int x2 = charHeight - y - 1; + int y2 = charWidth - x - 1; + bitmap[bytesPerRow * y2 + x2 / 8] |= (1 << (7 - (x2 % 8))); + } + } + } + } + XDestroyImage(image); + } +} + + +/* + * Determine if a given glyph is valid and return the + * corresponding XCharStruct. + */ +static const XCharStruct * +isvalid(const XFontStruct * fs, unsigned int which) +{ + unsigned int rows, pages; + unsigned int byte1 = 0, byte2 = 0; + int i, valid = 1; + + rows = fs->max_byte1 - fs->min_byte1 + 1; + pages = fs->max_char_or_byte2 - fs->min_char_or_byte2 + 1; + + if (rows == 1) { + /* "linear" fonts */ + if ((fs->min_char_or_byte2 > which) || (fs->max_char_or_byte2 < which)) + valid = 0; + } + else { + /* "matrix" fonts */ + byte2 = which & 0xff; + byte1 = which >> 8; + if ((fs->min_char_or_byte2 > byte2) || + (fs->max_char_or_byte2 < byte2) || + (fs->min_byte1 > byte1) || (fs->max_byte1 < byte1)) + valid = 0; + } + + if (valid) { + if (fs->per_char) { + if (rows == 1) { + /* "linear" fonts */ + return fs->per_char + (which - fs->min_char_or_byte2); + } + else { + /* "matrix" fonts */ + i = ((byte1 - fs->min_byte1) * pages) + + (byte2 - fs->min_char_or_byte2); + return fs->per_char + i; + } + } + else { + return &fs->min_bounds; + } + } + return NULL; +} + + +void +glXUseRotatedXFontMESA(Font font, int first, int count, int listbase, + int rotation) +{ + Display *dpy; + Window win; + Pixmap pixmap; + GC gc; + XFontStruct *fs; + GLint swapbytes, lsbfirst, rowlength; + GLint skiprows, skippixels, alignment; + unsigned int maxCharWidth, maxCharHeight; + GLubyte *bm; + int i; + + if (rotation != 0 && + rotation != 90 && + rotation != 180 && + rotation != 270) + return; + + dpy = glXGetCurrentDisplay(); + if (!dpy) + return; /* I guess glXMakeCurrent wasn't called */ + win = RootWindow(dpy, DefaultScreen(dpy)); + + fs = XQueryFont(dpy, font); + if (!fs) { + /* + _mesa_error(NULL, GL_INVALID_VALUE, + "Couldn't get font structure information"); + */ + return; + } + + /* Allocate a GL bitmap that can fit any character */ + maxCharWidth = fs->max_bounds.rbearing - fs->min_bounds.lbearing; + maxCharHeight = fs->max_bounds.ascent + fs->max_bounds.descent; + /* use max, in case we're rotating */ + if (rotation == 90 || rotation == 270) { + /* swap width/height */ + bm = (GLubyte *) malloc((maxCharHeight + 7) / 8 * maxCharWidth); + } + else { + /* normal or upside down */ + bm = (GLubyte *) malloc((maxCharWidth + 7) / 8 * maxCharHeight); + } + if (!bm) { + XFreeFontInfo(NULL, fs, 1); + /* + _mesa_error(NULL, GL_OUT_OF_MEMORY, + "Couldn't allocate bitmap in glXUseXFont()"); + */ + return; + } + +#if 0 + /* get the page info */ + pages = fs->max_char_or_byte2 - fs->min_char_or_byte2 + 1; + firstchar = (fs->min_byte1 << 8) + fs->min_char_or_byte2; + lastchar = (fs->max_byte1 << 8) + fs->max_char_or_byte2; + rows = fs->max_byte1 - fs->min_byte1 + 1; + unsigned int first_char, last_char, pages, rows; +#endif + + /* Save the current packing mode for bitmaps. */ + glGetIntegerv(GL_UNPACK_SWAP_BYTES, &swapbytes); + glGetIntegerv(GL_UNPACK_LSB_FIRST, &lsbfirst); + glGetIntegerv(GL_UNPACK_ROW_LENGTH, &rowlength); + glGetIntegerv(GL_UNPACK_SKIP_ROWS, &skiprows); + glGetIntegerv(GL_UNPACK_SKIP_PIXELS, &skippixels); + glGetIntegerv(GL_UNPACK_ALIGNMENT, &alignment); + + /* Enforce a standard packing mode which is compatible with + fill_bitmap() from above. This is actually the default mode, + except for the (non)alignment. */ + glPixelStorei(GL_UNPACK_SWAP_BYTES, GL_FALSE); + glPixelStorei(GL_UNPACK_LSB_FIRST, GL_FALSE); + glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); + glPixelStorei(GL_UNPACK_SKIP_ROWS, 0); + glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0); + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + + /* Create pixmap and GC */ + pixmap = XCreatePixmap(dpy, win, maxCharWidth, maxCharHeight, 1); + { + XGCValues values; + unsigned long valuemask; + values.foreground = BlackPixel(dpy, DefaultScreen(dpy)); + values.background = WhitePixel(dpy, DefaultScreen(dpy)); + values.font = fs->fid; + valuemask = GCForeground | GCBackground | GCFont; + gc = XCreateGC(dpy, pixmap, valuemask, &values); + } + +#ifdef DEBUG_XROT + if (debug_xfonts) + dump_font_struct(fs); +#endif + + for (i = 0; i < count; i++) { + const unsigned int c = first + i; + const int list = listbase + i; + unsigned int charWidth, charHeight; + unsigned int bitmapWidth = 0, bitmapHeight = 0; + GLfloat xOrig, yOrig, xStep, yStep, dtemp; + const XCharStruct *ch; + int xPos, yPos; + int valid; + + /* check on index validity and get the bounds */ + ch = isvalid(fs, c); + if (!ch) { + ch = &fs->max_bounds; + valid = 0; + } + else { + valid = 1; + } + +#ifdef DEBUG_XROT + if (debug_xfonts) { + char s[7]; + sprintf(s, isprint(c) ? "%c> " : "\\%03o> ", c); + dump_char_struct(ch, s); + } +#endif + + /* glBitmap()' parameters: + straight from the glXUseXFont(3) manpage. */ + charWidth = ch->rbearing - ch->lbearing; + charHeight = ch->ascent + ch->descent; + xOrig = -ch->lbearing; + yOrig = ch->descent; + xStep = ch->width; + yStep = 0; + + /* X11's starting point. */ + xPos = -ch->lbearing; + yPos = ch->ascent; + + /* Apply rotation */ + switch (rotation) { + case 0: + /* nothing */ + bitmapWidth = charWidth; + bitmapHeight = charHeight; + break; + case 90: + /* xStep, yStep */ + dtemp = xStep; + xStep = -yStep; + yStep = dtemp; + /* xOrig, yOrig */ + yOrig = xOrig; + xOrig = charHeight - (charHeight - yPos); + /* width, height */ + bitmapWidth = charHeight; + bitmapHeight = charWidth; + break; + case 180: + /* xStep, yStep */ + xStep = -xStep; + yStep = -yStep; + /* xOrig, yOrig */ + xOrig = charWidth - xOrig - 1; + yOrig = charHeight - yOrig - 1; + bitmapWidth = charWidth; + bitmapHeight = charHeight; + break; + case 270: + /* xStep, yStep */ + dtemp = xStep; + xStep = yStep; + yStep = -dtemp; + /* xOrig, yOrig */ + dtemp = yOrig; + yOrig = charWidth - xOrig; + xOrig = dtemp; + /* width, height */ + bitmapWidth = charHeight; + bitmapHeight = charWidth; + break; + default: + /* should never get here */ + ; + } + + glNewList(list, GL_COMPILE); + if (valid && bitmapWidth > 0 && bitmapHeight > 0) { + + fill_bitmap(dpy, pixmap, gc, bitmapWidth, bitmapHeight, + charWidth, charHeight, + xPos, yPos, c, bm, rotation); + + glBitmap(bitmapWidth, bitmapHeight, xOrig, yOrig, xStep, yStep, bm); + +#ifdef DEBUG_XROT + if (debug_xfonts) { + printf("width/height = %u/%u\n", bitmapWidth, bitmapHeight); + dump_bitmap(bitmapWidth, bitmapHeight, bm); + } +#endif + } + else { + glBitmap(0, 0, 0.0, 0.0, xStep, yStep, NULL); + } + glEndList(); + } + + free(bm); + XFreeFontInfo(NULL, fs, 1); + XFreePixmap(dpy, pixmap); + XFreeGC(dpy, gc); + + /* Restore saved packing modes. */ + glPixelStorei(GL_UNPACK_SWAP_BYTES, swapbytes); + glPixelStorei(GL_UNPACK_LSB_FIRST, lsbfirst); + glPixelStorei(GL_UNPACK_ROW_LENGTH, rowlength); + glPixelStorei(GL_UNPACK_SKIP_ROWS, skiprows); + glPixelStorei(GL_UNPACK_SKIP_PIXELS, skippixels); + glPixelStorei(GL_UNPACK_ALIGNMENT, alignment); +} + + diff --git a/progs/xdemos/xuserotfont.h b/progs/xdemos/xuserotfont.h new file mode 100644 index 00000000000..ea49203b7b9 --- /dev/null +++ b/progs/xdemos/xuserotfont.h @@ -0,0 +1,12 @@ +#ifndef XUSEROTFONT_H +#define XUSEROTFONT_H + +#include + + +extern void +glXUseRotatedXFontMESA(Font font, int first, int count, int listbase, + int rotation); + + +#endif diff --git a/progs/xdemos/yuvrect_client.c b/progs/xdemos/yuvrect_client.c new file mode 100644 index 00000000000..48f82cb7599 --- /dev/null +++ b/progs/xdemos/yuvrect_client.c @@ -0,0 +1,326 @@ +/* + * Test the GL_NV_texture_rectangle and GL_MESA_ycrcb_texture extensions and GLX_MESA_allocate-memory + * + * Dave Airlie - Feb 2005 + */ + +#include +#include +#include +#include +#include +#include +#include +#define GL_GLEXT_PROTOTYPES +#include + +#include "../util/readtex.c" /* I know, this is a hack. */ + +#define TEXTURE_FILE "../images/girl2.rgb" + +static GLfloat Xrot = 0, Yrot = 0, Zrot = 0; +static GLint ImgWidth, ImgHeight; +static GLushort *ImageYUV = NULL; +static void *glx_memory; + +static void DrawObject(void) +{ + glBegin(GL_QUADS); + + glTexCoord2f(0, 0); + glVertex2f(-1.0, -1.0); + + glTexCoord2f(ImgWidth, 0); + glVertex2f(1.0, -1.0); + + glTexCoord2f(ImgWidth, ImgHeight); + glVertex2f(1.0, 1.0); + + glTexCoord2f(0, ImgHeight); + glVertex2f(-1.0, 1.0); + + glEnd(); +} + + +static void scr_Display( void ) +{ + glClear( GL_COLOR_BUFFER_BIT ); + + glPushMatrix(); + glRotatef(Xrot, 1.0, 0.0, 0.0); + glRotatef(Yrot, 0.0, 1.0, 0.0); + glRotatef(Zrot, 0.0, 0.0, 1.0); + DrawObject(); + glPopMatrix(); + +} + + +static void Reshape( int width, int height ) +{ + glViewport( 0, 0, width, height ); + glMatrixMode( GL_PROJECTION ); + glLoadIdentity(); + glFrustum( -1.0, 1.0, -1.0, 1.0, 10.0, 100.0 ); + glMatrixMode( GL_MODELVIEW ); + glLoadIdentity(); + glTranslatef( 0.0, 0.0, -15.0 ); +} + +static int queryClient(Display *dpy, int screen) +{ +#ifdef GLX_MESA_allocate_memory + char *extensions; + + extensions = (char *)glXQueryExtensionsString(dpy, screen); + if (!extensions || !strstr(extensions,"GLX_MESA_allocate_memory")) { + return 0; + } + + return 1; +#else + return 0; +#endif +} + +static int +query_extension(char* extName) { + char *p = (char *) glGetString(GL_EXTENSIONS); + char *end = p + strlen(p); + while (p < end) { + int n = strcspn(p, " "); + if ((strlen(extName) == n) && (strncmp(extName, p, n) == 0)) + return GL_TRUE; + p += (n + 1); + } + return GL_FALSE; +} + +static void Init( int argc, char *argv[] , Display *dpy, int screen, Window win) +{ + GLuint texObj = 100; + const char *file; + void *glx_memory; + + if (!query_extension("GL_NV_texture_rectangle")) { + printf("Sorry, GL_NV_texture_rectangle is required\n"); + exit(0); + } + + if (!query_extension("GL_MESA_ycbcr_texture")) { + printf("Sorry, GL_MESA_ycbcr_texture is required\n"); + exit(0); + } + + if (!queryClient(dpy, screen)) { + printf("Sorry, GLX_MESA_allocate_memory is required\n"); + exit(0); + } + + glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, 1); + glBindTexture(GL_TEXTURE_RECTANGLE_NV, texObj); +#ifdef LINEAR_FILTER + /* linear filtering looks much nicer but is much slower for Mesa */ + glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_MAG_FILTER, GL_LINEAR); +#else + glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_MAG_FILTER, GL_NEAREST); +#endif + + if (argc > 1) + file = argv[1]; + else + file = TEXTURE_FILE; + + ImageYUV = LoadYUVImage(file, &ImgWidth, &ImgHeight); + if (!ImageYUV) { + printf("Couldn't read %s\n", TEXTURE_FILE); + exit(0); + } + + glx_memory = glXAllocateMemoryMESA(dpy, screen, ImgWidth * ImgHeight * 2, 0, 0 ,0); + if (!glx_memory) + { + fprintf(stderr,"Failed to allocate MESA memory\n"); + exit(-1); + } + + memcpy(glx_memory, ImageYUV, ImgWidth * ImgHeight * 2); + + printf("Image: %dx%d\n", ImgWidth, ImgHeight); + + glTexImage2D(GL_TEXTURE_RECTANGLE_NV, 0, + GL_YCBCR_MESA, ImgWidth, ImgHeight, 0, + GL_YCBCR_MESA, GL_UNSIGNED_SHORT_8_8_APPLE, glx_memory); + + assert(glGetError() == GL_NO_ERROR); + + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + + glEnable(GL_TEXTURE_RECTANGLE_NV); + + glShadeModel(GL_FLAT); + glClearColor(0.3, 0.3, 0.4, 1.0); + +} + +/* + * Create an RGB, double-buffered window. + * Return the window and context handles. + */ +static void +make_window( Display *dpy, const char *name, + int x, int y, int width, int height, + Window *winRet, GLXContext *ctxRet) +{ + int attribs[] = { GLX_RGBA, + GLX_RED_SIZE, 1, + GLX_GREEN_SIZE, 1, + GLX_BLUE_SIZE, 1, + GLX_DOUBLEBUFFER, + GLX_DEPTH_SIZE, 1, + None }; + int scrnum; + XSetWindowAttributes attr; + unsigned long mask; + Window root; + Window win; + GLXContext ctx; + XVisualInfo *visinfo; + + scrnum = DefaultScreen( dpy ); + root = RootWindow( dpy, scrnum ); + + visinfo = glXChooseVisual( dpy, scrnum, attribs ); + if (!visinfo) { + printf("Error: couldn't get an RGB, Double-buffered visual\n"); + exit(1); + } + + /* window attributes */ + attr.background_pixel = 0; + attr.border_pixel = 0; + attr.colormap = XCreateColormap( dpy, root, visinfo->visual, AllocNone); + attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask; + attr.override_redirect = 0; + mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask | CWOverrideRedirect; + + win = XCreateWindow( dpy, root, 0, 0, width, height, + 0, visinfo->depth, InputOutput, + visinfo->visual, mask, &attr ); + + /* set hints and properties */ + { + XSizeHints sizehints; + sizehints.x = x; + sizehints.y = y; + 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) { + printf("Error: glXCreateContext failed\n"); + exit(1); + } + + XFree(visinfo); + + *winRet = win; + *ctxRet = ctx; +} + + +static void +event_loop(Display *dpy, Window win) +{ + while (1) { + while (XPending(dpy) > 0) { + XEvent event; + XNextEvent(dpy, &event); + switch (event.type) { + case Expose: + /* we'll redraw below */ + break; + case ConfigureNotify: + Reshape(event.xconfigure.width, event.xconfigure.height); + break; + case KeyPress: + { + char buffer[10]; + int r, code; + code = XLookupKeysym(&event.xkey, 0); + r = XLookupString(&event.xkey, buffer, sizeof(buffer), + NULL, NULL); + if (buffer[0] == 27) { + /* escape */ + return; + + } + } + } + } + + } +} + + +int +main(int argc, char *argv[]) +{ + Display *dpy; + Window win; + GLXContext ctx; + char *dpyName = NULL; + GLboolean printInfo = GL_FALSE; + int i; + + for (i = 1; i < argc; i++) { + if (strcmp(argv[i], "-display") == 0) { + dpyName = argv[i+1]; + i++; + } + else if (strcmp(argv[i], "-info") == 0) { + printInfo = GL_TRUE; + } + else + printf("Warrning: unknown parameter: %s\n", argv[i]); + } + + dpy = XOpenDisplay(dpyName); + if (!dpy) { + printf("Error: couldn't open display %s\n", + dpyName ? dpyName : getenv("DISPLAY")); + return -1; + } + + make_window(dpy, "yuvrect_client", 0, 0, 300, 300, &win, &ctx); + XMapWindow(dpy, win); + glXMakeCurrent(dpy, win, ctx); + + if (printInfo) { + 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)); + } + + Init(argc, argv, dpy, DefaultScreen(dpy), win); + + scr_Display(); + glXSwapBuffers(dpy, win); + event_loop(dpy, win); + + glXFreeMemoryMESA(dpy, DefaultScreen(dpy), glx_memory); + glXDestroyContext(dpy, ctx); + XDestroyWindow(dpy, win); + XCloseDisplay(dpy); + + return 0; +} -- cgit v1.2.3