summaryrefslogtreecommitdiffstats
path: root/progs
diff options
context:
space:
mode:
authorJulien Cristau <[email protected]>2007-02-01 11:50:36 +0100
committerJulien Cristau <[email protected]>2007-02-01 11:50:36 +0100
commit2634f06c2095b79d4252bb81c0b0272139dad890 (patch)
tree855ba634812939982daa999dc44365a4d889d11e /progs
parent7549426a168f3803d6023622dd9e630a5fa2faf6 (diff)
parenteb667b979bc941f05b8f40a2fc39af6fac960ac5 (diff)
Merge branch 'upstream-experimental' into debian-experimental
Conflicts: progs/util/README progs/util/glstate.c progs/util/glstate.h progs/util/sampleMakefile src/glu/sgi/libnurbs/interface/bezierEval.h src/glu/sgi/libnurbs/interface/bezierPatch.cc src/glu/sgi/libnurbs/interface/bezierPatch.h src/glu/sgi/libnurbs/interface/bezierPatchMesh.cc src/glu/sgi/libnurbs/interface/bezierPatchMesh.h src/glu/sgi/libnurbs/interface/glcurveval.cc src/glu/sgi/libnurbs/interface/glimports.h src/glu/sgi/libnurbs/interface/glinterface.cc src/glu/sgi/libnurbs/interface/glrenderer.h src/glu/sgi/libnurbs/interface/incurveeval.cc src/glu/sgi/libnurbs/interface/insurfeval.cc src/glu/sgi/libnurbs/interface/mystdio.h src/glu/sgi/libnurbs/interface/mystdlib.h src/glu/sgi/libnurbs/internals/arc.h src/glu/sgi/libnurbs/internals/arcsorter.cc src/glu/sgi/libnurbs/internals/arcsorter.h src/glu/sgi/libnurbs/internals/arctess.h src/glu/sgi/libnurbs/internals/backend.cc src/glu/sgi/libnurbs/internals/backend.h src/glu/sgi/libnurbs/internals/basiccrveval.h src/glu/sgi/libnurbs/internals/basicsurfeval.h src/glu/sgi/libnurbs/internals/bezierarc.h src/glu/sgi/libnurbs/internals/bin.cc src/glu/sgi/libnurbs/internals/bin.h src/glu/sgi/libnurbs/internals/bufpool.cc src/glu/sgi/libnurbs/internals/bufpool.h src/glu/sgi/libnurbs/internals/cachingeval.cc src/glu/sgi/libnurbs/internals/cachingeval.h src/glu/sgi/libnurbs/internals/ccw.cc src/glu/sgi/libnurbs/internals/coveandtiler.h src/glu/sgi/libnurbs/internals/curve.cc src/glu/sgi/libnurbs/internals/curve.h src/glu/sgi/libnurbs/internals/curvelist.cc src/glu/sgi/libnurbs/internals/curvelist.h src/glu/sgi/libnurbs/internals/curvesub.cc src/glu/sgi/libnurbs/internals/dataTransform.cc src/glu/sgi/libnurbs/internals/dataTransform.h src/glu/sgi/libnurbs/internals/defines.h src/glu/sgi/libnurbs/internals/displaylist.cc src/glu/sgi/libnurbs/internals/displaylist.h src/glu/sgi/libnurbs/internals/displaymode.h src/glu/sgi/libnurbs/internals/flist.cc src/glu/sgi/libnurbs/internals/flist.h src/glu/sgi/libnurbs/internals/flistsorter.cc src/glu/sgi/libnurbs/internals/flistsorter.h src/glu/sgi/libnurbs/internals/gridline.h src/glu/sgi/libnurbs/internals/gridtrimvertex.h src/glu/sgi/libnurbs/internals/gridvertex.h src/glu/sgi/libnurbs/internals/hull.cc src/glu/sgi/libnurbs/internals/hull.h src/glu/sgi/libnurbs/internals/intersect.cc src/glu/sgi/libnurbs/internals/jarcloc.h src/glu/sgi/libnurbs/internals/knotvector.h src/glu/sgi/libnurbs/internals/mapdesc.cc src/glu/sgi/libnurbs/internals/mapdesc.h src/glu/sgi/libnurbs/internals/mapdescv.cc src/glu/sgi/libnurbs/internals/maplist.cc src/glu/sgi/libnurbs/internals/maplist.h src/glu/sgi/libnurbs/internals/mesher.cc src/glu/sgi/libnurbs/internals/mesher.h src/glu/sgi/libnurbs/internals/monoTriangulationBackend.cc src/glu/sgi/libnurbs/internals/monotonizer.cc src/glu/sgi/libnurbs/internals/monotonizer.h src/glu/sgi/libnurbs/internals/myassert.h src/glu/sgi/libnurbs/internals/mycode.cc src/glu/sgi/libnurbs/internals/mystring.h src/glu/sgi/libnurbs/internals/nurbsconsts.h src/glu/sgi/libnurbs/internals/nurbstess.cc src/glu/sgi/libnurbs/internals/patch.cc src/glu/sgi/libnurbs/internals/patch.h src/glu/sgi/libnurbs/internals/patchlist.cc src/glu/sgi/libnurbs/internals/patchlist.h src/glu/sgi/libnurbs/internals/pwlarc.h src/glu/sgi/libnurbs/internals/quilt.cc src/glu/sgi/libnurbs/internals/quilt.h src/glu/sgi/libnurbs/internals/reader.cc src/glu/sgi/libnurbs/internals/reader.h src/glu/sgi/libnurbs/internals/renderhints.cc src/glu/sgi/libnurbs/internals/renderhints.h src/glu/sgi/libnurbs/internals/simplemath.h src/glu/sgi/libnurbs/internals/slicer.cc src/glu/sgi/libnurbs/internals/slicer.h src/glu/sgi/libnurbs/internals/sorter.cc src/glu/sgi/libnurbs/internals/sorter.h src/glu/sgi/libnurbs/internals/splitarcs.cc src/glu/sgi/libnurbs/internals/subdivider.h src/glu/sgi/libnurbs/internals/tobezier.cc src/glu/sgi/libnurbs/internals/trimline.cc src/glu/sgi/libnurbs/internals/trimline.h src/glu/sgi/libnurbs/internals/trimregion.cc src/glu/sgi/libnurbs/internals/trimregion.h src/glu/sgi/libnurbs/internals/trimvertex.h src/glu/sgi/libnurbs/internals/trimvertpool.cc src/glu/sgi/libnurbs/internals/trimvertpool.h src/glu/sgi/libnurbs/internals/types.h src/glu/sgi/libnurbs/internals/uarray.cc src/glu/sgi/libnurbs/internals/uarray.h src/glu/sgi/libnurbs/internals/varray.cc src/glu/sgi/libnurbs/internals/varray.h src/glu/sgi/libnurbs/nurbtess/definitions.h src/glu/sgi/libnurbs/nurbtess/directedLine.h src/glu/sgi/libnurbs/nurbtess/glimports.h src/glu/sgi/libnurbs/nurbtess/gridWrap.cc src/glu/sgi/libnurbs/nurbtess/gridWrap.h src/glu/sgi/libnurbs/nurbtess/monoChain.cc src/glu/sgi/libnurbs/nurbtess/monoChain.h src/glu/sgi/libnurbs/nurbtess/monoTriangulation.cc src/glu/sgi/libnurbs/nurbtess/monoTriangulation.h src/glu/sgi/libnurbs/nurbtess/mystdio.h src/glu/sgi/libnurbs/nurbtess/mystdlib.h src/glu/sgi/libnurbs/nurbtess/partitionX.cc src/glu/sgi/libnurbs/nurbtess/partitionX.h src/glu/sgi/libnurbs/nurbtess/partitionY.cc src/glu/sgi/libnurbs/nurbtess/partitionY.h src/glu/sgi/libnurbs/nurbtess/polyDBG.h src/glu/sgi/libnurbs/nurbtess/polyUtil.cc src/glu/sgi/libnurbs/nurbtess/polyUtil.h src/glu/sgi/libnurbs/nurbtess/primitiveStream.cc src/glu/sgi/libnurbs/nurbtess/primitiveStream.h src/glu/sgi/libnurbs/nurbtess/quicksort.cc src/glu/sgi/libnurbs/nurbtess/quicksort.h src/glu/sgi/libnurbs/nurbtess/rectBlock.cc src/glu/sgi/libnurbs/nurbtess/rectBlock.h src/glu/sgi/libnurbs/nurbtess/sampleComp.cc src/glu/sgi/libnurbs/nurbtess/sampleComp.h src/glu/sgi/libnurbs/nurbtess/sampleCompBot.cc src/glu/sgi/libnurbs/nurbtess/sampleCompBot.h src/glu/sgi/libnurbs/nurbtess/sampleCompRight.cc src/glu/sgi/libnurbs/nurbtess/sampleCompRight.h src/glu/sgi/libnurbs/nurbtess/sampleCompTop.cc src/glu/sgi/libnurbs/nurbtess/sampleCompTop.h src/glu/sgi/libnurbs/nurbtess/sampleMonoPoly.cc src/glu/sgi/libnurbs/nurbtess/sampleMonoPoly.h src/glu/sgi/libnurbs/nurbtess/sampledLine.cc src/glu/sgi/libnurbs/nurbtess/sampledLine.h src/glu/sgi/libnurbs/nurbtess/searchTree.cc src/glu/sgi/libnurbs/nurbtess/searchTree.h src/glu/sgi/libnurbs/nurbtess/zlassert.h src/glu/sgi/libtess/README src/glu/sgi/libtess/alg-outline src/glu/sgi/libtess/dict-list.h src/glu/sgi/libtess/dict.c src/glu/sgi/libtess/dict.h src/glu/sgi/libtess/geom.c src/glu/sgi/libtess/memalloc.c src/glu/sgi/libtess/memalloc.h src/glu/sgi/libtess/mesh.c src/glu/sgi/libtess/mesh.h src/glu/sgi/libtess/normal.h src/glu/sgi/libtess/priorityq-heap.c src/glu/sgi/libtess/priorityq-heap.h src/glu/sgi/libtess/priorityq-sort.h src/glu/sgi/libtess/priorityq.c src/glu/sgi/libtess/priorityq.h src/glu/sgi/libtess/render.c src/glu/sgi/libtess/render.h src/glu/sgi/libtess/sweep.h src/glu/sgi/libtess/tess.h src/glu/sgi/libtess/tessmono.c src/glu/sgi/libtess/tessmono.h src/glu/sgi/libutil/error.c src/glu/sgi/libutil/glue.c src/glu/sgi/libutil/gluint.h src/glu/sgi/libutil/project.c src/glu/sgi/libutil/registry.c
Diffstat (limited to 'progs')
-rw-r--r--progs/demos/.cvsignore48
-rw-r--r--progs/demos/Windows/all.dsp101
-rw-r--r--progs/demos/Windows/bounce.dsp112
-rw-r--r--progs/demos/Windows/clearspd.dsp112
-rw-r--r--progs/demos/Windows/cubemap.dsp112
-rw-r--r--progs/demos/Windows/demos.dsw782
-rw-r--r--progs/demos/Windows/drawpix.dsp112
-rw-r--r--progs/demos/Windows/fire.dsp112
-rw-r--r--progs/demos/Windows/gears.dsp112
-rw-r--r--progs/demos/Windows/geartrain.dsp112
-rw-r--r--progs/demos/Windows/glinfo.dsp112
-rw-r--r--progs/demos/Windows/gloss.dsp112
-rw-r--r--progs/demos/Windows/gltestperf.dsp112
-rw-r--r--progs/demos/Windows/glutfx.dsp112
-rw-r--r--progs/demos/Windows/ipers.dsp112
-rw-r--r--progs/demos/Windows/isosurf.dsp112
-rw-r--r--progs/demos/Windows/loadbias.dsp112
-rw-r--r--progs/demos/Windows/morph3d.dsp112
-rw-r--r--progs/demos/Windows/multiarb.dsp112
-rw-r--r--progs/demos/Windows/occlude.dsp112
-rw-r--r--progs/demos/Windows/osdemo.dsp112
-rw-r--r--progs/demos/Windows/paltex.dsp112
-rw-r--r--progs/demos/Windows/pixeltex.dsp112
-rw-r--r--progs/demos/Windows/pointblast.dsp112
-rw-r--r--progs/demos/Windows/rain.dsp112
-rw-r--r--progs/demos/Windows/ray.dsp112
-rw-r--r--progs/demos/Windows/readpix.dsp112
-rw-r--r--progs/demos/Windows/reflect.dsp112
-rw-r--r--progs/demos/Windows/renormal.dsp112
-rw-r--r--progs/demos/Windows/shadowtex.dsp112
-rw-r--r--progs/demos/Windows/spectex.dsp112
-rw-r--r--progs/demos/Windows/spriteblast.dsp112
-rw-r--r--progs/demos/Windows/stex3d.dsp112
-rw-r--r--progs/demos/Windows/teapot.dsp112
-rw-r--r--progs/demos/Windows/terrain.dsp112
-rw-r--r--progs/demos/Windows/tessdemo.dsp112
-rw-r--r--progs/demos/Windows/texcyl.dsp112
-rw-r--r--progs/demos/Windows/texdown.dsp112
-rw-r--r--progs/demos/Windows/texenv.dsp112
-rw-r--r--progs/demos/Windows/texobj.dsp112
-rw-r--r--progs/demos/Windows/trispd.dsp112
-rw-r--r--progs/demos/Windows/tunnel.dsp112
-rw-r--r--progs/demos/Windows/tunnel2.dsp112
-rw-r--r--progs/demos/Windows/winpos.dsp112
-rw-r--r--progs/demos/occlude.c234
-rw-r--r--progs/directfb/Makefile36
-rw-r--r--progs/directfb/df_gears.c480
-rw-r--r--progs/directfb/df_morph3d.c1013
-rw-r--r--progs/directfb/df_reflect.c489
-rw-r--r--progs/directfb/multi_window.c240
-rw-r--r--progs/egl/Makefile65
-rw-r--r--progs/egl/demo1.c145
-rw-r--r--progs/egl/demo2.c190
-rw-r--r--progs/egl/demo3.c636
-rw-r--r--progs/egl/eglgears.c475
-rw-r--r--progs/egl/eglinfo.c166
-rw-r--r--progs/fbdev/Makefile53
-rw-r--r--progs/fbdev/glfbdevtest.c524
-rw-r--r--progs/fp/Makefile128
-rw-r--r--progs/fp/point-position.c119
-rw-r--r--progs/fp/tri-abs.c107
-rw-r--r--progs/fp/tri-add.c110
-rw-r--r--progs/fp/tri-cmp.c110
-rw-r--r--progs/fp/tri-cos.c113
-rw-r--r--progs/fp/tri-depth.c111
-rw-r--r--progs/fp/tri-depth2.c116
-rw-r--r--progs/fp/tri-depthwrite.c107
-rw-r--r--progs/fp/tri-depthwrite2.c107
-rw-r--r--progs/fp/tri-dp3.c109
-rw-r--r--progs/fp/tri-dp4.c109
-rw-r--r--progs/fp/tri-dph.c109
-rw-r--r--progs/fp/tri-dst.c109
-rw-r--r--progs/fp/tri-ex2.c110
-rw-r--r--progs/fp/tri-flr.c110
-rw-r--r--progs/fp/tri-fp.c109
-rw-r--r--progs/fp/tri-frc.c111
-rw-r--r--progs/fp/tri-inv.c109
-rw-r--r--progs/fp/tri-kil.c111
-rw-r--r--progs/fp/tri-lg2.c110
-rw-r--r--progs/fp/tri-lit.c111
-rw-r--r--progs/fp/tri-lrp.c109
-rw-r--r--progs/fp/tri-mad.c109
-rw-r--r--progs/fp/tri-max.c109
-rw-r--r--progs/fp/tri-min.c109
-rw-r--r--progs/fp/tri-mov.c102
-rw-r--r--progs/fp/tri-mul.c109
-rw-r--r--progs/fp/tri-param.c114
-rw-r--r--progs/fp/tri-position.c109
-rw-r--r--progs/fp/tri-pow.c109
-rw-r--r--progs/fp/tri-rcp.c110
-rw-r--r--progs/fp/tri-rsq.c110
-rw-r--r--progs/fp/tri-scs.c111
-rw-r--r--progs/fp/tri-sge.c109
-rw-r--r--progs/fp/tri-sge2.c114
-rw-r--r--progs/fp/tri-sin.c114
-rw-r--r--progs/fp/tri-slt.c109
-rw-r--r--progs/fp/tri-sub.c109
-rw-r--r--progs/fp/tri-swz.c109
-rw-r--r--progs/fp/tri-swz2.c109
-rw-r--r--progs/fp/tri-tex.c130
-rw-r--r--progs/fp/tri-xpd.c108
-rw-r--r--progs/ggi/blah2
-rw-r--r--progs/ggi/blat7
-rw-r--r--progs/ggi/box.asc66
-rw-r--r--progs/ggi/cone.asc198
-rw-r--r--progs/ggi/sphere.asc132
-rw-r--r--progs/ggi/torus.asc264
-rw-r--r--progs/ggi/tube.asc396
-rw-r--r--progs/miniglx/Makefile58
-rw-r--r--progs/miniglx/glfbdevtest.c478
-rw-r--r--progs/miniglx/manytex.c382
-rw-r--r--progs/miniglx/miniglxsample.c128
-rw-r--r--progs/miniglx/miniglxtest.c195
-rw-r--r--progs/miniglx/sample_server.c112
-rw-r--r--progs/miniglx/sample_server2.c229
-rw-r--r--progs/miniglx/texline.c268
-rw-r--r--progs/redbook/.cvsignore64
-rw-r--r--progs/redbook/Imakefile221
-rw-r--r--progs/redbook/Windows/redbook.dsw29
-rw-r--r--progs/redbook/Windows/teapots.dsp112
-rw-r--r--progs/samples/.cvsignore45
-rw-r--r--progs/samples/Imakefile101
-rw-r--r--progs/slang/Makefile55
-rw-r--r--progs/slang/README7
-rw-r--r--progs/slang/cltest.c253
-rw-r--r--progs/slang/cltest.txt1615
-rw-r--r--progs/slang/framework.c145
-rw-r--r--progs/slang/framework.h82
-rw-r--r--progs/slang/sotest.c439
-rw-r--r--progs/slang/vstest.c340
-rw-r--r--progs/slang/vstest.txt68
-rw-r--r--progs/slang/windows/vc60/cltest.dsp94
-rw-r--r--progs/slang/windows/vc60/framework.dsp92
-rw-r--r--progs/slang/windows/vc60/slang.dsw74
-rw-r--r--progs/slang/windows/vc60/sotest.dsp90
-rw-r--r--progs/slang/windows/vc60/vstest.dsp93
-rw-r--r--progs/tests/.cvsignore54
-rw-r--r--progs/tests/Makefile158
-rw-r--r--progs/tests/Makefile.win44
-rw-r--r--progs/tests/afsmultiarb.c469
-rw-r--r--progs/tests/antialias.c229
-rw-r--r--progs/tests/api_speed.c146
-rwxr-xr-xprogs/tests/api_speed.py143
-rw-r--r--progs/tests/arbfpspec.c192
-rw-r--r--progs/tests/arbfptest1.c210
-rw-r--r--progs/tests/arbfptexture.c153
-rw-r--r--progs/tests/arbfptrig.c156
-rw-r--r--progs/tests/arbnpot-mipmap.c184
-rw-r--r--progs/tests/arbnpot.c174
-rw-r--r--progs/tests/arbvptest1.c164
-rw-r--r--progs/tests/arbvptest3.c127
-rw-r--r--progs/tests/arbvptorus.c186
-rw-r--r--progs/tests/arbvpwarpmesh.c246
-rw-r--r--progs/tests/auxbuffer.c499
-rw-r--r--progs/tests/blendminmax.c209
-rw-r--r--progs/tests/blendsquare.c178
-rw-r--r--progs/tests/bufferobj.c371
-rw-r--r--progs/tests/bug_3050.c162
-rw-r--r--progs/tests/bug_3101.c128
-rw-r--r--progs/tests/bug_3195.c275
-rw-r--r--progs/tests/copypixrate.c259
-rw-r--r--progs/tests/crossbar.c235
-rw-r--r--progs/tests/cva.c164
-rw-r--r--progs/tests/debugger.c733
-rw-r--r--progs/tests/descrip.mms84
-rw-r--r--progs/tests/dinoshade.c914
-rw-r--r--progs/tests/ext422square.c258
-rw-r--r--progs/tests/fbotest1.c204
-rw-r--r--progs/tests/fbotest2.c199
-rw-r--r--progs/tests/fbotexture.c404
-rw-r--r--progs/tests/floattex.c169
-rw-r--r--progs/tests/fog.c199
-rw-r--r--progs/tests/fogcoord.c102
-rw-r--r--progs/tests/fptest1.c225
-rw-r--r--progs/tests/fptexture.c151
-rw-r--r--progs/tests/getprocaddress.c530
-rw-r--r--progs/tests/getprocaddress.py93
-rw-r--r--progs/tests/interleave.c406
-rw-r--r--progs/tests/invert.c195
-rw-r--r--progs/tests/jkrahntest.c181
-rw-r--r--progs/tests/manytex.c382
-rw-r--r--progs/tests/mipmap_limits.c252
-rw-r--r--progs/tests/multipal.c377
-rw-r--r--progs/tests/multitexarray.c238
-rw-r--r--progs/tests/multiwindow.c169
-rw-r--r--progs/tests/no_s3tc.c97
-rw-r--r--progs/tests/packedpixels.c342
-rw-r--r--progs/tests/pbo.c296
-rw-r--r--progs/tests/prog_parameter.c285
-rw-r--r--progs/tests/projtex.c1028
-rw-r--r--progs/tests/readrate.c285
-rw-r--r--progs/tests/seccolor.c145
-rw-r--r--progs/tests/sharedtex.c438
-rw-r--r--progs/tests/stencil_wrap.c257
-rw-r--r--progs/tests/stencilwrap.c281
-rw-r--r--progs/tests/subtexrate.c350
-rw-r--r--progs/tests/tex1d.c139
-rw-r--r--progs/tests/texcmp.c414
-rw-r--r--progs/tests/texcompress2.c273
-rw-r--r--progs/tests/texfilt.c398
-rw-r--r--progs/tests/texgenmix.c640
-rw-r--r--progs/tests/texline.c269
-rw-r--r--progs/tests/texobjshare.c219
-rw-r--r--progs/tests/texrect.c360
-rw-r--r--progs/tests/texwrap.c304
-rw-r--r--progs/tests/vao-01.c177
-rw-r--r--progs/tests/vao-02.c205
-rw-r--r--progs/tests/vparray.c294
-rw-r--r--progs/tests/vpeval.c231
-rw-r--r--progs/tests/vptest1.c170
-rw-r--r--progs/tests/vptest2.c151
-rw-r--r--progs/tests/vptest3.c120
-rw-r--r--progs/tests/vptorus.c174
-rw-r--r--progs/tests/vpwarpmesh.c236
-rw-r--r--progs/tests/yuvrect.c193
-rw-r--r--progs/tests/yuvsquare.c232
-rw-r--r--progs/tests/zreaddraw.c116
-rw-r--r--progs/tools/trace/Makefile30
-rw-r--r--progs/tools/trace/README23
-rwxr-xr-xprogs/tools/trace/gltrace82
-rw-r--r--progs/tools/trace/gltrace.py189
-rw-r--r--progs/tools/trace/gltrace_support.cc190
-rw-r--r--progs/tools/trace/gltrace_support.h65
-rw-r--r--progs/trivial/Makefile136
-rw-r--r--progs/trivial/clear.c126
-rw-r--r--progs/trivial/line-clip.c140
-rw-r--r--progs/trivial/line-cull.c136
-rw-r--r--progs/trivial/line-userclip-clip.c142
-rw-r--r--progs/trivial/line-userclip-nop-clip.c142
-rw-r--r--progs/trivial/line-userclip-nop.c142
-rw-r--r--progs/trivial/line-userclip.c142
-rw-r--r--progs/trivial/line.c140
-rw-r--r--progs/trivial/lineloop-clip.c136
-rw-r--r--progs/trivial/lineloop.c136
-rw-r--r--progs/trivial/point-clip.c138
-rw-r--r--progs/trivial/point-param.c145
-rw-r--r--progs/trivial/point-wide.c140
-rw-r--r--progs/trivial/point.c138
-rw-r--r--progs/trivial/poly-flat.c140
-rw-r--r--progs/trivial/poly-unfilled.c139
-rw-r--r--progs/trivial/poly.c138
-rw-r--r--progs/trivial/quad-clip-all-vertices.c138
-rw-r--r--progs/trivial/quad-clip-nearplane.c138
-rw-r--r--progs/trivial/quad-clip.c138
-rw-r--r--progs/trivial/quad-degenerate.c143
-rw-r--r--progs/trivial/quad-flat.c148
-rw-r--r--progs/trivial/quad-offset-factor.c167
-rw-r--r--progs/trivial/quad-offset-unfilled.c167
-rw-r--r--progs/trivial/quad-offset-units.c166
-rw-r--r--progs/trivial/quad-tex-2d.c169
-rw-r--r--progs/trivial/quad-tex-3d.c177
-rw-r--r--progs/trivial/quad-tex-pbo.c181
-rw-r--r--progs/trivial/quad-unfilled.c139
-rw-r--r--progs/trivial/quad.c138
-rw-r--r--progs/trivial/quads.c156
-rw-r--r--progs/trivial/quadstrip-flat.c150
-rw-r--r--progs/trivial/quadstrip.c144
-rw-r--r--progs/trivial/tri-blend.c144
-rw-r--r--progs/trivial/tri-clip.c137
-rw-r--r--progs/trivial/tri-cull.c136
-rw-r--r--progs/trivial/tri-dlist.c150
-rw-r--r--progs/trivial/tri-edgeflag.c141
-rw-r--r--progs/trivial/tri-flat-clip.c137
-rw-r--r--progs/trivial/tri-flat.c137
-rw-r--r--progs/trivial/tri-tex-3d.c170
-rw-r--r--progs/trivial/tri-unfilled-clip.c137
-rw-r--r--progs/trivial/tri-unfilled-smooth.c150
-rw-r--r--progs/trivial/tri-unfilled-userclip.c141
-rw-r--r--progs/trivial/tri-unfilled.c138
-rw-r--r--progs/trivial/tri-userclip.c140
-rw-r--r--progs/trivial/tri.c136
-rw-r--r--progs/trivial/tristrip-clip.c138
-rw-r--r--progs/trivial/tristrip.c138
-rw-r--r--progs/trivial/vp-array.c117
-rw-r--r--progs/trivial/vp-clip.c102
-rw-r--r--progs/trivial/vp-line-clip.c116
-rw-r--r--progs/trivial/vp-tri.c104
-rw-r--r--progs/trivial/vp-unfilled.c104
-rw-r--r--progs/util/README2
-rw-r--r--progs/util/descrip.mms42
-rw-r--r--progs/util/glstate.c6
-rw-r--r--progs/util/glstate.h6
-rw-r--r--progs/util/imagesgi.cpp369
-rw-r--r--progs/util/sampleMakefile6
-rw-r--r--progs/vp/Makefile53
-rw-r--r--progs/vp/abs.txt7
-rw-r--r--progs/vp/add.txt6
-rw-r--r--progs/vp/arl.txt9
-rw-r--r--progs/vp/dp3.txt5
-rw-r--r--progs/vp/dp4.txt5
-rw-r--r--progs/vp/dph.txt5
-rw-r--r--progs/vp/dst.txt5
-rw-r--r--progs/vp/ex2.txt6
-rw-r--r--progs/vp/flr.txt6
-rw-r--r--progs/vp/frc.txt6
-rw-r--r--progs/vp/lg2.txt6
-rw-r--r--progs/vp/lit.txt6
-rw-r--r--progs/vp/mad.txt5
-rw-r--r--progs/vp/max.txt5
-rw-r--r--progs/vp/min.txt5
-rw-r--r--progs/vp/mov.txt5
-rw-r--r--progs/vp/mul.txt5
-rw-r--r--progs/vp/pow.txt5
-rw-r--r--progs/vp/rcp.txt7
-rw-r--r--progs/vp/rsq.txt7
-rw-r--r--progs/vp/sge.txt5
-rw-r--r--progs/vp/slt.txt5
-rw-r--r--progs/vp/sub.txt5
-rw-r--r--progs/vp/swz.txt5
-rw-r--r--progs/vp/swz2.txt5
-rw-r--r--progs/vp/vp-tris.c216
-rw-r--r--progs/vp/xpd.txt5
-rw-r--r--progs/xdemos/.cvsignore16
313 files changed, 52267 insertions, 10 deletions
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/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/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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+#include <GL/glut.h>
+#include <GL/glext.h>
+
+
+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/directfb/Makefile b/progs/directfb/Makefile
new file mode 100644
index 00000000000..53b100a18d9
--- /dev/null
+++ b/progs/directfb/Makefile
@@ -0,0 +1,36 @@
+# progs/directfb/Makefile
+
+TOP = ../..
+include $(TOP)/configs/current
+
+
+INCDIR = $(TOP)/include -I$(TOP)/progs
+
+LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME)
+
+CFLAGS += $(shell pkg-config --cflags directfb)
+APP_LIB_DEPS += $(shell pkg-config --libs directfb)
+
+PROGS = df_gears \
+ df_reflect \
+ df_morph3d \
+ multi_window
+
+##### 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/directfb/df_gears.c b/progs/directfb/df_gears.c
new file mode 100644
index 00000000000..c480767bd33
--- /dev/null
+++ b/progs/directfb/df_gears.c
@@ -0,0 +1,480 @@
+/*
+ (c) Copyright 2001 convergence integrated media GmbH.
+ All rights reserved.
+
+ Written by Denis Oliver Kropp <[email protected]> and
+ Andreas Hundt <[email protected]>.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <math.h>
+
+#include <directfb.h>
+#include <directfbgl.h>
+
+#include <GL/gl.h>
+
+
+/* the super interface */
+IDirectFB *dfb;
+
+/* the primary surface (surface of primary layer) */
+IDirectFBSurface *primary;
+
+/* the GL context */
+IDirectFBGL *primary_gl;
+
+/* our font */
+IDirectFBFont *font;
+
+/* event buffer */
+IDirectFBEventBuffer *events;
+
+/* macro for a safe call to DirectFB functions */
+#define DFBCHECK(x...) \
+ { \
+ err = x; \
+ if (err != DFB_OK) { \
+ fprintf( stderr, "%s <%d>:\n\t", __FILE__, __LINE__ ); \
+ DirectFBErrorFatal( #x, err ); \
+ } \
+ }
+
+static int screen_width, screen_height;
+
+static unsigned long T0 = 0;
+static GLint Frames = 0;
+static GLfloat fps = 0;
+
+static inline unsigned long get_millis()
+{
+ struct timeval tv;
+
+ gettimeofday (&tv, NULL);
+ return (tv.tv_sec * 1000 + tv.tv_usec / 1000);
+}
+
+
+#ifndef M_PI
+#define M_PI 3.14159265
+#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 GLfloat view_rotx = 20.0, view_roty = 30.0, view_rotz = 0.0;
+static GLfloat inc_rotx = 0, inc_roty = 0, inc_rotz = 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();
+}
+
+/* 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<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));
+ }
+ }
+}
+
+int main( int argc, char *argv[] )
+{
+ int quit = 0;
+ DFBResult err;
+ DFBSurfaceDescription dsc;
+
+ DFBCHECK(DirectFBInit( &argc, &argv ));
+
+ /* create the super interface */
+ DFBCHECK(DirectFBCreate( &dfb ));
+
+ /* create an event buffer for all devices with these caps */
+ DFBCHECK(dfb->CreateInputEventBuffer( dfb, DICAPS_KEYS | DICAPS_AXES,
+ DFB_FALSE, &events ));
+
+ /* set our cooperative level to DFSCL_FULLSCREEN
+ for exclusive access to the primary layer */
+ dfb->SetCooperativeLevel( dfb, DFSCL_FULLSCREEN );
+
+ /* get the primary surface, i.e. the surface of the
+ primary layer we have exclusive access to */
+ dsc.flags = DSDESC_CAPS;
+ dsc.caps = DSCAPS_PRIMARY | DSCAPS_DOUBLE;
+
+ DFBCHECK(dfb->CreateSurface( dfb, &dsc, &primary ));
+
+ /* get the size of the surface and fill it */
+ DFBCHECK(primary->GetSize( primary, &screen_width, &screen_height ));
+ DFBCHECK(primary->FillRectangle( primary, 0, 0,
+ screen_width, screen_height ));
+ primary->Flip( primary, NULL, 0 );
+
+ /* create the default font and set it */
+ DFBCHECK(dfb->CreateFont( dfb, NULL, NULL, &font ));
+ DFBCHECK(primary->SetFont( primary, font ));
+
+ /* get the GL context */
+ DFBCHECK(primary->GetGL( primary, &primary_gl ));
+
+ DFBCHECK(primary_gl->Lock( primary_gl ));
+
+ init(argc, argv);
+ reshape(screen_width, screen_height);
+
+ DFBCHECK(primary_gl->Unlock( primary_gl ));
+
+ T0 = get_millis();
+
+ while (!quit) {
+ DFBInputEvent evt;
+ unsigned long t;
+
+ DFBCHECK(primary_gl->Lock( primary_gl ));
+
+ draw();
+
+ DFBCHECK(primary_gl->Unlock( primary_gl ));
+
+ if (fps) {
+ char buf[64];
+
+ snprintf(buf, 64, "%4.1f FPS\n", fps);
+
+ primary->SetColor( primary, 0xff, 0, 0, 0xff );
+ primary->DrawString( primary, buf, -1, screen_width - 5, 5, DSTF_TOPRIGHT );
+ }
+
+ primary->Flip( primary, NULL, 0 );
+ Frames++;
+
+
+ t = get_millis();
+ if (t - T0 >= 2000) {
+ GLfloat seconds = (t - T0) / 1000.0;
+
+ fps = Frames / seconds;
+
+ T0 = t;
+ Frames = 0;
+ }
+
+
+ while (events->GetEvent( events, DFB_EVENT(&evt) ) == DFB_OK) {
+ switch (evt.type) {
+ case DIET_KEYPRESS:
+ switch (evt.key_symbol) {
+ case DIKS_ESCAPE:
+ quit = 1;
+ break;
+ case DIKS_CURSOR_UP:
+ inc_rotx = 5.0;
+ break;
+ case DIKS_CURSOR_DOWN:
+ inc_rotx = -5.0;
+ break;
+ case DIKS_CURSOR_LEFT:
+ inc_roty = 5.0;
+ break;
+ case DIKS_CURSOR_RIGHT:
+ inc_roty = -5.0;
+ break;
+ case DIKS_PAGE_UP:
+ inc_rotz = 5.0;
+ break;
+ case DIKS_PAGE_DOWN:
+ inc_rotz = -5.0;
+ break;
+ default:
+ ;
+ }
+ break;
+ case DIET_KEYRELEASE:
+ switch (evt.key_symbol) {
+ case DIKS_CURSOR_UP:
+ inc_rotx = 0;
+ break;
+ case DIKS_CURSOR_DOWN:
+ inc_rotx = 0;
+ break;
+ case DIKS_CURSOR_LEFT:
+ inc_roty = 0;
+ break;
+ case DIKS_CURSOR_RIGHT:
+ inc_roty = 0;
+ break;
+ case DIKS_PAGE_UP:
+ inc_rotz = 0;
+ break;
+ case DIKS_PAGE_DOWN:
+ inc_rotz = 0;
+ break;
+ default:
+ ;
+ }
+ break;
+ case DIET_AXISMOTION:
+ if (evt.flags & DIEF_AXISREL) {
+ switch (evt.axis) {
+ case DIAI_X:
+ view_roty += evt.axisrel / 2.0;
+ break;
+ case DIAI_Y:
+ view_rotx += evt.axisrel / 2.0;
+ break;
+ case DIAI_Z:
+ view_rotz += evt.axisrel / 2.0;
+ break;
+ default:
+ ;
+ }
+ }
+ break;
+ default:
+ ;
+ }
+ }
+
+ angle += 2.0;
+
+ view_rotx += inc_rotx;
+ view_roty += inc_roty;
+ view_rotz += inc_rotz;
+ }
+
+ /* release our interfaces to shutdown DirectFB */
+ primary_gl->Release( primary_gl );
+ primary->Release( primary );
+ font->Release( font );
+ events->Release( events );
+ dfb->Release( dfb );
+
+ return 0;
+}
+
diff --git a/progs/directfb/df_morph3d.c b/progs/directfb/df_morph3d.c
new file mode 100644
index 00000000000..2730fa61569
--- /dev/null
+++ b/progs/directfb/df_morph3d.c
@@ -0,0 +1,1013 @@
+/*
+ (c) Copyright 2001 convergence integrated media GmbH.
+ All rights reserved.
+
+ Written by Denis Oliver Kropp <[email protected]> and
+ Andreas Hundt <[email protected]>.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/*-
+ * 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
+ *
+ * and
+ *
+ * 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.
+- 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 <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <math.h>
+#include <unistd.h>
+
+#include <directfb.h>
+#include <directfbgl.h>
+
+#include <GL/gl.h>
+
+
+/* the super interface */
+IDirectFB *dfb;
+
+/* the primary surface (surface of primary layer) */
+IDirectFBSurface *primary;
+
+/* the GL context */
+IDirectFBGL *primary_gl;
+
+/* our font */
+IDirectFBFont *font;
+
+/* event buffer */
+IDirectFBEventBuffer *events;
+
+/* macro for a safe call to DirectFB functions */
+#define DFBCHECK(x...) \
+ { \
+ err = x; \
+ if (err != DFB_OK) { \
+ fprintf( stderr, "%s <%d>:\n\t", __FILE__, __LINE__ ); \
+ DirectFBErrorFatal( #x, err ); \
+ } \
+ }
+
+static int screen_width, screen_height;
+
+static unsigned long T0 = 0;
+static GLint Frames = 0;
+static GLfloat fps = 0;
+
+static inline unsigned long get_millis()
+{
+ struct timeval tv;
+
+ gettimeofday (&tv, NULL);
+ return (tv.tv_sec * 1000 + tv.tv_usec / 1000);
+}
+
+
+
+#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 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<Ri; Ti++) { \
+ Xf=(float)(Ri-Ti)*Ax + (float)Ti*Bx; \
+ Yf=Vr+(float)(Ri-Ti)*Ay + (float)Ti*Ay; \
+ Xa=Xf+0.001; Yb=Yf+0.001; \
+ Factor=1-(((Xf2=sqr(Xf))+(Yf2=sqr(Yf)))*AmpVr2); \
+ Factor1=1-((sqr(Xa)+Yf2)*AmpVr2); \
+ Factor2=1-((Xf2+sqr(Yb))*AmpVr2); \
+ VertX=Factor*Xf; VertY=Factor*Yf; VertZ=Factor*Zf; \
+ NeiAX=Factor1*Xa-VertX; NeiAY=Factor1*Yf-VertY; NeiAZ=Factor1*Zf-VertZ; \
+ NeiBX=Factor2*Xf-VertX; NeiBY=Factor2*Yb-VertY; NeiBZ=Factor2*Zf-VertZ; \
+ glNormal3f(VectMul(NeiAX, NeiAY, NeiAZ, NeiBX, NeiBY, NeiBZ)); \
+ glVertex3f(VertX, VertY, VertZ); \
+ \
+ Xf=(float)(Ri-Ti-1)*Ax + (float)Ti*Bx; \
+ Yf=Vr+(float)(Ri-Ti-1)*Ay + (float)Ti*Ay; \
+ Xa=Xf+0.001; Yb=Yf+0.001; \
+ Factor=1-(((Xf2=sqr(Xf))+(Yf2=sqr(Yf)))*AmpVr2); \
+ Factor1=1-((sqr(Xa)+Yf2)*AmpVr2); \
+ Factor2=1-((Xf2+sqr(Yb))*AmpVr2); \
+ VertX=Factor*Xf; VertY=Factor*Yf; VertZ=Factor*Zf; \
+ NeiAX=Factor1*Xa-VertX; NeiAY=Factor1*Yf-VertY; NeiAZ=Factor1*Zf-VertZ; \
+ NeiBX=Factor2*Xf-VertX; NeiBY=Factor2*Yb-VertY; NeiBZ=Factor2*Zf-VertZ; \
+ glNormal3f(VectMul(NeiAX, NeiAY, NeiAZ, NeiBX, NeiBY, NeiBZ)); \
+ glVertex3f(VertX, VertY, VertZ); \
+ \
+ } \
+ Xf=(float)Ri*Bx; \
+ Yf=Vr+(float)Ri*Ay; \
+ Xa=Xf+0.001; Yb=Yf+0.001; \
+ Factor=1-(((Xf2=sqr(Xf))+(Yf2=sqr(Yf)))*AmpVr2); \
+ Factor1=1-((sqr(Xa)+Yf2)*AmpVr2); \
+ Factor2=1-((Xf2+sqr(Yb))*AmpVr2); \
+ VertX=Factor*Xf; VertY=Factor*Yf; VertZ=Factor*Zf; \
+ NeiAX=Factor1*Xa-VertX; NeiAY=Factor1*Yf-VertY; NeiAZ=Factor1*Zf-VertZ; \
+ NeiBX=Factor2*Xf-VertX; NeiBY=Factor2*Yb-VertY; NeiBZ=Factor2*Zf-VertZ; \
+ glNormal3f(VectMul(NeiAX, NeiAY, NeiAZ, NeiBX, NeiBY, NeiBZ)); \
+ glVertex3f(VertX, VertY, VertZ); \
+ glEnd(); \
+ } \
+}
+
+#define SQUARE(Edge, Amp, Divisions, Z) \
+{ \
+ int Xi,Yi; \
+ GLfloat Xf,Yf,Y,Xf2,Yf2,Y2,Xa,Yb; \
+ GLfloat Factor,Factor1,Factor2; \
+ GLfloat VertX,VertY,VertZ,NeiAX,NeiAY,NeiAZ,NeiBX,NeiBY,NeiBZ; \
+ GLfloat Zf=(Edge)*(Z); \
+ GLfloat AmpVr2=(Amp)/sqr((Edge)*SQRT2/2); \
+ \
+ for (Yi=0; Yi<(Divisions); Yi++) { \
+ Yf=-((Edge)/2.0) + ((float)Yi)/(Divisions)*(Edge); \
+ Yf2=sqr(Yf); \
+ Y=Yf+1.0/(Divisions)*(Edge); \
+ Y2=sqr(Y); \
+ glBegin(GL_QUAD_STRIP); \
+ for (Xi=0; Xi<=(Divisions); Xi++) { \
+ Xf=-((Edge)/2.0) + ((float)Xi)/(Divisions)*(Edge); \
+ Xf2=sqr(Xf); \
+ \
+ Xa=Xf+0.001; Yb=Y+0.001; \
+ Factor=1-((Xf2+Y2)*AmpVr2); \
+ Factor1=1-((sqr(Xa)+Y2)*AmpVr2); \
+ Factor2=1-((Xf2+sqr(Yb))*AmpVr2); \
+ VertX=Factor*Xf; VertY=Factor*Y; VertZ=Factor*Zf; \
+ NeiAX=Factor1*Xa-VertX; NeiAY=Factor1*Y-VertY; NeiAZ=Factor1*Zf-VertZ; \
+ NeiBX=Factor2*Xf-VertX; NeiBY=Factor2*Yb-VertY; NeiBZ=Factor2*Zf-VertZ; \
+ glNormal3f(VectMul(NeiAX, NeiAY, NeiAZ, NeiBX, NeiBY, NeiBZ)); \
+ glVertex3f(VertX, VertY, VertZ); \
+ \
+ Xa=Xf+0.001; Yb=Yf+0.001; \
+ Factor=1-((Xf2+Yf2)*AmpVr2); \
+ Factor1=1-((sqr(Xa)+Yf2)*AmpVr2); \
+ Factor2=1-((Xf2+sqr(Yb))*AmpVr2); \
+ VertX=Factor*Xf; VertY=Factor*Yf; VertZ=Factor*Zf; \
+ NeiAX=Factor1*Xa-VertX; NeiAY=Factor1*Yf-VertY; NeiAZ=Factor1*Zf-VertZ; \
+ NeiBX=Factor2*Xf-VertX; NeiBY=Factor2*Yb-VertY; NeiBZ=Factor2*Zf-VertZ; \
+ glNormal3f(VectMul(NeiAX, NeiAY, NeiAZ, NeiBX, NeiBY, NeiBZ)); \
+ glVertex3f(VertX, VertY, VertZ); \
+ } \
+ glEnd(); \
+ } \
+}
+
+#define PENTAGON(Edge, Amp, Divisions, Z) \
+{ \
+ int Ri,Ti,Fi; \
+ GLfloat Xf,Yf,Xa,Yb,Xf2,Yf2; \
+ GLfloat x[6],y[6]; \
+ GLfloat Factor,Factor1,Factor2; \
+ GLfloat VertX,VertY,VertZ,NeiAX,NeiAY,NeiAZ,NeiBX,NeiBY,NeiBZ; \
+ GLfloat Zf=(Edge)*(Z); \
+ GLfloat AmpVr2=(Amp)/sqr((Edge)*cossec36_2); \
+ \
+ for(Fi=0;Fi<6;Fi++) { \
+ x[Fi]=-cos( Fi*2*Pi/5 + Pi/10 )/(Divisions)*cossec36_2*(Edge); \
+ y[Fi]=sin( Fi*2*Pi/5 + Pi/10 )/(Divisions)*cossec36_2*(Edge); \
+ } \
+ \
+ for (Ri=1; Ri<=(Divisions); Ri++) { \
+ for (Fi=0; Fi<5; Fi++) { \
+ glBegin(GL_TRIANGLE_STRIP); \
+ for (Ti=0; Ti<Ri; Ti++) { \
+ Xf=(float)(Ri-Ti)*x[Fi] + (float)Ti*x[Fi+1]; \
+ Yf=(float)(Ri-Ti)*y[Fi] + (float)Ti*y[Fi+1]; \
+ Xa=Xf+0.001; Yb=Yf+0.001; \
+ Factor=1-(((Xf2=sqr(Xf))+(Yf2=sqr(Yf)))*AmpVr2); \
+ Factor1=1-((sqr(Xa)+Yf2)*AmpVr2); \
+ Factor2=1-((Xf2+sqr(Yb))*AmpVr2); \
+ VertX=Factor*Xf; VertY=Factor*Yf; VertZ=Factor*Zf; \
+ NeiAX=Factor1*Xa-VertX; NeiAY=Factor1*Yf-VertY; NeiAZ=Factor1*Zf-VertZ; \
+ NeiBX=Factor2*Xf-VertX; NeiBY=Factor2*Yb-VertY; NeiBZ=Factor2*Zf-VertZ; \
+ glNormal3f(VectMul(NeiAX, NeiAY, NeiAZ, NeiBX, NeiBY, NeiBZ)); \
+ glVertex3f(VertX, VertY, VertZ); \
+ \
+ Xf=(float)(Ri-Ti-1)*x[Fi] + (float)Ti*x[Fi+1]; \
+ Yf=(float)(Ri-Ti-1)*y[Fi] + (float)Ti*y[Fi+1]; \
+ Xa=Xf+0.001; Yb=Yf+0.001; \
+ Factor=1-(((Xf2=sqr(Xf))+(Yf2=sqr(Yf)))*AmpVr2); \
+ Factor1=1-((sqr(Xa)+Yf2)*AmpVr2); \
+ Factor2=1-((Xf2+sqr(Yb))*AmpVr2); \
+ VertX=Factor*Xf; VertY=Factor*Yf; VertZ=Factor*Zf; \
+ NeiAX=Factor1*Xa-VertX; NeiAY=Factor1*Yf-VertY; NeiAZ=Factor1*Zf-VertZ; \
+ NeiBX=Factor2*Xf-VertX; NeiBY=Factor2*Yb-VertY; NeiBZ=Factor2*Zf-VertZ; \
+ glNormal3f(VectMul(NeiAX, NeiAY, NeiAZ, NeiBX, NeiBY, NeiBZ)); \
+ glVertex3f(VertX, VertY, VertZ); \
+ \
+ } \
+ Xf=(float)Ri*x[Fi+1]; \
+ Yf=(float)Ri*y[Fi+1]; \
+ Xa=Xf+0.001; Yb=Yf+0.001; \
+ Factor=1-(((Xf2=sqr(Xf))+(Yf2=sqr(Yf)))*AmpVr2); \
+ Factor1=1-((sqr(Xa)+Yf2)*AmpVr2); \
+ Factor2=1-((Xf2+sqr(Yb))*AmpVr2); \
+ VertX=Factor*Xf; VertY=Factor*Yf; VertZ=Factor*Zf; \
+ NeiAX=Factor1*Xa-VertX; NeiAY=Factor1*Yf-VertY; NeiAZ=Factor1*Zf-VertZ; \
+ NeiBX=Factor2*Xf-VertX; NeiBY=Factor2*Yb-VertY; NeiBZ=Factor2*Zf-VertZ; \
+ glNormal3f(VectMul(NeiAX, NeiAY, NeiAZ, NeiBX, NeiBY, NeiBZ)); \
+ glVertex3f(VertX, VertY, VertZ); \
+ glEnd(); \
+ } \
+ } \
+}
+
+static void draw_tetra( void )
+{
+ GLuint list;
+
+ list = glGenLists( 1 );
+ glNewList( list, GL_COMPILE );
+ TRIANGLE(2,seno,edgedivisions,0.5/SQRT6);
+ glEndList();
+
+ glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[0]);
+ glCallList(list);
+ glPushMatrix();
+ glRotatef(180,0,0,1);
+ glRotatef(-tetraangle,1,0,0);
+ glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[1]);
+ glCallList(list);
+ glPopMatrix();
+ glPushMatrix();
+ glRotatef(180,0,1,0);
+ glRotatef(-180+tetraangle,0.5,SQRT3/2,0);
+ glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[2]);
+ glCallList(list);
+ glPopMatrix();
+ glRotatef(180,0,1,0);
+ glRotatef(-180+tetraangle,0.5,-SQRT3/2,0);
+ glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[3]);
+ glCallList(list);
+
+ glDeleteLists(list,1);
+}
+
+static void draw_cube( void )
+{
+ GLuint list;
+
+ list = glGenLists( 1 );
+ glNewList( list, GL_COMPILE );
+ SQUARE(2, seno, edgedivisions, 0.5)
+ glEndList();
+
+ glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[0]);
+ glCallList(list);
+ glRotatef(cubeangle,1,0,0);
+ glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[1]);
+ glCallList(list);
+ glRotatef(cubeangle,1,0,0);
+ glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[2]);
+ glCallList(list);
+ glRotatef(cubeangle,1,0,0);
+ glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[3]);
+ glCallList(list);
+ glRotatef(cubeangle,0,1,0);
+ glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[4]);
+ glCallList(list);
+ glRotatef(2*cubeangle,0,1,0);
+ glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[5]);
+ glCallList(list);
+
+ glDeleteLists(list,1);
+}
+
+static void draw_octa( void )
+{
+ GLuint list;
+
+ list = glGenLists( 1 );
+ glNewList( list, GL_COMPILE );
+ TRIANGLE(2,seno,edgedivisions,1/SQRT6);
+ glEndList();
+
+ glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[0]);
+ glCallList(list);
+ glPushMatrix();
+ glRotatef(180,0,0,1);
+ glRotatef(-180+octaangle,1,0,0);
+ glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[1]);
+ glCallList(list);
+ glPopMatrix();
+ glPushMatrix();
+ glRotatef(180,0,1,0);
+ glRotatef(-octaangle,0.5,SQRT3/2,0);
+ glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[2]);
+ glCallList(list);
+ glPopMatrix();
+ glPushMatrix();
+ glRotatef(180,0,1,0);
+ glRotatef(-octaangle,0.5,-SQRT3/2,0);
+ glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[3]);
+ glCallList(list);
+ glPopMatrix();
+ glRotatef(180,1,0,0);
+ glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[4]);
+ glCallList(list);
+ glPushMatrix();
+ glRotatef(180,0,0,1);
+ glRotatef(-180+octaangle,1,0,0);
+ glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[5]);
+ glCallList(list);
+ glPopMatrix();
+ glPushMatrix();
+ glRotatef(180,0,1,0);
+ glRotatef(-octaangle,0.5,SQRT3/2,0);
+ glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[6]);
+ glCallList(list);
+ glPopMatrix();
+ glRotatef(180,0,1,0);
+ glRotatef(-octaangle,0.5,-SQRT3/2,0);
+ glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[7]);
+ glCallList(list);
+
+ glDeleteLists(list,1);
+}
+
+static void draw_dodeca( void )
+{
+ GLuint list;
+
+#define TAU ((SQRT5+1)/2)
+
+ list = glGenLists( 1 );
+ glNewList( list, GL_COMPILE );
+ PENTAGON(1,seno,edgedivisions,sqr(TAU) * sqrt((TAU+2)/5) / 2);
+ glEndList();
+
+ glPushMatrix();
+ glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[0]);
+ glCallList(list);
+ glRotatef(180,0,0,1);
+ glPushMatrix();
+ glRotatef(-dodecaangle,1,0,0);
+ glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[1]);
+ glCallList(list);
+ glPopMatrix();
+ glPushMatrix();
+ glRotatef(-dodecaangle,cos72,sin72,0);
+ glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[2]);
+ glCallList(list);
+ glPopMatrix();
+ glPushMatrix();
+ glRotatef(-dodecaangle,cos72,-sin72,0);
+ glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[3]);
+ glCallList(list);
+ glPopMatrix();
+ glPushMatrix();
+ glRotatef(dodecaangle,cos36,-sin36,0);
+ glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[4]);
+ glCallList(list);
+ glPopMatrix();
+ glRotatef(dodecaangle,cos36,sin36,0);
+ glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[5]);
+ glCallList(list);
+ glPopMatrix();
+ glRotatef(180,1,0,0);
+ glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[6]);
+ glCallList(list);
+ glRotatef(180,0,0,1);
+ glPushMatrix();
+ glRotatef(-dodecaangle,1,0,0);
+ glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[7]);
+ glCallList(list);
+ glPopMatrix();
+ glPushMatrix();
+ glRotatef(-dodecaangle,cos72,sin72,0);
+ glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[8]);
+ glCallList(list);
+ glPopMatrix();
+ glPushMatrix();
+ glRotatef(-dodecaangle,cos72,-sin72,0);
+ glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[9]);
+ glCallList(list);
+ glPopMatrix();
+ glPushMatrix();
+ glRotatef(dodecaangle,cos36,-sin36,0);
+ glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[10]);
+ glCallList(list);
+ glPopMatrix();
+ glRotatef(dodecaangle,cos36,sin36,0);
+ glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[11]);
+ glCallList(list);
+
+ glDeleteLists(list,1);
+}
+
+static void draw_ico( void )
+{
+ GLuint list;
+
+ list = glGenLists( 1 );
+ glNewList( list, GL_COMPILE );
+ TRIANGLE(1.5,seno,edgedivisions,(3*SQRT3+SQRT15)/12);
+ glEndList();
+
+ glPushMatrix();
+
+ glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[0]);
+ glCallList(list);
+ glPushMatrix();
+ glRotatef(180,0,0,1);
+ glRotatef(-icoangle,1,0,0);
+ glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[1]);
+ glCallList(list);
+ glPushMatrix();
+ glRotatef(180,0,1,0);
+ glRotatef(-180+icoangle,0.5,SQRT3/2,0);
+ glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[2]);
+ glCallList(list);
+ glPopMatrix();
+ glRotatef(180,0,1,0);
+ glRotatef(-180+icoangle,0.5,-SQRT3/2,0);
+ glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[3]);
+ glCallList(list);
+ glPopMatrix();
+ glPushMatrix();
+ glRotatef(180,0,1,0);
+ glRotatef(-180+icoangle,0.5,SQRT3/2,0);
+ glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[4]);
+ glCallList(list);
+ glPushMatrix();
+ glRotatef(180,0,1,0);
+ glRotatef(-180+icoangle,0.5,SQRT3/2,0);
+ glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[5]);
+ glCallList(list);
+ glPopMatrix();
+ glRotatef(180,0,0,1);
+ glRotatef(-icoangle,1,0,0);
+ glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[6]);
+ glCallList(list);
+ glPopMatrix();
+ glRotatef(180,0,1,0);
+ glRotatef(-180+icoangle,0.5,-SQRT3/2,0);
+ glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[7]);
+ glCallList(list);
+ glPushMatrix();
+ glRotatef(180,0,1,0);
+ glRotatef(-180+icoangle,0.5,-SQRT3/2,0);
+ glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[8]);
+ glCallList(list);
+ glPopMatrix();
+ glRotatef(180,0,0,1);
+ glRotatef(-icoangle,1,0,0);
+ glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[9]);
+ glCallList(list);
+ glPopMatrix();
+ glRotatef(180,1,0,0);
+ glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[10]);
+ glCallList(list);
+ glPushMatrix();
+ glRotatef(180,0,0,1);
+ glRotatef(-icoangle,1,0,0);
+ glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[11]);
+ glCallList(list);
+ glPushMatrix();
+ glRotatef(180,0,1,0);
+ glRotatef(-180+icoangle,0.5,SQRT3/2,0);
+ glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[12]);
+ glCallList(list);
+ glPopMatrix();
+ glRotatef(180,0,1,0);
+ glRotatef(-180+icoangle,0.5,-SQRT3/2,0);
+ glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[13]);
+ glCallList(list);
+ glPopMatrix();
+ glPushMatrix();
+ glRotatef(180,0,1,0);
+ glRotatef(-180+icoangle,0.5,SQRT3/2,0);
+ glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[14]);
+ glCallList(list);
+ glPushMatrix();
+ glRotatef(180,0,1,0);
+ glRotatef(-180+icoangle,0.5,SQRT3/2,0);
+ glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[15]);
+ glCallList(list);
+ glPopMatrix();
+ glRotatef(180,0,0,1);
+ glRotatef(-icoangle,1,0,0);
+ glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[16]);
+ glCallList(list);
+ glPopMatrix();
+ glRotatef(180,0,1,0);
+ glRotatef(-180+icoangle,0.5,-SQRT3/2,0);
+ glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[17]);
+ glCallList(list);
+ glPushMatrix();
+ glRotatef(180,0,1,0);
+ glRotatef(-180+icoangle,0.5,-SQRT3/2,0);
+ glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[18]);
+ glCallList(list);
+ glPopMatrix();
+ glRotatef(180,0,0,1);
+ glRotatef(-icoangle,1,0,0);
+ glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[19]);
+ glCallList(list);
+
+ glDeleteLists(list,1);
+}
+
+static void draw ( void ) {
+ glClear( /*GL_COLOR_BUFFER_BIT |*/ GL_DEPTH_BUFFER_BIT );
+
+ glPushMatrix();
+
+ glTranslatef( 0.0, 0.0, -10.0 );
+ glScalef( Scale*WindH/WindW, Scale, Scale );
+ glTranslatef(2.5*WindW/WindH*sin(step*1.11),2.5*cos(step*1.25*1.11),0);
+ glRotatef(step*100,1,0,0);
+ glRotatef(step*95,0,1,0);
+ glRotatef(step*90,0,0,1);
+
+ seno=(sin(step)+1.0/3.0)*(4.0/5.0)*Magnitude;
+
+ draw_object();
+
+ glPopMatrix();
+
+ glFlush();
+
+ step+=0.05;
+}
+
+static void reshape( int width, int height )
+{
+ glViewport(0, 0, WindW=(GLint)width, WindH=(GLint)height);
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glFrustum( -1.0, 1.0, -1.0, 1.0, 5.0, 15.0 );
+ glMatrixMode(GL_MODELVIEW);
+}
+
+static void pinit(void)
+{
+ switch(object) {
+ case 1:
+ draw_object=draw_tetra;
+ MaterialColor[0]=MaterialRed;
+ MaterialColor[1]=MaterialGreen;
+ MaterialColor[2]=MaterialBlue;
+ MaterialColor[3]=MaterialWhite;
+ edgedivisions=tetradivisions;
+ Magnitude=2.5;
+ break;
+ case 2:
+ draw_object=draw_cube;
+ MaterialColor[0]=MaterialRed;
+ MaterialColor[1]=MaterialGreen;
+ MaterialColor[2]=MaterialCyan;
+ MaterialColor[3]=MaterialMagenta;
+ MaterialColor[4]=MaterialYellow;
+ MaterialColor[5]=MaterialBlue;
+ edgedivisions=cubedivisions;
+ Magnitude=2.0;
+ break;
+ case 3:
+ draw_object=draw_octa;
+ MaterialColor[0]=MaterialRed;
+ MaterialColor[1]=MaterialGreen;
+ MaterialColor[2]=MaterialBlue;
+ MaterialColor[3]=MaterialWhite;
+ MaterialColor[4]=MaterialCyan;
+ MaterialColor[5]=MaterialMagenta;
+ MaterialColor[6]=MaterialGray;
+ MaterialColor[7]=MaterialYellow;
+ edgedivisions=octadivisions;
+ Magnitude=2.5;
+ break;
+ case 4:
+ draw_object=draw_dodeca;
+ MaterialColor[ 0]=MaterialRed;
+ MaterialColor[ 1]=MaterialGreen;
+ MaterialColor[ 2]=MaterialCyan;
+ MaterialColor[ 3]=MaterialBlue;
+ MaterialColor[ 4]=MaterialMagenta;
+ MaterialColor[ 5]=MaterialYellow;
+ MaterialColor[ 6]=MaterialGreen;
+ MaterialColor[ 7]=MaterialCyan;
+ MaterialColor[ 8]=MaterialRed;
+ MaterialColor[ 9]=MaterialMagenta;
+ MaterialColor[10]=MaterialBlue;
+ MaterialColor[11]=MaterialYellow;
+ edgedivisions=dodecadivisions;
+ Magnitude=2.0;
+ break;
+ case 5:
+ draw_object=draw_ico;
+ MaterialColor[ 0]=MaterialRed;
+ MaterialColor[ 1]=MaterialGreen;
+ MaterialColor[ 2]=MaterialBlue;
+ MaterialColor[ 3]=MaterialCyan;
+ MaterialColor[ 4]=MaterialYellow;
+ MaterialColor[ 5]=MaterialMagenta;
+ MaterialColor[ 6]=MaterialRed;
+ MaterialColor[ 7]=MaterialGreen;
+ MaterialColor[ 8]=MaterialBlue;
+ MaterialColor[ 9]=MaterialWhite;
+ MaterialColor[10]=MaterialCyan;
+ MaterialColor[11]=MaterialYellow;
+ MaterialColor[12]=MaterialMagenta;
+ MaterialColor[13]=MaterialRed;
+ MaterialColor[14]=MaterialGreen;
+ MaterialColor[15]=MaterialBlue;
+ MaterialColor[16]=MaterialCyan;
+ MaterialColor[17]=MaterialYellow;
+ MaterialColor[18]=MaterialMagenta;
+ MaterialColor[19]=MaterialGray;
+ edgedivisions=icodivisions;
+ Magnitude=2.5;
+ break;
+ }
+ if (mono) {
+ int loop;
+ for (loop=0; loop<20; loop++) MaterialColor[loop]=MaterialGray;
+ }
+ if (smooth) {
+ glShadeModel( GL_SMOOTH );
+ } else {
+ glShadeModel( GL_FLAT );
+ }
+
+}
+
+static void init(void)
+{
+ printf("Morph 3D - Shows morphing platonic polyhedra\n");
+ printf("Author: Marcelo Fernandes Vianna ([email protected])\n\n");
+ printf(" [1] - Tetrahedron\n");
+ printf(" [2] - Hexahedron (Cube)\n");
+ printf(" [3] - Octahedron\n");
+ printf(" [4] - Dodecahedron\n");
+ printf(" [5] - Icosahedron\n");
+ printf("[SPACE] - Toggle colored faces\n");
+ printf("[RETURN] - Toggle smooth/flat shading\n");
+ printf(" [ESC] - Quit\n");
+
+ object=1;
+
+ glClearDepth(1.0);
+ glClearColor( 0.0, 0.0, 0.0, 0.0 );
+ glColor3f( 1.0, 1.0, 1.0 );
+
+ glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
+ glFlush();
+ primary->Flip( primary, NULL, 0 );
+
+ glLightfv(GL_LIGHT0, GL_AMBIENT, ambient);
+ glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse);
+ glLightfv(GL_LIGHT0, GL_POSITION, position0);
+ glLightfv(GL_LIGHT1, GL_AMBIENT, ambient);
+ glLightfv(GL_LIGHT1, GL_DIFFUSE, diffuse);
+ glLightfv(GL_LIGHT1, GL_POSITION, position1);
+ glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient);
+ glLightModelfv(GL_LIGHT_MODEL_TWO_SIDE, lmodel_twoside);
+ glEnable(GL_LIGHTING);
+ glEnable(GL_LIGHT0);
+ glEnable(GL_LIGHT1);
+ glEnable(GL_DEPTH_TEST);
+ glEnable(GL_NORMALIZE);
+
+ glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, front_shininess);
+ glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, front_specular);
+
+ glHint(GL_FOG_HINT, GL_FASTEST);
+ glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);
+ glHint(GL_POLYGON_SMOOTH_HINT, GL_FASTEST);
+
+ pinit();
+}
+
+int main( int argc, char *argv[] )
+{
+ int quit = 0;
+ DFBResult err;
+ DFBSurfaceDescription dsc;
+
+ DFBCHECK(DirectFBInit( &argc, &argv ));
+
+ /* create the super interface */
+ DFBCHECK(DirectFBCreate( &dfb ));
+
+ /* create an event buffer for all devices with these caps */
+ DFBCHECK(dfb->CreateInputEventBuffer( dfb, DICAPS_KEYS, DFB_FALSE, &events ));
+
+ /* set our cooperative level to DFSCL_FULLSCREEN
+ for exclusive access to the primary layer */
+ dfb->SetCooperativeLevel( dfb, DFSCL_FULLSCREEN );
+
+ /* get the primary surface, i.e. the surface of the
+ primary layer we have exclusive access to */
+ dsc.flags = DSDESC_CAPS;
+ dsc.caps = DSCAPS_PRIMARY | DSCAPS_DOUBLE;
+
+ DFBCHECK(dfb->CreateSurface( dfb, &dsc, &primary ));
+
+ /* get the size of the surface and fill it */
+ DFBCHECK(primary->GetSize( primary, &screen_width, &screen_height ));
+ DFBCHECK(primary->FillRectangle( primary, 0, 0,
+ screen_width, screen_height ));
+
+ /* create the default font and set it */
+ DFBCHECK(dfb->CreateFont( dfb, NULL, NULL, &font ));
+ DFBCHECK(primary->SetFont( primary, font ));
+
+ /* get the GL context */
+ DFBCHECK(primary->GetGL( primary, &primary_gl ));
+
+ DFBCHECK(primary_gl->Lock( primary_gl ));
+
+ init();
+ reshape(screen_width, screen_height);
+
+ DFBCHECK(primary_gl->Unlock( primary_gl ));
+
+ T0 = get_millis();
+
+ while (!quit) {
+ DFBInputEvent evt;
+ unsigned long t;
+
+ primary->Clear( primary, 0, 0, 0, 0 );
+
+ DFBCHECK(primary_gl->Lock( primary_gl ));
+
+ draw();
+
+ DFBCHECK(primary_gl->Unlock( primary_gl ));
+
+ if (fps) {
+ char buf[64];
+
+ sprintf(buf, "%4.1f FPS\n", fps);
+ primary->SetColor( primary, 0xff, 0, 0, 0xff );
+ primary->DrawString( primary, buf, -1, screen_width - 5, 5, DSTF_TOPRIGHT );
+ }
+
+ primary->Flip( primary, NULL, 0 );
+ Frames++;
+
+
+ t = get_millis();
+ if (t - T0 >= 1000) {
+ GLfloat seconds = (t - T0) / 1000.0;
+
+ fps = Frames / seconds;
+
+ T0 = t;
+ Frames = 0;
+ }
+
+
+ while (events->GetEvent( events, DFB_EVENT(&evt) ) == DFB_OK) {
+ switch (evt.type) {
+ case DIET_KEYPRESS:
+ switch (evt.key_symbol) {
+ case DIKS_ESCAPE:
+ quit = 1;
+ break;
+ case DIKS_1: object=1; break;
+ case DIKS_2: object=2; break;
+ case DIKS_3: object=3; break;
+ case DIKS_4: object=4; break;
+ case DIKS_5: object=5; break;
+ case DIKS_SPACE: mono^=1; break;
+ case DIKS_ENTER: smooth^=1; break;
+ default:
+ ;
+ }
+ pinit();
+ break;
+ default:
+ ;
+ }
+ }
+ }
+
+ /* release our interfaces to shutdown DirectFB */
+ primary_gl->Release( primary_gl );
+ primary->Release( primary );
+ font->Release( font );
+ events->Release( events );
+ dfb->Release( dfb );
+
+ return 0;
+}
+
diff --git a/progs/directfb/df_reflect.c b/progs/directfb/df_reflect.c
new file mode 100644
index 00000000000..a0e789c3871
--- /dev/null
+++ b/progs/directfb/df_reflect.c
@@ -0,0 +1,489 @@
+/*
+ (c) Copyright 2001 convergence integrated media GmbH.
+ All rights reserved.
+
+ Written by Denis Oliver Kropp <[email protected]> and
+ Andreas Hundt <[email protected]>.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <math.h>
+
+#include <directfb.h>
+#include <directfbgl.h>
+
+#include <GL/glu.h>
+
+#include "util/showbuffer.c"
+#include "util/readtex.c"
+
+
+/* the super interface */
+IDirectFB *dfb;
+
+/* the primary surface (surface of primary layer) */
+IDirectFBSurface *primary;
+
+/* the GL context */
+IDirectFBGL *primary_gl;
+
+/* our font */
+IDirectFBFont *font;
+
+/* event buffer */
+IDirectFBEventBuffer *events;
+
+/* macro for a safe call to DirectFB functions */
+#define DFBCHECK(x...) \
+ { \
+ err = x; \
+ if (err != DFB_OK) { \
+ fprintf( stderr, "%s <%d>:\n\t", __FILE__, __LINE__ ); \
+ DirectFBErrorFatal( #x, err ); \
+ } \
+ }
+
+static int screen_width, screen_height;
+
+static unsigned long T0 = 0;
+static GLint Frames = 0;
+static GLfloat fps = 0;
+
+static inline unsigned long get_millis()
+{
+ struct timeval tv;
+
+ gettimeofday (&tv, NULL);
+ return (tv.tv_sec * 1000 + tv.tv_usec / 1000);
+}
+
+/*******************************/
+
+#define DEG2RAD (3.14159/180.0)
+
+#define TABLE_TEXTURE "../images/tile.rgb"
+
+static GLint ImgWidth, ImgHeight;
+static GLenum ImgFormat;
+static GLubyte *Image = NULL;
+
+#define MAX_OBJECTS 2
+static GLint table_list;
+static GLint objects_list[MAX_OBJECTS];
+
+static GLfloat xrot, yrot;
+static GLfloat spin;
+
+static GLint Width = 400, Height = 300;
+static GLenum ShowBuffer = GL_NONE;
+
+
+static void make_table( void )
+{
+ static GLfloat table_mat[] = { 1.0, 1.0, 1.0, 0.6 };
+ static GLfloat gray[] = { 0.4, 0.4, 0.4, 1.0 };
+
+ 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();
+}
+
+
+static void make_objects( void )
+{
+ 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();
+}
+
+
+static void init( void )
+{
+ make_table();
+ make_objects();
+
+ 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);
+
+ 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 );
+
+ xrot = 30.0;
+ yrot = 50.0;
+ spin = 0.0;
+
+ 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 w, int h)
+{
+ GLfloat yAspect = 2.5;
+ GLfloat xAspect = yAspect * (float) w / (float) h;
+ Width = w;
+ Height = h;
+ glViewport(0, 0, w, h);
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glFrustum( -xAspect, xAspect, -yAspect, yAspect, 10.0, 30.0 );
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
+}
+
+
+
+static void draw_objects( 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( spin, 1.0, 0.5, 0.0 );
+ glRotatef( 0.5*spin, 0.0, 0.5, 1.0 );
+ glCallList( objects_list[0] );
+ glPopMatrix();
+
+ glPushMatrix();
+ glTranslatef( -1.0, 0.85+3.0*fabs( cos(0.01*spin) ), 0.0 );
+ glRotatef( 0.5*spin, 0.0, 0.5, 1.0 );
+ glRotatef( spin, 1.0, 0.5, 0.0 );
+ glScalef( 0.5, 0.5, 0.5 );
+ glCallList( objects_list[1] );
+ glPopMatrix();
+#ifndef USE_ZBUFFER
+ }
+ else {
+ glPushMatrix();
+ glTranslatef( -1.0, 0.85+3.0*fabs( cos(0.01*spin) ), 0.0 );
+ glRotatef( 0.5*spin, 0.0, 0.5, 1.0 );
+ glRotatef( spin, 1.0, 0.5, 0.0 );
+ glScalef( 0.5, 0.5, 0.5 );
+ glCallList( objects_list[1] );
+ glPopMatrix();
+
+ glPushMatrix();
+ glTranslatef( 1.0, 1.5, 0.0 );
+ glRotatef( spin, 1.0, 0.5, 0.0 );
+ glRotatef( 0.5*spin, 0.0, 0.5, 1.0 );
+ glCallList( objects_list[0] );
+ glPopMatrix();
+ }
+#endif
+}
+
+
+
+static void draw_table( void )
+{
+ glCallList( table_list );
+}
+
+
+
+static void draw( void )
+{
+ static GLfloat light_pos[] = { 0.0, 20.0, 0.0, 1.0 };
+ GLfloat dist = 20.0;
+ GLfloat eyex, eyey, eyez;
+
+ glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
+
+
+ eyex = dist * cos(yrot*DEG2RAD) * cos(xrot*DEG2RAD);
+ eyez = dist * sin(yrot*DEG2RAD) * cos(xrot*DEG2RAD);
+ eyey = dist * sin(xrot*DEG2RAD);
+
+ /* view from top */
+ glPushMatrix();
+ gluLookAt( eyex, eyey, eyez, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0 );
+
+ 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 );
+ draw_table();
+ 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);
+
+ draw_objects(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 );
+ draw_table();
+ glDisable( GL_TEXTURE_2D );
+ glDisable( GL_BLEND );
+
+ /* view from top */
+ glPushMatrix();
+
+ draw_objects(eyex, eyey, eyez);
+
+ glPopMatrix();
+
+ glPopMatrix();
+
+ if (ShowBuffer == GL_DEPTH) {
+ ShowDepthBuffer(Width, Height, 1.0, 0.0);
+ }
+ else if (ShowBuffer == GL_STENCIL) {
+ ShowStencilBuffer(Width, Height, 255.0, 0.0);
+ }
+ else if (ShowBuffer == GL_ALPHA) {
+ ShowAlphaBuffer(Width, Height);
+ }
+}
+
+/*******************************/
+
+int main( int argc, char *argv[] )
+{
+ int quit = 0;
+ DFBResult err;
+ DFBSurfaceDescription dsc;
+
+ DFBCHECK(DirectFBInit( &argc, &argv ));
+
+ /* create the super interface */
+ DFBCHECK(DirectFBCreate( &dfb ));
+
+ /* create an event buffer for all devices with these caps */
+ DFBCHECK(dfb->CreateInputEventBuffer( dfb, DICAPS_ALL, DFB_FALSE, &events ));
+
+ /* set our cooperative level to DFSCL_FULLSCREEN
+ for exclusive access to the primary layer */
+ dfb->SetCooperativeLevel( dfb, DFSCL_FULLSCREEN );
+
+ /* get the primary surface, i.e. the surface of the
+ primary layer we have exclusive access to */
+ dsc.flags = DSDESC_CAPS;
+ dsc.caps = (DFBSurfaceCapabilities)(DSCAPS_PRIMARY | DSCAPS_DOUBLE);
+
+ DFBCHECK(dfb->CreateSurface( dfb, &dsc, &primary ));
+
+ /* get the size of the surface and fill it */
+ DFBCHECK(primary->GetSize( primary, &screen_width, &screen_height ));
+ DFBCHECK(primary->FillRectangle( primary, 0, 0,
+ screen_width, screen_height ));
+
+ /* create the default font and set it */
+ DFBCHECK(dfb->CreateFont( dfb, NULL, NULL, &font ));
+ DFBCHECK(primary->SetFont( primary, font ));
+
+ /* get the GL context */
+ DFBCHECK(primary->GetGL( primary, &primary_gl ));
+
+ DFBCHECK(primary_gl->Lock( primary_gl ));
+
+ init();
+ reshape(screen_width, screen_height);
+
+ DFBCHECK(primary_gl->Unlock( primary_gl ));
+
+ T0 = get_millis();
+
+ while (!quit) {
+ DFBInputEvent evt;
+ unsigned long t;
+
+ DFBCHECK(primary_gl->Lock( primary_gl ));
+
+ draw();
+
+ DFBCHECK(primary_gl->Unlock( primary_gl ));
+
+ if (fps) {
+ char buf[64];
+
+ sprintf(buf, "%4.1f FPS\n", fps);
+ primary->SetColor( primary, 0xff, 0, 0, 0xff );
+ primary->DrawString( primary, buf, -1, screen_width - 5, 5, DSTF_TOPRIGHT );
+ }
+
+ primary->Flip( primary, NULL, (DFBSurfaceFlipFlags)0 );
+ Frames++;
+
+
+ t = get_millis();
+ if (t - T0 >= 1000) {
+ GLfloat seconds = (t - T0) / 1000.0;
+
+ fps = Frames / seconds;
+
+ T0 = t;
+ Frames = 0;
+ }
+
+
+ while (events->GetEvent( events, DFB_EVENT(&evt) ) == DFB_OK) {
+ switch (evt.type) {
+ case DIET_KEYPRESS:
+ switch (DFB_LOWER_CASE(evt.key_symbol)) {
+ case DIKS_ESCAPE:
+ quit = 1;
+ break;
+ case DIKS_CURSOR_UP:
+ xrot += 3.0;
+ if ( xrot > 85 )
+ xrot = 85;
+ break;
+ case DIKS_CURSOR_DOWN:
+ xrot -= 3.0;
+ if ( xrot < 5 )
+ xrot = 5;
+ break;
+ case DIKS_CURSOR_LEFT:
+ yrot += 3.0;
+ break;
+ case DIKS_CURSOR_RIGHT:
+ yrot -= 3.0;
+ break;
+ case DIKS_SMALL_D:
+ ShowBuffer = GL_DEPTH;
+ break;
+ case DIKS_SMALL_S:
+ ShowBuffer = GL_STENCIL;
+ break;
+ case DIKS_SMALL_A:
+ ShowBuffer = GL_ALPHA;
+ break;
+ default:
+ ShowBuffer = GL_NONE;
+ }
+ break;
+ case DIET_AXISMOTION:
+ if (evt.flags & DIEF_AXISREL) {
+ switch (evt.axis) {
+ case DIAI_X:
+ yrot += evt.axisrel / 2.0;
+ break;
+ case DIAI_Y:
+ xrot += evt.axisrel / 2.0;
+ break;
+ default:
+ ;
+ }
+ }
+ break;
+ default:
+ ;
+ }
+ }
+
+ spin += 2.0;
+ yrot += 3.0;
+ }
+
+ /* release our interfaces to shutdown DirectFB */
+ primary_gl->Release( primary_gl );
+ primary->Release( primary );
+ font->Release( font );
+ events->Release( events );
+ dfb->Release( dfb );
+
+ return 0;
+}
+
diff --git a/progs/directfb/multi_window.c b/progs/directfb/multi_window.c
new file mode 100644
index 00000000000..9bb0e4be8ef
--- /dev/null
+++ b/progs/directfb/multi_window.c
@@ -0,0 +1,240 @@
+/*
+ (c) Copyright 2001 convergence integrated media GmbH.
+ All rights reserved.
+
+ Written by Denis Oliver Kropp <[email protected]> and
+ Andreas Hundt <[email protected]>.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <math.h>
+
+#include <GL/gl.h>
+#include <GL/glu.h>
+
+#include <directfb.h>
+#include <directfbgl.h>
+
+
+typedef struct {
+ IDirectFBWindow *window;
+ IDirectFBSurface *surface;
+ IDirectFBGL *gl;
+
+ int width;
+ int height;
+
+ unsigned long last_time;
+ int frames;
+ float fps;
+} Context;
+
+static const GLfloat blue[4] = {0.2, 0.2, 1.0, 1.0};
+
+static IDirectFB *dfb;
+static IDirectFBDisplayLayer *layer;
+static IDirectFBFont *font;
+static IDirectFBEventBuffer *events = NULL;
+
+/* macro for a safe call to DirectFB functions */
+#define DFBCHECK(x...) \
+ do { \
+ ret = x; \
+ if (ret != DFB_OK) { \
+ fprintf( stderr, "%s <%d>:\n\t", __FILE__, __LINE__ ); \
+ DirectFBErrorFatal( #x, ret ); \
+ } \
+ } while (0)
+
+
+static inline unsigned long get_millis()
+{
+ struct timeval tv;
+
+ gettimeofday (&tv, NULL);
+ return (tv.tv_sec * 1000 + tv.tv_usec / 1000);
+}
+
+
+static void
+setup( Context *context )
+{
+ GLfloat pos[4] = {5.0, 5.0, 10.0, 0.0};
+
+ context->surface->GetSize( context->surface,
+ &context->width, &context->height );
+
+ context->gl->Lock( context->gl );
+
+ glLightfv(GL_LIGHT0, GL_POSITION, pos);
+ glEnable(GL_CULL_FACE);
+ glEnable(GL_LIGHTING);
+ glEnable(GL_LIGHT0);
+ glEnable(GL_DEPTH_TEST);
+
+ glViewport(0, 0, context->width, context->height);
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ gluPerspective(70.0, context->width / (float) context->height, 1.0, 80.0);
+
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
+ glTranslatef(0.0, 0.0, -40.0);
+
+ context->gl->Unlock( context->gl );
+}
+
+static void
+update( Context *context )
+{
+ unsigned long t;
+ IDirectFBSurface *surface = context->surface;
+ static __u8 r = 0, g = 0, b = 0;
+
+
+ context->gl->Lock( context->gl );
+
+ glClearColor( r++/255.0, g++/255.0, b++/255.0, 1.0 );
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+ context->gl->Unlock( context->gl );
+
+ if (context->fps) {
+ char buf[16];
+
+ snprintf(buf, sizeof(buf), "%.1f FPS\n", context->fps);
+
+ surface->SetColor( surface, 0xff, 0x00, 0x00, 0xff );
+ surface->DrawString( surface, buf, -1,
+ context->width - 5, 5, DSTF_TOPRIGHT );
+ }
+
+ surface->Flip( surface, NULL, 0 );
+
+ context->frames++;
+
+ t = get_millis();
+ if (t - context->last_time >= 2000) {
+ float seconds = (t - context->last_time) / 1000.0f;
+
+ context->fps = context->frames / seconds;
+
+ context->last_time = t;
+ context->frames = 0;
+ }
+}
+
+int
+main( int argc, char *argv[] )
+{
+ DFBResult ret;
+ int i;
+ int quit = 0;
+ const int num = 2;
+ Context contexts[num];
+
+ DFBCHECK(DirectFBInit( &argc, &argv ));
+
+ /* create the super interface */
+ DFBCHECK(DirectFBCreate( &dfb ));
+
+ DFBCHECK(dfb->GetDisplayLayer( dfb, DLID_PRIMARY, &layer ));
+
+ /* create the default font */
+ DFBCHECK(dfb->CreateFont( dfb, NULL, NULL, &font ));
+
+ for (i=0; i<num; i++) {
+ IDirectFBWindow *window;
+ IDirectFBSurface *surface;
+ IDirectFBGL *gl;
+ DFBWindowDescription desc;
+
+ desc.flags = DWDESC_POSX | DWDESC_POSY |
+ DWDESC_WIDTH | DWDESC_HEIGHT;
+ desc.posx = (i%3) * 200 + 10;
+ desc.posy = (i/3) * 200 + 10;
+ desc.width = 180;
+ desc.height = 180;
+
+ DFBCHECK(layer->CreateWindow( layer, &desc, &window ));
+ DFBCHECK(window->GetSurface( window, &surface ));
+ DFBCHECK(surface->GetGL( surface, &gl ));
+
+ contexts[i].window = window;
+ contexts[i].surface = surface;
+ contexts[i].gl = gl;
+
+ contexts[i].last_time = get_millis();
+ contexts[i].frames = 0;
+ contexts[i].fps = 0;
+
+ setup( &contexts[i] );
+
+ if (events)
+ DFBCHECK(window->AttachEventBuffer( window, events ));
+ else
+ DFBCHECK(window->CreateEventBuffer( window, &events ));
+
+ DFBCHECK(surface->SetFont( surface, font ));
+
+ window->SetOpacity( window, 0xff );
+ }
+
+ while (!quit) {
+ DFBWindowEvent evt;
+
+ for (i=0; i<num; i++)
+ update( &contexts[i] );
+
+ while (events->GetEvent( events, DFB_EVENT(&evt) ) == DFB_OK) {
+ switch (evt.type) {
+ case DWET_KEYDOWN:
+ switch (evt.key_symbol) {
+ case DIKS_ESCAPE:
+ quit = 1;
+ break;
+
+ default:
+ break;
+ }
+ break;
+
+ default:
+ break;
+ }
+ }
+ }
+
+ events->Release( events );
+
+ for (i=0; i<num; i++) {
+ contexts[i].gl->Release( contexts[i].gl );
+ contexts[i].surface->Release( contexts[i].surface );
+ contexts[i].window->Release( contexts[i].window );
+ }
+
+ font->Release( font );
+ layer->Release( layer );
+ dfb->Release( dfb );
+
+ return 0;
+}
+
diff --git a/progs/egl/Makefile b/progs/egl/Makefile
new file mode 100644
index 00000000000..33447a9d575
--- /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 $(TOP)/$(LIB_DIR)/libEGL.so
+ $(CC) $(CFLAGS) demo1.o -L$(TOP)/$(LIB_DIR) -lEGL $(LIBDRM_LIB) -o $@
+
+demo1.o: demo1.c $(HEADERS)
+ $(CC) -c $(CFLAGS) -I$(TOP)/include demo1.c
+
+
+demo2: demo2.o $(TOP)/$(LIB_DIR)/libEGL.so
+ $(CC) $(CFLAGS) demo2.o -L$(TOP)/$(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 $(TOP)/$(LIB_DIR)/libEGL.so
+ $(CC) $(CFLAGS) demo3.o -L$(TOP)/$(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 $(TOP)/$(LIB_DIR)/libEGL.so
+ $(CC) $(CFLAGS) eglinfo.o -L$(TOP)/$(LIB_DIR) -lEGL $(LIBDRM_LIB) -o $@
+
+eglinfo.o: eglinfo.c $(HEADERS)
+ $(CC) -c $(CFLAGS) -I$(TOP)/include eglinfo.c
+
+
+eglgears: eglgears.o $(TOP)/$(LIB_DIR)/libEGL.so
+ $(CC) $(CFLAGS) eglgears.o -L$(TOP)/$(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 <GLES/egl.h>
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+
+/**
+ * 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 <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include <GLES/egl.h>
+
+/*#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 <GLES/egl.h>
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+
+
+#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<width; x++) {
+ i = (y*width + x) * 4;
+ fputc(ptr[i], f); /* write red */
+ fputc(ptr[i+1], f); /* write green */
+ fputc(ptr[i+2], f); /* write blue */
+ }
+ }
+ }
+ else {
+ /*ASCII*/
+ int counter = 0;
+ fprintf(f,"P3\n");
+ fprintf(f,"# ascii ppm file created by osdemo.c\n");
+ fprintf(f,"%i %i\n", width, height);
+ fprintf(f,"255\n");
+ for (y=height-1; y>=0; y--) {
+ for (x=0; x<width; x++) {
+ i = (y*width + x) * 4;
+ fprintf(f, " %3d %3d %3d", ptr[i], ptr[i+1], ptr[i+2]);
+ counter++;
+ if (counter % 5 == 0)
+ fprintf(f, "\n");
+ }
+ }
+ }
+ fclose(f);
+ }
+}
+
+#include "../src/egl/main/egldisplay.h"
+
+typedef struct fb_display
+{
+ _EGLDisplay Base; /* base class/object */
+ void *pFB;
+} fbDisplay;
+
+
+int
+main(int argc, char *argv[])
+{
+ int maj, min;
+ EGLContext ctx;
+ EGLSurface screen_surf;
+ EGLConfig configs[10];
+ EGLScreenMESA screen;
+ EGLModeMESA mode;
+ EGLint numConfigs, count;
+ EGLBoolean b;
+ const EGLint screenAttribs[] = {
+ EGL_WIDTH, 1024,
+ EGL_HEIGHT, 768,
+ EGL_NONE
+ };
+
+ /*
+ EGLDisplay d = eglGetDisplay(EGL_DEFAULT_DISPLAY);
+ */
+ EGLDisplay d = eglGetDisplay(":0");
+ 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);
+ 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;
+ }
+
+ 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);
+
+
+ Init();
+ Reshape(1024, 768);
+
+ glDrawBuffer( GL_FRONT );
+ glClearColor( 0, 1.0, 0, 1);
+
+ glClear( GL_COLOR_BUFFER_BIT );
+
+ doubleBuffer = 1;
+ glDrawBuffer( GL_BACK );
+
+ Draw(d, screen_surf);
+
+ write_ppm("dump.ppm", ((struct fb_display *)_eglLookupDisplay(d))->pFB, 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 <math.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <GL/gl.h>
+#include <GLES/egl.h>
+#include <assert.h>
+
+#define MAX_CONFIGS 10
+#define MAX_MODES 100
+
+#define BENCHMARK
+
+#ifdef BENCHMARK
+
+/* XXX this probably isn't very portable */
+
+#include <sys/time.h>
+#include <unistd.h>
+
+/* 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 <GLES/egl.h>
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#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 <assert.h>
+#include <errno.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/ioctl.h>
+#include <sys/mman.h>
+#include <sys/types.h>
+#include <linux/fb.h>
+#include <linux/kd.h>
+#include <linux/vt.h>
+#include <GL/gl.h>
+#include <GL/glfbdev.h>
+#include <math.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%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..d979be83d34
--- /dev/null
+++ b/progs/fp/Makefile
@@ -0,0 +1,128 @@
+# 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 \
+ point-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/point-position.c b/progs/fp/point-position.c
new file mode 100644
index 00000000000..c352a939cb1
--- /dev/null
+++ b/progs/fp/point-position.c
@@ -0,0 +1,119 @@
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+#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);
+
+#if 0
+ glBegin(GL_QUADS);
+ glTexCoord2f(1,0);
+ glVertex3f( 0.9, -0.9, -30.0);
+ glTexCoord2f(1,1);
+ glVertex3f( 0.9, 0.9, -30.0);
+ glTexCoord2f(0,1);
+ glVertex3f(-0.9, 0.9, -30.0);
+ glTexCoord2f(0,0);
+ glVertex3f(-0.9, -0.9, -30.0);
+ glEnd();
+#else
+ glPointSize(100);
+ glBegin(GL_POINTS);
+ glColor3f(0,0,1);
+ glVertex3f( 0, 0, -30.0);
+ glEnd();
+#endif
+
+ 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-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 <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+
+
+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 <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+
+
+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 <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+
+
+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 <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+#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 <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+#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 <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+#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 <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+
+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 <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+
+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 <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+
+
+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 <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+
+
+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 <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+
+
+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 <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+#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 <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+
+
+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 <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+
+
+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 <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+#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 <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+#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 <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+
+
+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 <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+
+
+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 <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+
+
+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 <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+#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 <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+
+
+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 <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+
+
+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 <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+#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 <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+#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 <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+#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 <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+#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 <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+#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 <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+#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 <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+
+
+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 <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+
+
+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 <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+
+
+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 <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+#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 <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+#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 <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+#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 <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+#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 <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+#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 <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+#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 <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+#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 <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+
+
+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 <assert.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+#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 <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+#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/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/sphere.asc b/progs/ggi/sphere.asc
new file mode 100644
index 00000000000..1424a740d7b
--- /dev/null
+++ b/progs/ggi/sphere.asc
@@ -0,0 +1,132 @@
+Ambient light color: Red=0.039216 Green=0.039216 Blue=0.039216
+
+Named object: "Object01"
+Tri-mesh, Vertices: 20 Faces: 36
+Vertex list:
+Vertex 0: X: -210 Y: -432.781738 Z: 180.000031
+Vertex 1: X: -610.810303 Y: 144.260559 Z: 103.580154
+Vertex 2: X: 56.586655 Y: 144.260544 Z: -128.902023
+Vertex 3: X: -75.776352 Y: 144.260605 Z: 565.321838
+Vertex 4: X: -462.815979 Y: -347.937683 Z: 131.797302
+Vertex 5: X: -616.506042 Y: -126.67173 Z: 102.494209
+Vertex 6: X: -41.847229 Y: -347.937683 Z: -14.843644
+Vertex 7: X: 60.375015 Y: -126.671753 Z: -133.291641
+Vertex 8: X: -125.336807 Y: -347.937653 Z: 423.046448
+Vertex 9: X: -73.868958 Y: -126.671692 Z: 570.797424
+Vertex 10: X: -448.353271 Y: 237.304672 Z: -92.34951
+Vertex 11: X: -192.440964 Y: 237.304672 Z: -181.494431
+Vertex 12: X: 145.038193 Y: 237.304672 Z: 109.754745
+Vertex 13: X: 94.283768 Y: 237.304688 Z: 375.953766
+Vertex 14: X: -326.684937 Y: 237.304733 Z: 522.594727
+Vertex 15: X: -531.842834 Y: 237.304718 Z: 345.540588
+Vertex 16: X: -331.419525 Y: -225.964966 Z: -168.564438
+Vertex 17: X: 152.575485 Y: -225.964935 Z: 249.129868
+Vertex 18: X: -451.155914 Y: -225.964905 Z: 459.434662
+Vertex 19: X: -298.413483 Y: 423.31897 Z: 163.142761
+Face list:
+Face 0: A:0 B:4 C:6 AB:1 BC:1 CA:1
+Face 1: A:4 B:5 C:16 AB:1 BC:1 CA:1
+Face 2: A:4 B:16 C:6 AB:1 BC:1 CA:1
+Face 3: A:6 B:16 C:7 AB:1 BC:1 CA:1
+Face 4: A:5 B:1 C:10 AB:1 BC:1 CA:1
+Face 5: A:5 B:10 C:16 AB:1 BC:1 CA:1
+Face 6: A:16 B:10 C:11 AB:1 BC:1 CA:1
+Face 7: A:16 B:11 C:7 AB:1 BC:1 CA:1
+Face 8: A:7 B:11 C:2 AB:1 BC:1 CA:1
+Face 9: A:0 B:6 C:8 AB:1 BC:1 CA:1
+Face 10: A:6 B:7 C:17 AB:1 BC:1 CA:1
+Face 11: A:6 B:17 C:8 AB:1 BC:1 CA:1
+Face 12: A:8 B:17 C:9 AB:1 BC:1 CA:1
+Face 13: A:7 B:2 C:12 AB:1 BC:1 CA:1
+Face 14: A:7 B:12 C:17 AB:1 BC:1 CA:1
+Face 15: A:17 B:12 C:13 AB:1 BC:1 CA:1
+Face 16: A:17 B:13 C:9 AB:1 BC:1 CA:1
+Face 17: A:9 B:13 C:3 AB:1 BC:1 CA:1
+Face 18: A:0 B:8 C:4 AB:1 BC:1 CA:1
+Face 19: A:8 B:9 C:18 AB:1 BC:1 CA:1
+Face 20: A:8 B:18 C:4 AB:1 BC:1 CA:1
+Face 21: A:4 B:18 C:5 AB:1 BC:1 CA:1
+Face 22: A:9 B:3 C:14 AB:1 BC:1 CA:1
+Face 23: A:9 B:14 C:18 AB:1 BC:1 CA:1
+Face 24: A:18 B:14 C:15 AB:1 BC:1 CA:1
+Face 25: A:18 B:15 C:5 AB:1 BC:1 CA:1
+Face 26: A:5 B:15 C:1 AB:1 BC:1 CA:1
+Face 27: A:1 B:15 C:10 AB:1 BC:1 CA:1
+Face 28: A:15 B:14 C:19 AB:1 BC:1 CA:1
+Face 29: A:15 B:19 C:10 AB:1 BC:1 CA:1
+Face 30: A:10 B:19 C:11 AB:1 BC:1 CA:1
+Face 31: A:14 B:3 C:13 AB:1 BC:1 CA:1
+Face 32: A:14 B:13 C:19 AB:1 BC:1 CA:1
+Face 33: A:19 B:13 C:12 AB:1 BC:1 CA:1
+Face 34: A:19 B:12 C:11 AB:1 BC:1 CA:1
+
+ Page 1
+
+
+
+Face 35: A:11 B:12 C:2 AB:1 BC:1 CA:1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Page 2
+
+
+
diff --git a/progs/ggi/torus.asc b/progs/ggi/torus.asc
new file mode 100644
index 00000000000..6bd41f40337
--- /dev/null
+++ b/progs/ggi/torus.asc
@@ -0,0 +1,264 @@
+Ambient light color: Red=0.039216 Green=0.039216 Blue=0.039216
+
+Named object: "Object01"
+Tri-mesh, Vertices: 40 Faces: 80
+Vertex list:
+Vertex 0: X: -50.170624 Y: -0.000026 Z: -240.147842
+Vertex 1: X: -80.584503 Y: -63.958851 Z: -205.014572
+Vertex 2: X: -129.795166 Y: -39.528744 Z: -148.16774
+Vertex 3: X: -129.795166 Y: 39.528721 Z: -148.16774
+Vertex 4: X: -80.584503 Y: 63.958797 Z: -205.014572
+Vertex 5: X: 85.963654 Y: -0.000002 Z: 31.490465
+Vertex 6: X: 39.614838 Y: -63.958828 Z: 34.827602
+Vertex 7: X: -35.37915 Y: -39.528728 Z: 40.227196
+Vertex 8: X: -35.37912 Y: 39.528736 Z: 40.227188
+Vertex 9: X: 39.614838 Y: 63.95882 Z: 34.827595
+Vertex 10: X: -9.852051 Y: 0.000023 Z: 319.829254
+Vertex 11: X: -44.985352 Y: -63.958805 Z: 289.415405
+Vertex 12: X: -101.832199 Y: -39.528709 Z: 240.204758
+Vertex 13: X: -101.832184 Y: 39.528755 Z: 240.204773
+Vertex 14: X: -44.985352 Y: 63.958843 Z: 289.415405
+Vertex 15: X: -281.490326 Y: 0.000035 Z: 455.963654
+Vertex 16: X: -284.827484 Y: -63.958794 Z: 409.614868
+Vertex 17: X: -290.227112 Y: -39.528702 Z: 334.62085
+Vertex 18: X: -290.227112 Y: 39.528763 Z: 334.62088
+Vertex 19: X: -284.827484 Y: 63.958855 Z: 409.614838
+Vertex 20: X: -569.829163 Y: 0.000026 Z: 360.14798
+Vertex 21: X: -539.415344 Y: -63.958801 Z: 325.014709
+Vertex 22: X: -490.204712 Y: -39.528709 Z: 268.167847
+Vertex 23: X: -490.204712 Y: 39.528755 Z: 268.167847
+Vertex 24: X: -539.415344 Y: 63.958847 Z: 325.014679
+Vertex 25: X: -705.963684 Y: 0.000002 Z: 88.509598
+Vertex 26: X: -659.614807 Y: -63.958824 Z: 85.172462
+Vertex 27: X: -584.62085 Y: -39.528725 Z: 79.77285
+Vertex 28: X: -584.62085 Y: 39.52874 Z: 79.77285
+Vertex 29: X: -659.614868 Y: 63.958824 Z: 85.172447
+Vertex 30: X: -610.147827 Y: -0.000023 Z: -199.829361
+Vertex 31: X: -575.014587 Y: -63.958847 Z: -169.415497
+Vertex 32: X: -518.167725 Y: -39.528744 Z: -120.204819
+Vertex 33: X: -518.167725 Y: 39.528721 Z: -120.204834
+Vertex 34: X: -575.014587 Y: 63.958801 Z: -169.415497
+Vertex 35: X: -338.509338 Y: -0.000035 Z: -335.963745
+Vertex 36: X: -335.172241 Y: -63.958858 Z: -289.614868
+Vertex 37: X: -329.772675 Y: -39.528751 Z: -214.620865
+Vertex 38: X: -329.772675 Y: 39.528713 Z: -214.620865
+Vertex 39: X: -335.172241 Y: 63.95879 Z: -289.614899
+Face list:
+Face 0: A:0 B:6 C:1 AB:0 BC:1 CA:1
+Smoothing: 1
+Face 1: A:0 B:5 C:6 AB:1 BC:1 CA:0
+Smoothing: 1
+Face 2: A:1 B:7 C:2 AB:0 BC:1 CA:1
+Smoothing: 2
+Face 3: A:1 B:6 C:7 AB:1 BC:1 CA:0
+Smoothing: 2
+Face 4: A:2 B:8 C:3 AB:0 BC:1 CA:1
+Smoothing: 3
+Face 5: A:2 B:7 C:8 AB:1 BC:1 CA:0
+Smoothing: 3
+Face 6: A:3 B:9 C:4 AB:0 BC:1 CA:1
+Smoothing: 4
+Face 7: A:3 B:8 C:9 AB:1 BC:1 CA:0
+
+ Page 1
+
+
+
+Smoothing: 4
+Face 8: A:4 B:5 C:0 AB:0 BC:1 CA:1
+Smoothing: 5
+Face 9: A:4 B:9 C:5 AB:1 BC:1 CA:0
+Smoothing: 5
+Face 10: A:5 B:11 C:6 AB:0 BC:1 CA:1
+Smoothing: 6
+Face 11: A:5 B:10 C:11 AB:1 BC:1 CA:0
+Smoothing: 6
+Face 12: A:6 B:12 C:7 AB:0 BC:1 CA:1
+Smoothing: 7
+Face 13: A:6 B:11 C:12 AB:1 BC:1 CA:0
+Smoothing: 7
+Face 14: A:7 B:13 C:8 AB:0 BC:1 CA:1
+Smoothing: 8
+Face 15: A:7 B:12 C:13 AB:1 BC:1 CA:0
+Smoothing: 8
+Face 16: A:8 B:14 C:9 AB:0 BC:1 CA:1
+Smoothing: 9
+Face 17: A:8 B:13 C:14 AB:1 BC:1 CA:0
+Smoothing: 9
+Face 18: A:9 B:10 C:5 AB:0 BC:1 CA:1
+Smoothing: 10
+Face 19: A:9 B:14 C:10 AB:1 BC:1 CA:0
+Smoothing: 10
+Face 20: A:10 B:16 C:11 AB:0 BC:1 CA:1
+Smoothing: 11
+Face 21: A:10 B:15 C:16 AB:1 BC:1 CA:0
+Smoothing: 11
+Face 22: A:11 B:17 C:12 AB:0 BC:1 CA:1
+Smoothing: 12
+Face 23: A:11 B:16 C:17 AB:1 BC:1 CA:0
+Smoothing: 12
+Face 24: A:12 B:18 C:13 AB:0 BC:1 CA:1
+Smoothing: 13
+Face 25: A:12 B:17 C:18 AB:1 BC:1 CA:0
+Smoothing: 13
+Face 26: A:13 B:19 C:14 AB:0 BC:1 CA:1
+Smoothing: 14
+Face 27: A:13 B:18 C:19 AB:1 BC:1 CA:0
+Smoothing: 14
+Face 28: A:14 B:15 C:10 AB:0 BC:1 CA:1
+Smoothing: 15
+Face 29: A:14 B:19 C:15 AB:1 BC:1 CA:0
+Smoothing: 15
+Face 30: A:15 B:21 C:16 AB:0 BC:1 CA:1
+Smoothing: 16
+Face 31: A:15 B:20 C:21 AB:1 BC:1 CA:0
+Smoothing: 16
+Face 32: A:16 B:22 C:17 AB:0 BC:1 CA:1
+Smoothing: 17
+Face 33: A:16 B:21 C:22 AB:1 BC:1 CA:0
+Smoothing: 17
+Face 34: A:17 B:23 C:18 AB:0 BC:1 CA:1
+Smoothing: 18
+Face 35: A:17 B:22 C:23 AB:1 BC:1 CA:0
+Smoothing: 18
+Face 36: A:18 B:24 C:19 AB:0 BC:1 CA:1
+Smoothing: 19
+Face 37: A:18 B:23 C:24 AB:1 BC:1 CA:0
+Smoothing: 19
+
+ Page 2
+
+
+
+Face 38: A:19 B:20 C:15 AB:0 BC:1 CA:1
+Smoothing: 20
+Face 39: A:19 B:24 C:20 AB:1 BC:1 CA:0
+Smoothing: 20
+Face 40: A:20 B:26 C:21 AB:0 BC:1 CA:1
+Smoothing: 21
+Face 41: A:20 B:25 C:26 AB:1 BC:1 CA:0
+Smoothing: 21
+Face 42: A:21 B:27 C:22 AB:0 BC:1 CA:1
+Smoothing: 22
+Face 43: A:21 B:26 C:27 AB:1 BC:1 CA:0
+Smoothing: 22
+Face 44: A:22 B:28 C:23 AB:0 BC:1 CA:1
+Smoothing: 23
+Face 45: A:22 B:27 C:28 AB:1 BC:1 CA:0
+Smoothing: 23
+Face 46: A:23 B:29 C:24 AB:0 BC:1 CA:1
+Smoothing: 24
+Face 47: A:23 B:28 C:29 AB:1 BC:1 CA:0
+Smoothing: 24
+Face 48: A:24 B:25 C:20 AB:0 BC:1 CA:1
+Smoothing: 25
+Face 49: A:24 B:29 C:25 AB:1 BC:1 CA:0
+Smoothing: 25
+Face 50: A:25 B:31 C:26 AB:0 BC:1 CA:1
+Smoothing: 26
+Face 51: A:25 B:30 C:31 AB:1 BC:1 CA:0
+Smoothing: 26
+Face 52: A:26 B:32 C:27 AB:0 BC:1 CA:1
+Smoothing: 27
+Face 53: A:26 B:31 C:32 AB:1 BC:1 CA:0
+Smoothing: 27
+Face 54: A:27 B:33 C:28 AB:0 BC:1 CA:1
+Smoothing: 28
+Face 55: A:27 B:32 C:33 AB:1 BC:1 CA:0
+Smoothing: 28
+Face 56: A:28 B:34 C:29 AB:0 BC:1 CA:1
+Smoothing: 29
+Face 57: A:28 B:33 C:34 AB:1 BC:1 CA:0
+Smoothing: 29
+Face 58: A:29 B:30 C:25 AB:0 BC:1 CA:1
+Smoothing: 30
+Face 59: A:29 B:34 C:30 AB:1 BC:1 CA:0
+Smoothing: 30
+Face 60: A:30 B:36 C:31 AB:0 BC:1 CA:1
+Smoothing: 31
+Face 61: A:30 B:35 C:36 AB:1 BC:1 CA:0
+Smoothing: 31
+Face 62: A:31 B:37 C:32 AB:0 BC:1 CA:1
+Smoothing: 32
+Face 63: A:31 B:36 C:37 AB:1 BC:1 CA:0
+Smoothing: 32
+Face 64: A:32 B:38 C:33 AB:0 BC:1 CA:1
+Smoothing: 1
+Face 65: A:32 B:37 C:38 AB:1 BC:1 CA:0
+Smoothing: 1
+Face 66: A:33 B:39 C:34 AB:0 BC:1 CA:1
+Smoothing: 2
+Face 67: A:33 B:38 C:39 AB:1 BC:1 CA:0
+Smoothing: 2
+Face 68: A:34 B:35 C:30 AB:0 BC:1 CA:1
+
+ Page 3
+
+
+
+Smoothing: 3
+Face 69: A:34 B:39 C:35 AB:1 BC:1 CA:0
+Smoothing: 3
+Face 70: A:35 B:1 C:36 AB:0 BC:1 CA:1
+Smoothing: 4
+Face 71: A:35 B:0 C:1 AB:1 BC:1 CA:0
+Smoothing: 4
+Face 72: A:36 B:2 C:37 AB:0 BC:1 CA:1
+Smoothing: 5
+Face 73: A:36 B:1 C:2 AB:1 BC:1 CA:0
+Smoothing: 5
+Face 74: A:37 B:3 C:38 AB:0 BC:1 CA:1
+Smoothing: 6
+Face 75: A:37 B:2 C:3 AB:1 BC:1 CA:0
+Smoothing: 6
+Face 76: A:38 B:4 C:39 AB:0 BC:1 CA:1
+Smoothing: 7
+Face 77: A:38 B:3 C:4 AB:1 BC:1 CA:0
+Smoothing: 7
+Face 78: A:39 B:0 C:35 AB:0 BC:1 CA:1
+Smoothing: 8
+Face 79: A:39 B:4 C:0 AB:1 BC:1 CA:0
+Smoothing: 8
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Page 4
+
+
+
diff --git a/progs/ggi/tube.asc b/progs/ggi/tube.asc
new file mode 100644
index 00000000000..0b5dd0d810b
--- /dev/null
+++ b/progs/ggi/tube.asc
@@ -0,0 +1,396 @@
+Ambient light color: Red=0.039216 Green=0.039216 Blue=0.039216
+
+Named object: "Object01"
+Tri-mesh, Vertices: 64 Faces: 128
+Vertex list:
+Vertex 0: X: 61.483898 Y: 37.836231 Z: -70.94294
+Vertex 1: X: 82.867447 Y: 37.836235 Z: -41.288902
+Vertex 2: X: 91.275154 Y: 37.836239 Z: -5.70901
+Vertex 3: X: 85.427025 Y: 37.836243 Z: 30.380013
+Vertex 4: X: 66.213379 Y: 37.836243 Z: 61.483936
+Vertex 5: X: 36.559322 Y: 37.836246 Z: 82.86747
+Vertex 6: X: 0.979424 Y: 37.836246 Z: 91.275154
+Vertex 7: X: -35.109554 Y: 37.836246 Z: 85.42701
+Vertex 8: X: -66.213478 Y: 37.836246 Z: 66.213356
+Vertex 9: X: -87.597 Y: 37.836243 Z: 36.559303
+Vertex 10: X: -96.004677 Y: 37.836239 Z: 0.979406
+Vertex 11: X: -90.156517 Y: 37.836235 Z: -35.109615
+Vertex 12: X: -70.942848 Y: 37.836235 Z: -66.213516
+Vertex 13: X: -41.288776 Y: 37.836231 Z: -87.597023
+Vertex 14: X: -5.708872 Y: 37.836231 Z: -96.004692
+Vertex 15: X: 30.380142 Y: 37.836231 Z: -90.156502
+Vertex 16: X: 61.483898 Y: -38.14529 Z: -70.942932
+Vertex 17: X: 82.867447 Y: -38.145287 Z: -41.288895
+Vertex 18: X: 91.275154 Y: -38.145283 Z: -5.709003
+Vertex 19: X: 85.427025 Y: -38.145279 Z: 30.38002
+Vertex 20: X: 66.213379 Y: -38.145279 Z: 61.483944
+Vertex 21: X: 36.559322 Y: -38.145275 Z: 82.867477
+Vertex 22: X: 0.979424 Y: -38.145275 Z: 91.275162
+Vertex 23: X: -35.109554 Y: -38.145275 Z: 85.427017
+Vertex 24: X: -66.213478 Y: -38.145275 Z: 66.213364
+Vertex 25: X: -87.597 Y: -38.145279 Z: 36.559311
+Vertex 26: X: -96.004677 Y: -38.145283 Z: 0.979412
+Vertex 27: X: -90.156517 Y: -38.145287 Z: -35.109608
+Vertex 28: X: -70.942848 Y: -38.145287 Z: -66.213516
+Vertex 29: X: -41.288776 Y: -38.14529 Z: -87.597015
+Vertex 30: X: -5.708872 Y: -38.14529 Z: -96.004684
+Vertex 31: X: 30.380142 Y: -38.14529 Z: -90.156494
+Vertex 32: X: 29.53923 Y: 37.836235 Z: -36.632011
+Vertex 33: X: 40.224194 Y: 37.836239 Z: -21.814436
+Vertex 34: X: 44.425369 Y: 37.836239 Z: -4.035822
+Vertex 35: X: 41.503166 Y: 37.836239 Z: 13.997195
+Vertex 36: X: 31.902466 Y: 37.836243 Z: 29.539249
+Vertex 37: X: 17.084883 Y: 37.836243 Z: 40.224201
+Vertex 38: X: -0.693734 Y: 37.836243 Z: 44.425365
+Vertex 39: X: -18.726728 Y: 37.836243 Z: 41.503159
+Vertex 40: X: -34.26878 Y: 37.836243 Z: 31.902454
+Vertex 41: X: -44.953732 Y: 37.836239 Z: 17.084871
+Vertex 42: X: -49.154892 Y: 37.836239 Z: -0.693745
+Vertex 43: X: -46.232677 Y: 37.836239 Z: -18.726759
+Vertex 44: X: -36.631962 Y: 37.836235 Z: -34.268806
+Vertex 45: X: -21.814371 Y: 37.836235 Z: -44.953747
+Vertex 46: X: -4.035751 Y: 37.836235 Z: -49.1549
+Vertex 47: X: 13.997261 Y: 37.836235 Z: -46.23267
+Vertex 48: X: 29.53923 Y: -38.145287 Z: -36.632004
+Vertex 49: X: 40.224194 Y: -38.145283 Z: -21.814428
+Vertex 50: X: 44.425369 Y: -38.145283 Z: -4.035816
+Vertex 51: X: 41.503166 Y: -38.145283 Z: 13.997201
+Vertex 52: X: 31.902466 Y: -38.145279 Z: 29.539257
+Vertex 53: X: 17.084883 Y: -38.145279 Z: 40.224209
+Vertex 54: X: -0.693734 Y: -38.145279 Z: 44.425373
+Vertex 55: X: -18.726728 Y: -38.145279 Z: 41.503166
+
+ Page 1
+
+
+
+Vertex 56: X: -34.26878 Y: -38.145279 Z: 31.902462
+Vertex 57: X: -44.953732 Y: -38.145283 Z: 17.084879
+Vertex 58: X: -49.154892 Y: -38.145283 Z: -0.693738
+Vertex 59: X: -46.232677 Y: -38.145283 Z: -18.726751
+Vertex 60: X: -36.631962 Y: -38.145287 Z: -34.268799
+Vertex 61: X: -21.814371 Y: -38.145287 Z: -44.953739
+Vertex 62: X: -4.035751 Y: -38.145287 Z: -49.154892
+Vertex 63: X: 13.997261 Y: -38.145287 Z: -46.232662
+Face list:
+Face 0: A:0 B:1 C:17 AB:1 BC:1 CA:0
+Smoothing: 1
+Face 1: A:0 B:17 C:16 AB:0 BC:1 CA:1
+Smoothing: 1
+Face 2: A:1 B:2 C:18 AB:1 BC:1 CA:0
+Smoothing: 2
+Face 3: A:1 B:18 C:17 AB:0 BC:1 CA:1
+Smoothing: 2
+Face 4: A:2 B:3 C:19 AB:1 BC:1 CA:0
+Smoothing: 3
+Face 5: A:2 B:19 C:18 AB:0 BC:1 CA:1
+Smoothing: 3
+Face 6: A:3 B:4 C:20 AB:1 BC:1 CA:0
+Smoothing: 4
+Face 7: A:3 B:20 C:19 AB:0 BC:1 CA:1
+Smoothing: 4
+Face 8: A:4 B:5 C:21 AB:1 BC:1 CA:0
+Smoothing: 5
+Face 9: A:4 B:21 C:20 AB:0 BC:1 CA:1
+Smoothing: 5
+Face 10: A:5 B:6 C:22 AB:1 BC:1 CA:0
+Smoothing: 6
+Face 11: A:5 B:22 C:21 AB:0 BC:1 CA:1
+Smoothing: 6
+Face 12: A:6 B:7 C:23 AB:1 BC:1 CA:0
+Smoothing: 7
+Face 13: A:6 B:23 C:22 AB:0 BC:1 CA:1
+Smoothing: 7
+Face 14: A:7 B:8 C:24 AB:1 BC:1 CA:0
+Smoothing: 8
+Face 15: A:7 B:24 C:23 AB:0 BC:1 CA:1
+Smoothing: 8
+Face 16: A:8 B:9 C:25 AB:1 BC:1 CA:0
+Smoothing: 9
+Face 17: A:8 B:25 C:24 AB:0 BC:1 CA:1
+Smoothing: 9
+Face 18: A:9 B:10 C:26 AB:1 BC:1 CA:0
+Smoothing: 10
+Face 19: A:9 B:26 C:25 AB:0 BC:1 CA:1
+Smoothing: 10
+Face 20: A:10 B:11 C:27 AB:1 BC:1 CA:0
+Smoothing: 11
+Face 21: A:10 B:27 C:26 AB:0 BC:1 CA:1
+Smoothing: 11
+Face 22: A:11 B:12 C:28 AB:1 BC:1 CA:0
+Smoothing: 12
+Face 23: A:11 B:28 C:27 AB:0 BC:1 CA:1
+Smoothing: 12
+Face 24: A:12 B:13 C:29 AB:1 BC:1 CA:0
+Smoothing: 13
+Face 25: A:12 B:29 C:28 AB:0 BC:1 CA:1
+Smoothing: 13
+
+ Page 2
+
+
+
+Face 26: A:13 B:14 C:30 AB:1 BC:1 CA:0
+Smoothing: 14
+Face 27: A:13 B:30 C:29 AB:0 BC:1 CA:1
+Smoothing: 14
+Face 28: A:14 B:15 C:31 AB:1 BC:1 CA:0
+Smoothing: 15
+Face 29: A:14 B:31 C:30 AB:0 BC:1 CA:1
+Smoothing: 15
+Face 30: A:15 B:0 C:16 AB:1 BC:1 CA:0
+Smoothing: 16
+Face 31: A:15 B:16 C:31 AB:0 BC:1 CA:1
+Smoothing: 16
+Face 32: A:32 B:49 C:33 AB:0 BC:1 CA:1
+Smoothing: 17
+Face 33: A:32 B:48 C:49 AB:1 BC:1 CA:0
+Smoothing: 17
+Face 34: A:33 B:50 C:34 AB:0 BC:1 CA:1
+Smoothing: 18
+Face 35: A:33 B:49 C:50 AB:1 BC:1 CA:0
+Smoothing: 18
+Face 36: A:34 B:51 C:35 AB:0 BC:1 CA:1
+Smoothing: 19
+Face 37: A:34 B:50 C:51 AB:1 BC:1 CA:0
+Smoothing: 19
+Face 38: A:35 B:52 C:36 AB:0 BC:1 CA:1
+Smoothing: 20
+Face 39: A:35 B:51 C:52 AB:1 BC:1 CA:0
+Smoothing: 20
+Face 40: A:36 B:53 C:37 AB:0 BC:1 CA:1
+Smoothing: 21
+Face 41: A:36 B:52 C:53 AB:1 BC:1 CA:0
+Smoothing: 21
+Face 42: A:37 B:54 C:38 AB:0 BC:1 CA:1
+Smoothing: 22
+Face 43: A:37 B:53 C:54 AB:1 BC:1 CA:0
+Smoothing: 22
+Face 44: A:38 B:55 C:39 AB:0 BC:1 CA:1
+Smoothing: 23
+Face 45: A:38 B:54 C:55 AB:1 BC:1 CA:0
+Smoothing: 23
+Face 46: A:39 B:56 C:40 AB:0 BC:1 CA:1
+Smoothing: 24
+Face 47: A:39 B:55 C:56 AB:1 BC:1 CA:0
+Smoothing: 24
+Face 48: A:40 B:57 C:41 AB:0 BC:1 CA:1
+Smoothing: 25
+Face 49: A:40 B:56 C:57 AB:1 BC:1 CA:0
+Smoothing: 25
+Face 50: A:41 B:58 C:42 AB:0 BC:1 CA:1
+Smoothing: 26
+Face 51: A:41 B:57 C:58 AB:1 BC:1 CA:0
+Smoothing: 26
+Face 52: A:42 B:59 C:43 AB:0 BC:1 CA:1
+Smoothing: 27
+Face 53: A:42 B:58 C:59 AB:1 BC:1 CA:0
+Smoothing: 27
+Face 54: A:43 B:60 C:44 AB:0 BC:1 CA:1
+Smoothing: 28
+Face 55: A:43 B:59 C:60 AB:1 BC:1 CA:0
+Smoothing: 28
+Face 56: A:44 B:61 C:45 AB:0 BC:1 CA:1
+
+ Page 3
+
+
+
+Smoothing: 29
+Face 57: A:44 B:60 C:61 AB:1 BC:1 CA:0
+Smoothing: 29
+Face 58: A:45 B:62 C:46 AB:0 BC:1 CA:1
+Smoothing: 30
+Face 59: A:45 B:61 C:62 AB:1 BC:1 CA:0
+Smoothing: 30
+Face 60: A:46 B:63 C:47 AB:0 BC:1 CA:1
+Smoothing: 31
+Face 61: A:46 B:62 C:63 AB:1 BC:1 CA:0
+Smoothing: 31
+Face 62: A:47 B:48 C:32 AB:0 BC:1 CA:1
+Smoothing: 32
+Face 63: A:47 B:63 C:48 AB:1 BC:1 CA:0
+Smoothing: 32
+Face 64: A:0 B:32 C:33 AB:0 BC:1 CA:0
+Smoothing: 1
+Face 65: A:0 B:33 C:1 AB:0 BC:0 CA:1
+Smoothing: 1
+Face 66: A:1 B:33 C:34 AB:0 BC:1 CA:0
+Smoothing: 1
+Face 67: A:1 B:34 C:2 AB:0 BC:0 CA:1
+Smoothing: 1
+Face 68: A:2 B:34 C:35 AB:0 BC:1 CA:0
+Smoothing: 1
+Face 69: A:2 B:35 C:3 AB:0 BC:0 CA:1
+Smoothing: 1
+Face 70: A:3 B:35 C:36 AB:0 BC:1 CA:0
+Smoothing: 1
+Face 71: A:3 B:36 C:4 AB:0 BC:0 CA:1
+Smoothing: 1
+Face 72: A:4 B:36 C:37 AB:0 BC:1 CA:0
+Smoothing: 1
+Face 73: A:4 B:37 C:5 AB:0 BC:0 CA:1
+Smoothing: 1
+Face 74: A:5 B:37 C:38 AB:0 BC:1 CA:0
+Smoothing: 1
+Face 75: A:5 B:38 C:6 AB:0 BC:0 CA:1
+Smoothing: 1
+Face 76: A:6 B:38 C:39 AB:0 BC:1 CA:0
+Smoothing: 1
+Face 77: A:6 B:39 C:7 AB:0 BC:0 CA:1
+Smoothing: 1
+Face 78: A:7 B:39 C:40 AB:0 BC:1 CA:0
+Smoothing: 1
+Face 79: A:7 B:40 C:8 AB:0 BC:0 CA:1
+Smoothing: 1
+Face 80: A:8 B:40 C:41 AB:0 BC:1 CA:0
+Smoothing: 1
+Face 81: A:8 B:41 C:9 AB:0 BC:0 CA:1
+Smoothing: 1
+Face 82: A:9 B:41 C:42 AB:0 BC:1 CA:0
+Smoothing: 1
+Face 83: A:9 B:42 C:10 AB:0 BC:0 CA:1
+Smoothing: 1
+Face 84: A:10 B:42 C:43 AB:0 BC:1 CA:0
+Smoothing: 1
+Face 85: A:10 B:43 C:11 AB:0 BC:0 CA:1
+Smoothing: 1
+Face 86: A:11 B:43 C:44 AB:0 BC:1 CA:0
+Smoothing: 1
+
+ Page 4
+
+
+
+Face 87: A:11 B:44 C:12 AB:0 BC:0 CA:1
+Smoothing: 1
+Face 88: A:12 B:44 C:45 AB:0 BC:1 CA:0
+Smoothing: 1
+Face 89: A:12 B:45 C:13 AB:0 BC:0 CA:1
+Smoothing: 1
+Face 90: A:13 B:45 C:46 AB:0 BC:1 CA:0
+Smoothing: 1
+Face 91: A:13 B:46 C:14 AB:0 BC:0 CA:1
+Smoothing: 1
+Face 92: A:14 B:46 C:47 AB:0 BC:1 CA:0
+Smoothing: 1
+Face 93: A:14 B:47 C:15 AB:0 BC:0 CA:1
+Smoothing: 1
+Face 94: A:15 B:47 C:32 AB:0 BC:1 CA:0
+Smoothing: 1
+Face 95: A:15 B:32 C:0 AB:0 BC:0 CA:1
+Smoothing: 1
+Face 96: A:16 B:17 C:49 AB:1 BC:0 CA:0
+Smoothing: 2
+Face 97: A:16 B:49 C:48 AB:0 BC:1 CA:0
+Smoothing: 2
+Face 98: A:17 B:18 C:50 AB:1 BC:0 CA:0
+Smoothing: 2
+Face 99: A:17 B:50 C:49 AB:0 BC:1 CA:0
+Smoothing: 2
+Face 100: A:18 B:19 C:51 AB:1 BC:0 CA:0
+Smoothing: 2
+Face 101: A:18 B:51 C:50 AB:0 BC:1 CA:0
+Smoothing: 2
+Face 102: A:19 B:20 C:52 AB:1 BC:0 CA:0
+Smoothing: 2
+Face 103: A:19 B:52 C:51 AB:0 BC:1 CA:0
+Smoothing: 2
+Face 104: A:20 B:21 C:53 AB:1 BC:0 CA:0
+Smoothing: 2
+Face 105: A:20 B:53 C:52 AB:0 BC:1 CA:0
+Smoothing: 2
+Face 106: A:21 B:22 C:54 AB:1 BC:0 CA:0
+Smoothing: 2
+Face 107: A:21 B:54 C:53 AB:0 BC:1 CA:0
+Smoothing: 2
+Face 108: A:22 B:23 C:55 AB:1 BC:0 CA:0
+Smoothing: 2
+Face 109: A:22 B:55 C:54 AB:0 BC:1 CA:0
+Smoothing: 2
+Face 110: A:23 B:24 C:56 AB:1 BC:0 CA:0
+Smoothing: 2
+Face 111: A:23 B:56 C:55 AB:0 BC:1 CA:0
+Smoothing: 2
+Face 112: A:24 B:25 C:57 AB:1 BC:0 CA:0
+Smoothing: 2
+Face 113: A:24 B:57 C:56 AB:0 BC:1 CA:0
+Smoothing: 2
+Face 114: A:25 B:26 C:58 AB:1 BC:0 CA:0
+Smoothing: 2
+Face 115: A:25 B:58 C:57 AB:0 BC:1 CA:0
+Smoothing: 2
+Face 116: A:26 B:27 C:59 AB:1 BC:0 CA:0
+Smoothing: 2
+Face 117: A:26 B:59 C:58 AB:0 BC:1 CA:0
+
+ Page 5
+
+
+
+Smoothing: 2
+Face 118: A:27 B:28 C:60 AB:1 BC:0 CA:0
+Smoothing: 2
+Face 119: A:27 B:60 C:59 AB:0 BC:1 CA:0
+Smoothing: 2
+Face 120: A:28 B:29 C:61 AB:1 BC:0 CA:0
+Smoothing: 2
+Face 121: A:28 B:61 C:60 AB:0 BC:1 CA:0
+Smoothing: 2
+Face 122: A:29 B:30 C:62 AB:1 BC:0 CA:0
+Smoothing: 2
+Face 123: A:29 B:62 C:61 AB:0 BC:1 CA:0
+Smoothing: 2
+Face 124: A:30 B:31 C:63 AB:1 BC:0 CA:0
+Smoothing: 2
+Face 125: A:30 B:63 C:62 AB:0 BC:1 CA:0
+Smoothing: 2
+Face 126: A:31 B:16 C:48 AB:1 BC:0 CA:0
+Smoothing: 2
+Face 127: A:31 B:48 C:63 AB:0 BC:1 CA:0
+Smoothing: 2
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Page 6
+
+
+
diff --git a/progs/miniglx/Makefile b/progs/miniglx/Makefile
new file mode 100644
index 00000000000..7f1e162186f
--- /dev/null
+++ b/progs/miniglx/Makefile
@@ -0,0 +1,58 @@
+# Makefile for miniglx demo programs
+
+TOP = ../..
+
+include $(TOP)/configs/current
+
+
+SOURCES = miniglxtest.c \
+ miniglxsample.c \
+ sample_server.c \
+ sample_server2.c \
+ manytex.c \
+ texline.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/miniglx/glfbdevtest.c b/progs/miniglx/glfbdevtest.c
new file mode 100644
index 00000000000..c82ca6e5f63
--- /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 <assert.h>
+#include <errno.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/ioctl.h>
+#include <sys/mman.h>
+#include <sys/types.h>
+#include <linux/fb.h>
+#include <linux/kd.h>
+#include <linux/vt.h>
+#include <GL/glut.h>
+#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..36fa10d222b
--- /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 <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+#include <GL/glut.h>
+
+
+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 <number of texture objects>\n");
+ printf(" -size <width> <height> - 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 <n> - Set lower priority on <n> 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 <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <GL/gl.h>
+
+#if USE_MINIGLX
+#include <GL/miniglx.h>
+#else
+#include <GL/glx.h>
+#include <X11/Xlib.h>
+#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..ecc5786b73a
--- /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 <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <GL/gl.h>
+#define USE_MINI_GLX 1
+#if USE_MINI_GLX
+#include <GL/miniglx.h>
+#else
+#include <GL/glx.h>
+#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..039c04fa40a
--- /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 <stdio.h>
+#include <stdlib.h>
+#include <GL/gl.h>
+#include <GL/miniglx.h>
+
+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..58effcf484d
--- /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 <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <GL/gl.h>
+#include <GL/miniglx.h>
+#include <errno.h>
+#include <assert.h>
+
+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..d2a97d2876e
--- /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 <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <GL/glut.h>
+#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/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/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/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/slang/Makefile b/progs/slang/Makefile
new file mode 100644
index 00000000000..1c602ce49c5
--- /dev/null
+++ b/progs/slang/Makefile
@@ -0,0 +1,55 @@
+# progs/slang/Makefile
+
+TOP = ../..
+
+include $(TOP)/configs/current
+
+INCDIR = $(TOP)/include
+
+LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME)
+
+#
+# targets
+#
+
+.PHONY: default tests clean
+
+default: cltest sotest vstest
+
+tests: default
+ ! ./sotest 2> /dev/null | (grep -e ^[*][*][*])
+ ! ./vstest 2> /dev/null | (grep -e ^[*][*][*])
+ ! ./cltest 2> /dev/null | (grep -e ^[*][*][*])
+
+clean:
+ rm -f cltest.o sotest.o vstest.o framework.o cltest sotest vstest
+
+#
+# executables
+#
+
+cltest: cltest.o framework.o $(LIB_DEP)
+ $(CC) cltest.o framework.o $(APP_LIB_DEPS) -o cltest
+
+sotest: sotest.o framework.o $(LIB_DEP)
+ $(CC) sotest.o framework.o $(APP_LIB_DEPS) -o sotest
+
+vstest: vstest.o framework.o $(LIB_DEP)
+ $(CC) vstest.o framework.o $(APP_LIB_DEPS) -o vstest
+
+#
+# objects
+#
+
+framework.o: framework.c framework.h
+ $(CC) -c -I$(INCDIR) framework.c -o framework.o
+
+cltest.o: cltest.c framework.h
+ $(CC) -c -I$(INCDIR) cltest.c -o cltest.o
+
+sotest.o: sotest.c framework.h
+ $(CC) -c -I$(INCDIR) sotest.c -o sotest.o
+
+vstest.o: vstest.c framework.h
+ $(CC) -c -I$(INCDIR) vstest.c -o vstest.o
+
diff --git a/progs/slang/README b/progs/slang/README
new file mode 100644
index 00000000000..13a6aaad348
--- /dev/null
+++ b/progs/slang/README
@@ -0,0 +1,7 @@
+GLSL regression tests.
+
+Type "make" to build all test apps.
+
+Type "make tests" to build and run all test apps. If any
+error is detected, a line starting with *** is output.
+
diff --git a/progs/slang/cltest.c b/progs/slang/cltest.c
new file mode 100644
index 00000000000..2753f59f85b
--- /dev/null
+++ b/progs/slang/cltest.c
@@ -0,0 +1,253 @@
+/*
+ * GL_ARB_shading_language_100 test application.
+ *
+ * Tests correctness of emited code. Runs multiple well-formed shaders and checks if
+ * they produce valid results.
+ *
+ * Requires specific support on the GL implementation side. A special function printMESA()
+ * must be supported in the language that prints current values of generic type
+ * to the appropriate shader's info log, and optionally to the screen.
+ *
+ * Author: Michal Krol
+ */
+
+#include "framework.h"
+
+#define EPSILON 0.0001f
+
+static GLhandleARB vert = 0;
+static GLhandleARB prog = 0;
+
+static int get_line (FILE *f, char *line, int size)
+{
+ if (fgets (line, size, f) == NULL)
+ return 0;
+ if (line[strlen (line) - 1] == '\n')
+ line[strlen (line) - 1] = '\0';
+ return 1;
+}
+
+struct ATTRIB
+{
+ char name[32];
+ GLfloat value[64][4];
+ GLuint count;
+};
+
+struct ATTRIBS
+{
+ struct ATTRIB attrib[32];
+ GLuint count;
+};
+
+struct SHADER
+{
+ char code[16000];
+ GLfloat output[1000];
+ GLuint count;
+};
+
+enum SHADER_LOAD_STATE
+{
+ SLS_NONE,
+ SLS_CODE,
+ SLS_OUTPUT
+};
+
+struct PROGRAM
+{
+ struct PROGRAM *next;
+ char name[256];
+ struct ATTRIBS attribs;
+ struct SHADER vertex;
+};
+
+enum PROGRAM_LOAD_STATE
+{
+ PLS_NONE,
+ PLS_ATTRIB,
+ PLS_VERTEX
+};
+
+static struct PROGRAM *program = NULL;
+
+static void load_test_file (const char *filename, struct PROGRAM **program)
+{
+ struct PROGRAM **currprog = program;
+ FILE *f;
+ char line[256];
+ enum PROGRAM_LOAD_STATE pls = PLS_NONE;
+ enum SHADER_LOAD_STATE sls = SLS_NONE;
+
+ f = fopen (filename, "r");
+ if (f == NULL)
+ return;
+
+ while (get_line (f, line, sizeof (line))) {
+ if (line[0] == '$') {
+ if (strncmp (line + 1, "program", 7) == 0) {
+ if (*currprog != NULL)
+ currprog = &(**currprog).next;
+ *currprog = (struct PROGRAM *) (malloc (sizeof (struct PROGRAM)));
+ if (*currprog == NULL)
+ break;
+ (**currprog).next = NULL;
+ strcpy ((**currprog).name, line + 9);
+ (**currprog).attribs.count = 0;
+ (**currprog).vertex.code[0] = '\0';
+ (**currprog).vertex.count = 0;
+ pls = PLS_NONE;
+ }
+ else if (strncmp (line + 1, "attrib", 6) == 0) {
+ if (*currprog == NULL)
+ break;
+ strcpy ((**currprog).attribs.attrib[(**currprog).attribs.count].name, line + 8);
+ (**currprog).attribs.attrib[(**currprog).attribs.count].count = 0;
+ (**currprog).attribs.count++;
+ pls = PLS_ATTRIB;
+ }
+ else if (strcmp (line + 1, "vertex") == 0) {
+ if (*currprog == NULL)
+ break;
+ pls = PLS_VERTEX;
+ sls = SLS_NONE;
+ }
+ else if (strcmp (line + 1, "code") == 0) {
+ if (*currprog == NULL || pls != PLS_VERTEX)
+ break;
+ sls = SLS_CODE;
+ }
+ else if (strcmp (line + 1, "output") == 0) {
+ if (*currprog == NULL || pls != PLS_VERTEX)
+ break;
+ sls = SLS_OUTPUT;
+ }
+ }
+ else {
+ if ((*currprog == NULL || pls == PLS_NONE || sls == SLS_NONE) && line[0] != '\0')
+ break;
+ if (*currprog != NULL && pls == PLS_VERTEX) {
+ if (sls == SLS_CODE) {
+ strcat ((**currprog).vertex.code, line);
+ strcat ((**currprog).vertex.code, "\n");
+ }
+ else if (sls == SLS_OUTPUT && line[0] != '\0') {
+ if (strcmp (line, "true") == 0)
+ (**currprog).vertex.output[(**currprog).vertex.count] = 1.0f;
+ else if (strcmp (line, "false") == 0)
+ (**currprog).vertex.output[(**currprog).vertex.count] = 0.0f;
+ else
+ sscanf (line, "%f", &(**currprog).vertex.output[(**currprog).vertex.count]);
+ (**currprog).vertex.count++;
+ }
+ }
+ else if (*currprog != NULL && pls == PLS_ATTRIB && line[0] != '\0') {
+ struct ATTRIB *att = &(**currprog).attribs.attrib[(**currprog).attribs.count - 1];
+ GLfloat *vec = att->value[att->count];
+ sscanf (line, "%f %f %f %f", &vec[0], &vec[1], &vec[2], &vec[3]);
+ att->count++;
+ }
+ }
+ }
+
+ fclose (f);
+}
+
+void InitScene (void)
+{
+ prog = glCreateProgramObjectARB ();
+ vert = glCreateShaderObjectARB (GL_VERTEX_SHADER_ARB);
+ glAttachObjectARB (prog, vert);
+ glDeleteObjectARB (vert);
+ load_test_file ("cltest.txt", &program);
+}
+
+void RenderScene (void)
+{
+ struct PROGRAM *nextprogram;
+ char *code;
+ GLint info_length, length;
+ char output[65000], *p;
+ GLuint i;
+
+ if (program == NULL)
+ exit (0);
+
+ code = program->vertex.code;
+ glShaderSourceARB (vert, 1, (const GLcharARB **) (&code), NULL);
+ glCompileShaderARB (vert);
+ CheckObjectStatus (vert);
+
+ for (i = 0; i < program->attribs.count; i++) {
+ const char *name = program->attribs.attrib[i].name;
+ if (strcmp (name, "gl_Vertex") != 0)
+ glBindAttribLocationARB (prog, i, name);
+ }
+
+ glLinkProgramARB (prog);
+ CheckObjectStatus (prog);
+ glUseProgramObjectARB (prog);
+
+ printf ("\n--- %s\n", program->name);
+
+ glGetObjectParameterivARB (vert, GL_OBJECT_INFO_LOG_LENGTH_ARB, &info_length);
+
+ glBegin (GL_POINTS);
+ if (program->attribs.count == 0) {
+ glVertex2f (0.0f, 0.0f);
+ }
+ else {
+ for (i = 0; i < program->attribs.attrib[0].count; i++) {
+ GLuint j;
+ for (j = 0; j < program->attribs.count; j++) {
+ GLuint n = (j + 1) % program->attribs.count;
+ GLfloat *vec = program->attribs.attrib[n].value[i];
+ const char *name = program->attribs.attrib[n].name;
+ if (strcmp (name, "gl_Vertex") == 0)
+ glVertex4fv (vec);
+ else
+ glVertexAttrib4fvARB (n, vec);
+ }
+ }
+ }
+ glEnd ();
+ glFlush ();
+
+ glGetInfoLogARB (vert, sizeof (output), &length, output);
+ p = output + info_length - 1;
+ for (i = 0; i < program->vertex.count; i++) {
+ GLfloat value;
+ if (p == NULL) {
+ printf ("*** %s\n", "I/O error");
+ break;
+ }
+ if (strncmp (p, "true", 4) == 0)
+ value = 1.0f;
+ else if (strncmp (p, "false", 5) == 0)
+ value = 0.0f;
+ else if (sscanf (p, "%f", &value) != 1) {
+ printf ("*** %s\n", "I/O error");
+ break;
+ }
+ if (fabs (value - program->vertex.output[i]) > EPSILON) {
+ printf ("*** Values are different, is %f, should be %f\n", value,
+ program->vertex.output[i]);
+ }
+ p = strchr (p, '\n');
+ if (p != NULL)
+ p++;
+ }
+ if (*p != '\0')
+ printf ("*** %s\n", "I/O error");
+
+ nextprogram = program->next;
+ free (program);
+ program = nextprogram;
+}
+
+int main (int argc, char *argv[])
+{
+ InitFramework (&argc, argv);
+ return 0;
+}
+
diff --git a/progs/slang/cltest.txt b/progs/slang/cltest.txt
new file mode 100644
index 00000000000..97cc177c9f3
--- /dev/null
+++ b/progs/slang/cltest.txt
@@ -0,0 +1,1615 @@
+$ /*
+$ Shader test script.
+$
+$ Author: Michal Krol
+$
+$ Comment line starts with dollar sign and white space.
+$
+$ $program <name> starts a new test program section called <name>. Contains all other sections.
+$
+$ $attrib <name> starts vertex data input section for attrib called <name>. Each line consists of
+$ four values that form single vertex attrib.
+$
+$ $vertex starts vertex shader section. Contains $code and &output sections.
+$
+$ $code starts source code section. All text in this section gets compiled into appropriate
+$ shader object.
+$
+$ $output starts shader execution results section. These are compared, value-by-value,
+$ with results of executing printMESA() functions within a shader.
+$ */
+
+
+$ /*
+$ --------------------------------------------------------------------------------------------------
+$ Test printMESA() function.
+$ */
+
+$program PRINT TEST
+
+$vertex
+
+$code
+
+#version 110
+
+#extension MESA_shader_debug: require
+
+void main () {
+ gl_Position = gl_ModelViewMatrix * gl_Vertex;
+ gl_FrontColor = vec4 (1.0);
+
+ printMESA (11.1);
+ printMESA (111);
+ printMESA (true);
+
+ printMESA (vec2 (22.1, 22.2));
+ printMESA (vec3 (33.1, 33.2, 33.3));
+ printMESA (vec4 (44.1, 44.2, 44.3, 44.4));
+
+ printMESA (ivec2 (221, 222));
+ printMESA (ivec3 (331, 332, 333));
+ printMESA (ivec4 (441, 442, 443, 444));
+
+ printMESA (bvec2 (false, true));
+ printMESA (bvec3 (true, true, false));
+ printMESA (bvec4 (true, false, true, false));
+
+ printMESA (mat2 (55.11, 55.12, 55.21, 55.22));
+ printMESA (mat3 (66.11, 66.12, 66.13,
+ 66.21, 66.22, 66.23,
+ 66.31, 66.32, 66.33));
+ printMESA (mat4 (77.11, 77.12, 77.13, 77.14,
+ 77.21, 77.22, 77.23, 77.24,
+ 77.31, 77.32, 77.33, 77.34,
+ 77.41, 77.42, 77.43, 77.44));
+}
+
+$output
+
+11.1
+111
+true
+
+22.1
+22.2
+33.1
+33.2
+33.3
+44.1
+44.2
+44.3
+44.4
+
+221
+222
+331
+332
+333
+441
+442
+443
+444
+
+false
+true
+true
+true
+false
+true
+false
+true
+false
+
+55.11
+55.12
+55.21
+55.22
+
+66.11
+66.12
+66.13
+66.21
+66.22
+66.23
+66.31
+66.32
+66.33
+
+77.11
+77.12
+77.13
+77.14
+77.21
+77.22
+77.23
+77.24
+77.31
+77.32
+77.33
+77.34
+77.41
+77.42
+77.43
+77.44
+
+
+$ /*
+$ --------------------------------------------------------------------------------------------------
+$ Test type casting.
+$ */
+
+$program TYPE CAST TEST
+
+$attrib gl_Vertex
+0.0 0.0 0.0 1.0
+
+$attrib _Zero
+0.0 0.0 0.0 0.0
+
+$attrib _One
+1.1 0.0 0.0 0.0
+
+$attrib _Two
+2.2 0.0 0.0 0.0
+
+$attrib _MinusThree
+-3.3 0.0 0.0 0.0
+
+$vertex
+
+$code
+
+#version 110
+
+#extension MESA_shader_debug: require
+
+attribute float _Zero;
+attribute float _One;
+attribute float _Two;
+attribute float _MinusThree;
+
+void main () {
+ gl_Position = gl_ModelViewMatrix * gl_Vertex;
+ gl_FrontColor = vec4 (1.0);
+
+ printMESA (_Zero);
+ printMESA (_One);
+ printMESA (_Two);
+ printMESA (_MinusThree);
+
+ printMESA (float (_Zero));
+ printMESA (float (_One));
+ printMESA (float (_Two));
+ printMESA (float (_MinusThree));
+ printMESA (float (45.99));
+ printMESA (float (-6.17));
+
+ printMESA (bool (_Zero));
+ printMESA (bool (_One));
+ printMESA (bool (_Two));
+ printMESA (bool (_MinusThree));
+ printMESA (bool (45.99));
+ printMESA (bool (-6.17));
+ printMESA (bool (0.0001));
+ printMESA (bool (0.0));
+
+ printMESA (int (_Zero));
+ printMESA (int (_One));
+ printMESA (int (_Two));
+ printMESA (int (_MinusThree));
+ printMESA (int (45.99));
+ printMESA (int (45.22));
+ printMESA (int (-6.17));
+ printMESA (int (-6.87));
+}
+
+$output
+
+0.0
+1.1
+2.2
+-3.3
+
+0.0
+1.1
+2.2
+-3.3
+45.99
+-6.17
+
+false
+true
+true
+true
+true
+true
+true
+false
+
+0
+1
+2
+-3
+45
+45
+-6
+-6
+
+$ /*
+$ --------------------------------------------------------------------------------------------------
+$ Test vector swizzles.
+$ */
+
+$program SWIZZLE TEST
+
+$attrib gl_Vertex
+0.0 0.0 0.0 1.0
+
+$attrib _One
+1.1 1.2 1.3 1.4
+
+$attrib _Two
+2.1 2.2 2.3 2.4
+
+$vertex
+
+$code
+
+#version 110
+
+#extension MESA_shader_debug: require
+
+attribute vec4 _One;
+attribute vec4 _Two;
+
+void assign5678 (out vec4 v)
+{
+ v.x = 5.5;
+ v.y = 6.6;
+ v.z = 7.7;
+ v.w = 8.8;
+}
+
+void main () {
+ gl_Position = gl_ModelViewMatrix * gl_Vertex;
+ gl_FrontColor = vec4 (1.0);
+
+ printMESA (_One);
+ printMESA (_Two);
+
+ printMESA (_One.x);
+ printMESA (_One.y);
+ printMESA (_One.z);
+ printMESA (_One.w);
+
+ printMESA (_Two.xy);
+ printMESA (_Two.yx);
+ printMESA (_Two.xw);
+ printMESA (_Two.wx);
+ printMESA (_Two.yz);
+ printMESA (_Two.zy);
+ printMESA (_Two.xz);
+ printMESA (_Two.zx);
+ printMESA (_Two.zw);
+ printMESA (_Two.wz);
+
+ printMESA (_One.xyz);
+ printMESA (_One.yzx);
+ printMESA (_One.zxy);
+ printMESA (_One.xzy);
+ printMESA (_One.yzw);
+ printMESA (_One.zwx);
+
+ printMESA (_Two.xyzw);
+ printMESA (_Two.yzwx);
+ printMESA (_Two.wzyx);
+ printMESA (_Two.zwyx);
+
+ printMESA (_One.xx);
+ printMESA (_One.zz);
+ printMESA (_One.ww);
+
+ printMESA (_Two.xxx);
+ printMESA (_Two.yyy);
+ printMESA (_Two.www);
+
+ printMESA (_One.xxxx);
+ printMESA (_One.zzzz);
+
+ printMESA (_Two.xxyy);
+ printMESA (_Two.wwxx);
+ printMESA (_Two.zxxw);
+
+ vec4 v;
+
+ v.zxwy = vec4 (5.5, 6.6, 7.7, 8.8);
+ printMESA (v);
+
+ assign5678 (v.ywxz);
+ printMESA (v);
+}
+
+$output
+
+1.1
+1.2
+1.3
+1.4
+2.1
+2.2
+2.3
+2.4
+
+1.1
+1.2
+1.3
+1.4
+
+2.1
+2.2
+2.2
+2.1
+2.1
+2.4
+2.4
+2.1
+2.2
+2.3
+2.3
+2.2
+2.1
+2.3
+2.3
+2.1
+2.3
+2.4
+2.4
+2.3
+
+1.1
+1.2
+1.3
+1.2
+1.3
+1.1
+1.3
+1.1
+1.2
+1.1
+1.3
+1.2
+1.2
+1.3
+1.4
+1.3
+1.4
+1.1
+
+2.1
+2.2
+2.3
+2.4
+2.2
+2.3
+2.4
+2.1
+2.4
+2.3
+2.2
+2.1
+2.3
+2.4
+2.2
+2.1
+
+1.1
+1.1
+1.3
+1.3
+1.4
+1.4
+
+2.1
+2.1
+2.1
+2.2
+2.2
+2.2
+2.4
+2.4
+2.4
+
+1.1
+1.1
+1.1
+1.1
+1.3
+1.3
+1.3
+1.3
+
+2.1
+2.1
+2.2
+2.2
+2.4
+2.4
+2.1
+2.1
+2.3
+2.1
+2.1
+2.4
+
+6.6
+8.8
+5.5
+7.7
+
+7.7
+5.5
+8.8
+6.6
+
+
+$ /*
+$ --------------------------------------------------------------------------------------------------
+$ Test relational operators.
+$ */
+
+$program RELATIONAL OPERATOR TEST
+
+$attrib gl_Vertex
+0.0 0.0 0.0 1.0
+
+$attrib _Two
+2.0 0.0 0.0 0.0
+
+$attrib _Two2
+2.0 0.0 0.0 0.0
+
+$attrib _MinusThree
+-3.0 0.0 0.0 0.0
+
+$vertex
+
+$code
+
+#version 110
+
+#extension MESA_shader_debug: require
+
+attribute float _Two;
+attribute float _Two2;
+attribute float _MinusThree;
+
+struct foo
+{
+ float f;
+ vec4 v4;
+ vec3 v3;
+ mat4 m4;
+ int i;
+ bool b;
+};
+
+void printMESA (const in foo bar)
+{
+ printMESA (bar.f);
+ printMESA (bar.v4);
+ printMESA (bar.v3);
+ printMESA (bar.m4);
+ printMESA (bar.i);
+ printMESA (bar.b);
+}
+
+void main () {
+ gl_Position = gl_ModelViewMatrix * gl_Vertex;
+ gl_FrontColor = vec4 (1.0);
+
+ int iTwo = int (_Two);
+ int iTwo2 = int (_Two2);
+ int iMinusThree = int (_MinusThree);
+
+ printMESA (_Two <= _Two);
+ printMESA (_Two <= _Two2);
+ printMESA (_Two <= _MinusThree);
+ printMESA (_MinusThree <= _Two);
+ printMESA (iTwo <= iTwo);
+ printMESA (iTwo <= iTwo2);
+ printMESA (iTwo <= iMinusThree);
+ printMESA (iMinusThree <= iTwo);
+
+ printMESA (_Two >= _Two);
+ printMESA (_Two >= _Two2);
+ printMESA (_Two >= _MinusThree);
+ printMESA (_MinusThree >= _Two);
+ printMESA (iTwo >= iTwo);
+ printMESA (iTwo >= iTwo2);
+ printMESA (iTwo >= iMinusThree);
+ printMESA (iMinusThree >= iTwo);
+
+ printMESA (_Two < _Two);
+ printMESA (_Two < _Two2);
+ printMESA (_Two < _MinusThree);
+ printMESA (_MinusThree < _Two);
+ printMESA (iTwo < iTwo);
+ printMESA (iTwo < iTwo2);
+ printMESA (iTwo < iMinusThree);
+ printMESA (iMinusThree < iTwo);
+
+ printMESA (_Two > _Two);
+ printMESA (_Two > _Two2);
+ printMESA (_Two > _MinusThree);
+ printMESA (_MinusThree > _Two);
+ printMESA (iTwo > iTwo);
+ printMESA (iTwo > iTwo2);
+ printMESA (iTwo > iMinusThree);
+ printMESA (iMinusThree > iTwo);
+
+ printMESA (_Two == _Two);
+ printMESA (_Two == _Two2);
+ printMESA (_Two == _MinusThree);
+ printMESA (_MinusThree == _MinusThree);
+ printMESA (iTwo == iTwo);
+ printMESA (iTwo == iTwo2);
+ printMESA (iTwo == iMinusThree);
+ printMESA (iMinusThree == iMinusThree);
+
+ printMESA (_Two != _Two);
+ printMESA (_Two != _Two2);
+ printMESA (_Two != _MinusThree);
+ printMESA (_MinusThree != _MinusThree);
+ printMESA (iTwo != iTwo);
+ printMESA (iTwo != iTwo2);
+ printMESA (iTwo != iMinusThree);
+ printMESA (iMinusThree != iMinusThree);
+
+ foo foo1;
+ foo1.f = 13.31;
+ foo1.v4 = vec4 (44.11, 44.22, 44.33, 44.44);
+ foo1.v3 = vec3 (33.11, 33.22, 33.33);
+ foo1.m4 = mat4 (17.88);
+ foo1.i = 666;
+ foo1.b = true;
+ printMESA (foo1);
+
+ // make foo2 the same as foo1
+ foo foo2;
+ foo2.f = 13.31;
+ foo2.v4 = vec4 (44.11, 44.22, 44.33, 44.44);
+ foo2.v3 = vec3 (33.11, 33.22, 33.33);
+ foo2.m4 = mat4 (17.88);
+ foo2.i = 666;
+ foo2.b = true;
+
+ printMESA (foo1 == foo2);
+ printMESA (foo1 != foo2);
+
+ // make them a little bit different
+ foo2.m4[2].y = 333.333;
+ printMESA (foo2);
+
+ printMESA (foo1 == foo2);
+ printMESA (foo1 != foo2);
+}
+
+$output
+
+true
+true
+false
+true
+true
+true
+false
+true
+
+true
+true
+true
+false
+true
+true
+true
+false
+
+false
+false
+false
+true
+false
+false
+false
+true
+
+false
+false
+true
+false
+false
+false
+true
+false
+
+true
+true
+false
+true
+true
+true
+false
+true
+
+false
+false
+true
+false
+false
+false
+true
+false
+
+13.31
+44.11
+44.22
+44.33
+44.44
+33.11
+33.22
+33.33
+17.88
+0.0
+0.0
+0.0
+0.0
+17.88
+0.0
+0.0
+0.0
+0.0
+17.88
+0.0
+0.0
+0.0
+0.0
+17.88
+666
+true
+
+true
+false
+
+13.31
+44.11
+44.22
+44.33
+44.44
+33.11
+33.22
+33.33
+17.88
+0.0
+0.0
+0.0
+0.0
+17.88
+0.0
+0.0
+0.0
+333.333
+17.88
+0.0
+0.0
+0.0
+0.0
+17.88
+666
+true
+
+false
+true
+
+
+$ /*
+$ --------------------------------------------------------------------------------------------------
+$ Test logical operators.
+$ */
+
+$program LOGICAL OPERATOR TEST
+
+$attrib gl_Vertex
+0.0 0.0 0.0 1.0
+
+$attrib _False
+0.0 0.0 0.0 0.0
+
+$attrib _True
+1.0 0.0 0.0 0.0
+
+$attrib _False2
+0.0 0.0 0.0 0.0
+
+$attrib _True2
+1.0 0.0 0.0 0.0
+
+$vertex
+
+$code
+
+#version 110
+
+#extension MESA_shader_debug: require
+
+attribute float _False;
+attribute float _True;
+attribute float _False2;
+attribute float _True2;
+
+void main () {
+ gl_Position = gl_ModelViewMatrix * gl_Vertex;
+ gl_FrontColor = vec4 (1.0);
+
+ printMESA (_False);
+ printMESA (_True);
+ printMESA (_False2);
+ printMESA (_True2);
+
+ bool False = bool (_False);
+ bool True = bool (_True);
+ bool False2 = bool (_False2);
+ bool True2 = bool (_True2);
+
+ //
+ // It is important to test each operator with the following argument types:
+ // * Both arguments are different variables, even if they have the same values.
+ // False and False2 are distinct attributes, but are the same in value.
+ // * Both arguments may be the same variables. This case tests possible
+ // optimizations, e.g. X && X --> X.
+ // * Both arguments are constant. This tests constant folding.
+ //
+
+ printMESA (!False);
+ printMESA (!True);
+ printMESA (!false);
+ printMESA (!true);
+
+ printMESA (False ^^ False2);
+ printMESA (False ^^ True2);
+ printMESA (True ^^ False2);
+ printMESA (True ^^ True2);
+ printMESA (False ^^ False);
+ printMESA (False ^^ True);
+ printMESA (True ^^ False);
+ printMESA (True ^^ True);
+ printMESA (false ^^ false);
+ printMESA (false ^^ true);
+ printMESA (true ^^ false);
+ printMESA (true ^^ true);
+
+ printMESA (False && False2);
+ printMESA (False && True2);
+ printMESA (True && False2);
+ printMESA (True && True2);
+ printMESA (False && False);
+ printMESA (False && True);
+ printMESA (True && False);
+ printMESA (True && True);
+ printMESA (false && false);
+ printMESA (false && true);
+ printMESA (true && false);
+ printMESA (true && true);
+
+ printMESA (False || False2);
+ printMESA (False || True2);
+ printMESA (True || False2);
+ printMESA (True || True2);
+ printMESA (False || False);
+ printMESA (False || True);
+ printMESA (True || False);
+ printMESA (True || True);
+ printMESA (false || false);
+ printMESA (false || true);
+ printMESA (true || false);
+ printMESA (true || true);
+
+ //
+ // Test short-circuit evaluation of && and ||. The right expression evaluation depends
+ // on the value of the left expression. If the right expression has side effects, we
+ // can easily test if it happened.
+ //
+
+ bool x;
+
+ x = false;
+ printMESA (x);
+ printMESA (False && (x = true));
+ printMESA (x);
+
+ x = false;
+ printMESA (x);
+ printMESA (false && (x = true));
+ printMESA (x);
+
+ x = true;
+ printMESA (x);
+ printMESA (True || (x = false));
+ printMESA (x);
+
+ x = true;
+ printMESA (x);
+ printMESA (true || (x = false));
+ printMESA (x);
+}
+
+$output
+
+0.0
+1.0
+0.0
+1.0
+
+true
+false
+true
+false
+
+false
+true
+true
+false
+false
+true
+true
+false
+false
+true
+true
+false
+
+false
+false
+false
+true
+false
+false
+false
+true
+false
+false
+false
+true
+
+false
+true
+true
+true
+false
+true
+true
+true
+false
+true
+true
+true
+
+false
+false
+false
+
+false
+false
+false
+
+true
+true
+true
+
+true
+true
+true
+
+
+$ /*
+$ --------------------------------------------------------------------------------------------------
+$ Test subscript operator/array access.
+$ */
+
+$program ARRAY ACCESS TEST
+
+$attrib gl_Vertex
+0.0 0.0 0.0 1.0
+
+$attrib _Zero
+0.0 0.0 0.0 0.0
+
+$attrib _One
+1.1 0.0 0.0 0.0
+
+$attrib _Two
+2.9 0.0 0.0 0.0
+
+$attrib _Vec
+11.11 22.22 33.33 44.44
+
+$vertex
+
+$code
+
+#version 110
+
+#extension MESA_shader_debug: require
+
+attribute float _Zero;
+attribute float _One;
+attribute float _Two;
+attribute vec4 _Vec;
+
+void main () {
+ gl_Position = gl_ModelViewMatrix * gl_Vertex;
+ gl_FrontColor = vec4 (1.0);
+
+ printMESA (_Zero);
+ printMESA (_One);
+ printMESA (_Two);
+ printMESA (_Vec);
+
+ printMESA (_Vec[0]);
+ printMESA (_Vec[1]);
+ printMESA (_Vec[2]);
+ printMESA (_Vec[3]);
+
+ printMESA (_Vec[int (_Zero)]);
+ printMESA (_Vec[int (_One)]);
+ printMESA (_Vec[int (_Two)]);
+}
+
+$output
+
+0.0
+1.1
+2.9
+11.11
+22.22
+33.33
+44.44
+
+11.11
+22.22
+33.33
+44.44
+
+11.11
+22.22
+33.33
+
+
+$ /*
+$ --------------------------------------------------------------------------------------------------
+$ Test pre/post-increment/decrement operators.
+$ Note: assumes relational operators being correct.
+$ */
+
+$program PRE/POST-INC/DEC OPERATOR TEST
+
+$attrib gl_Vertex
+0.0 0.0 0.0 1.0
+
+$attrib _Zero
+0.0 0.0 0.0 0.0
+
+$attrib _One
+1.1 0.0 0.0 0.0
+
+$attrib _Two4
+2.1 2.2 2.3 2.4
+
+$vertex
+
+$code
+
+#version 110
+
+#extension MESA_shader_debug: require
+
+attribute float _Zero;
+attribute float _One;
+attribute vec4 _Two4;
+
+float fZero, fOne;
+vec4 fTwo4;
+int iZero, iOne;
+ivec4 iTwo4;
+
+void reset () {
+ fZero = _Zero;
+ fOne = _One;
+ fTwo4 = _Two4;
+ iZero = int (_Zero);
+ iOne = int (_One);
+ iTwo4 = ivec4 (_Two4);
+}
+
+void main () {
+ gl_Position = gl_ModelViewMatrix * gl_Vertex;
+ gl_FrontColor = vec4 (1.0);
+
+ printMESA (_Zero);
+ printMESA (_One);
+ printMESA (_Two4);
+
+ // pre-increment
+ reset ();
+ printMESA (++fZero);
+ printMESA (++fOne);
+ printMESA (++iZero);
+ printMESA (++iOne);
+ printMESA (fZero);
+ printMESA (fOne);
+ printMESA (iZero);
+ printMESA (iOne);
+ printMESA (++fTwo4 == _Two4 + 1.0);
+ printMESA (++iTwo4 == ivec4 (_Two4) + 1);
+
+ // pre-decrement
+ reset ();
+ printMESA (--fZero);
+ printMESA (--fOne);
+ printMESA (--iZero);
+ printMESA (--iOne);
+ printMESA (fZero);
+ printMESA (fOne);
+ printMESA (iZero);
+ printMESA (iOne);
+ printMESA (--fTwo4 == _Two4 - 1.0);
+ printMESA (--iTwo4 == ivec4 (_Two4) - 1);
+
+ // post-increment
+ reset ();
+ printMESA (fZero++);
+ printMESA (fOne++);
+ printMESA (iZero++);
+ printMESA (iOne++);
+ printMESA (fZero);
+ printMESA (fOne);
+ printMESA (iZero);
+ printMESA (iOne);
+ printMESA (fTwo4++ == _Two4);
+ printMESA (iTwo4++ == ivec4 (_Two4));
+
+ // post-decrement
+ reset ();
+ printMESA (fZero--);
+ printMESA (fOne--);
+ printMESA (iZero--);
+ printMESA (iOne--);
+ printMESA (fZero);
+ printMESA (fOne);
+ printMESA (iZero);
+ printMESA (iOne);
+ printMESA (fTwo4-- == _Two4);
+ printMESA (iTwo4-- == ivec4 (_Two4));
+}
+
+$output
+
+0.0
+1.1
+2.1
+2.2
+2.3
+2.4
+
+1.0
+2.1
+1
+2
+1.0
+2.1
+1
+2
+true
+true
+
+-1.0
+0.1
+-1
+0
+-1.0
+0.1
+-1
+0
+true
+true
+
+0.0
+1.1
+0
+1
+1.0
+2.1
+1
+2
+true
+true
+
+0.0
+1.1
+0
+1
+-1.0
+0.1
+-1
+0
+true
+true
+
+
+$ /*
+$ --------------------------------------------------------------------------------------------------
+$ Test arithmetical operators.
+$ */
+
+$program ARITHMETICAL OPERATOR TEST
+
+$attrib gl_Vertex
+0.0 0.0 0.0 1.0
+
+$attrib _Zero
+0.0 0.0 0.0 0.0
+
+$attrib _One
+1.1 0.0 0.0 0.0
+
+$attrib _Two4
+2.1 2.2 2.3 2.4
+
+$vertex
+
+$code
+
+#version 110
+
+#extension MESA_shader_debug: require
+
+attribute float _Zero;
+attribute float _One;
+attribute vec4 _Two4;
+
+void main () {
+ gl_Position = gl_ModelViewMatrix * gl_Vertex;
+ gl_FrontColor = vec4 (1.0);
+
+ printMESA (_Zero);
+ printMESA (_One);
+ printMESA (_Two4);
+
+ int iZero = int (_Zero);
+ int iOne = int (_One);
+ ivec4 iTwo4 = ivec4 (_Two4);
+
+ printMESA (-_Zero);
+ printMESA (-_One);
+ printMESA (-_Two4);
+ printMESA (-_Two4.z);
+
+ printMESA (_Zero + 0.0);
+ printMESA (_One + 0.0);
+ printMESA (_Two4 + 0.0);
+ printMESA (_Two4.y + 0.0);
+
+ printMESA (_Zero + _Zero);
+ printMESA (_Zero + _One);
+ printMESA (_Zero + _Two4);
+ printMESA (_One + _Zero);
+ printMESA (_One + _Two4);
+ printMESA (_Two4 + _Two4);
+
+ printMESA (_Zero - 0.0);
+ printMESA (_One - 0.0);
+ printMESA (_Two4 - 0.0);
+ printMESA (_Two4.y - 0.0);
+
+ printMESA (_Zero - _Zero);
+ printMESA (_Zero - _One);
+ printMESA (_Zero - _Two4);
+ printMESA (_One - _Zero);
+ printMESA (_One - _Two4);
+ printMESA (_Two4 - _Two4);
+
+ printMESA (_Zero * 1.0);
+ printMESA (_One * 1.0);
+ printMESA (_Two4 * 1.0);
+ printMESA (_Two4.x * 1.0);
+
+ printMESA (_Zero * _Zero);
+ printMESA (_Zero * _One);
+ printMESA (_Zero * _Two4);
+ printMESA (_One * _Zero);
+ printMESA (_One * _One);
+ printMESA (_One * _Two4);
+ printMESA (_Two4 * _Two4);
+
+ printMESA (_Zero / 1.0);
+ printMESA (_One / 1.0);
+ printMESA (_Two4 / 1.0);
+ printMESA (_Two4.x / 1.0);
+
+ printMESA (_Zero / _One);
+ printMESA (_Zero / _Two4);
+ printMESA (_One / _One);
+ printMESA (_One / _Two4);
+ printMESA (_Two4 / _Two4);
+}
+
+$output
+
+0.0
+1.1
+2.1
+2.2
+2.3
+2.4
+
+0.0
+-1.1
+-2.1
+-2.2
+-2.3
+-2.4
+-2.3
+
+0.0
+1.1
+2.1
+2.2
+2.3
+2.4
+2.2
+
+0.0
+1.1
+2.1
+2.2
+2.3
+2.4
+1.1
+3.2
+3.3
+3.4
+3.5
+4.2
+4.4
+4.6
+4.8
+
+0.0
+1.1
+2.1
+2.2
+2.3
+2.4
+2.2
+
+0.0
+-1.1
+-2.1
+-2.2
+-2.3
+-2.4
+1.1
+-1.0
+-1.1
+-1.2
+-1.3
+0.0
+0.0
+0.0
+0.0
+
+0.0
+1.1
+2.1
+2.2
+2.3
+2.4
+2.1
+
+0.0
+0.0
+0.0
+0.0
+0.0
+0.0
+0.0
+1.21
+2.31
+2.42
+2.53
+2.64
+4.41
+4.84
+5.29
+5.76
+
+0.0
+1.1
+2.1
+2.2
+2.3
+2.4
+2.1
+
+0.0
+0.0
+0.0
+0.0
+0.0
+1.0
+0.52381
+0.5
+0.47826
+0.45833
+1.0
+1.0
+1.0
+1.0
+
+
+$ /*
+$ --------------------------------------------------------------------------------------------------
+$ Test matrix operations.
+$ Note: assumes relational operators being correct.
+$ */
+
+$program MATRIX TEST
+
+$attrib gl_Vertex
+0.0 0.0 0.0 1.0
+
+$attrib _Zero
+0.0 0.0 0.0 0.0
+
+$attrib _One
+1.0 1.0 1.0 1.0
+
+$attrib _Two
+2.0 2.0 2.0 2.0
+
+$vertex
+
+$code
+
+#version 110
+
+#extension MESA_shader_debug: require
+
+attribute vec4 _Zero;
+attribute vec4 _One;
+attribute vec4 _Two;
+
+void main () {
+ gl_Position = gl_ModelViewMatrix * gl_Vertex;
+ gl_FrontColor = vec4 (1.0);
+
+ printMESA (_Zero);
+ printMESA (_One);
+ printMESA (_Two);
+
+ mat4 Identity = mat4 (_One.x);
+
+ printMESA (Identity == mat4 (1.0, 0.0, 0.0, 0.0,
+ 0.0, 1.0, 0.0, 0.0,
+ 0.0, 0.0, 1.0, 0.0,
+ 0.0, 0.0, 0.0, 1.0));
+ printMESA (Identity * _Two == _Two);
+
+ mat4 Matrix = mat4 (1.1, 1.2, 1.3, 1.4,
+ 2.1, 2.2, 2.3, 2.4,
+ 3.1, 3.2, 3.3, 3.4,
+ 4.1, 4.2, 4.3, 4.4);
+
+ printMESA (Matrix[2].y);
+ printMESA (Matrix[1]);
+}
+
+$output
+
+0.0
+0.0
+0.0
+0.0
+1.0
+1.0
+1.0
+1.0
+2.0
+2.0
+2.0
+2.0
+true
+true
+3.2
+2.1
+2.2
+2.3
+2.4
+
+
+$ /*
+$ --------------------------------------------------------------------------------------------------
+$ Test vec4 extension operations.
+$ */
+
+$program VEC4 EXTENSION OPERATIONS
+
+$attrib gl_Vertex
+0.0 0.0 0.0 1.0
+
+$attrib _One
+1.1 0.0 0.0 0.0
+
+$attrib _Two4
+2.1 2.2 2.3 2.4
+
+$attrib _Three4
+3.1 3.2 3.3 3.4
+
+$vertex
+
+$code
+
+#version 110
+
+#extension MESA_shader_debug: require
+
+attribute float _One;
+attribute vec4 _Two4;
+attribute vec4 _Three4;
+
+void main () {
+ gl_Position = gl_ModelViewMatrix * gl_Vertex;
+ gl_FrontColor = vec4 (1.0);
+
+ printMESA (_One);
+ printMESA (_Two4);
+ printMESA (_Three4);
+
+ printMESA (vec4 (_One));
+
+ printMESA (_Two4 + _Three4);
+ printMESA (_Two4 - _Three4);
+ printMESA (_Two4 * _Three4);
+ printMESA (_Two4 / _Three4);
+
+ printMESA (_Two4 + _One);
+ printMESA (_Two4 - _One);
+ printMESA (_Two4 * _One);
+ printMESA (_Two4 / _One);
+
+ printMESA (_One + _Two4);
+ printMESA (_One - _Two4);
+ printMESA (_One * _Two4);
+ printMESA (_One / _Two4);
+
+ printMESA (-_Three4);
+
+ printMESA (dot (_Two4.xyz, _Three4.xyz));
+ printMESA (dot (_Two4, _Three4));
+
+ printMESA (length (_Two4.xyz));
+ printMESA (length (_Three4));
+
+ printMESA (normalize (_Two4.xyz));
+ printMESA (normalize (_Three4));
+
+ vec4 tmp = _Two4;
+ printMESA (tmp);
+
+ printMESA (_Two4 == _Three4);
+ printMESA (_Two4 != _Three4);
+ printMESA (_Two4 == _Two4);
+ printMESA (_Three4 != _Three4);
+ printMESA (_Two4 != vec4 (_Two4.xyz, 999.0));
+ printMESA (_Two4 != vec4 (999.0, _Two4.yzw));
+}
+
+$output
+
+1.1
+2.1
+2.2
+2.3
+2.4
+3.1
+3.2
+3.3
+3.4
+
+1.1
+1.1
+1.1
+1.1
+
+5.2
+5.4
+5.6
+5.8
+-1.0
+-1.0
+-1.0
+-1.0
+6.51
+7.04
+7.59
+8.16
+0.677419
+0.6875
+0.69697
+0.705882
+
+3.2
+3.3
+3.4
+3.5
+1.0
+1.1
+1.2
+1.3
+2.31
+2.42
+2.53
+2.64
+1.909091
+2.0
+2.090909
+2.181818
+
+3.2
+3.3
+3.4
+3.5
+-1.0
+-1.1
+-1.2
+-1.3
+2.31
+2.42
+2.53
+2.64
+0.52381
+0.5
+0.478261
+0.458333
+
+-3.1
+-3.2
+-3.3
+-3.4
+
+21.14
+29.3
+
+3.813135
+6.503845
+
+0.550728
+0.576953
+0.603178
+0.476641
+0.492017
+0.507392
+0.522768
+
+2.1
+2.2
+2.3
+2.4
+
+false
+true
+true
+false
+true
+true
diff --git a/progs/slang/framework.c b/progs/slang/framework.c
new file mode 100644
index 00000000000..692cef9c8cb
--- /dev/null
+++ b/progs/slang/framework.c
@@ -0,0 +1,145 @@
+#include "framework.h"
+
+/*
+ * GL_ARB_multitexture
+ */
+#ifndef GL_ARB_multitexture
+PFNGLCLIENTACTIVETEXTUREARBPROC glClientActiveTextureARB;
+PFNGLMULTITEXCOORD4FVARBPROC glMultiTexCoord4fvARB;
+#endif
+
+/*
+ * GL_ARB_shader_objects
+ */
+PFNGLDELETEOBJECTARBPROC glDeleteObjectARB;
+PFNGLGETHANDLEARBPROC glGetHandleARB;
+PFNGLDETACHOBJECTARBPROC glDetachObjectARB;
+PFNGLCREATESHADEROBJECTARBPROC glCreateShaderObjectARB;
+PFNGLSHADERSOURCEARBPROC glShaderSourceARB;
+PFNGLCOMPILESHADERARBPROC glCompileShaderARB;
+PFNGLCREATEPROGRAMOBJECTARBPROC glCreateProgramObjectARB;
+PFNGLATTACHOBJECTARBPROC glAttachObjectARB;
+PFNGLLINKPROGRAMARBPROC glLinkProgramARB;
+PFNGLUSEPROGRAMOBJECTARBPROC glUseProgramObjectARB;
+PFNGLGETOBJECTPARAMETERIVARBPROC glGetObjectParameterivARB;
+PFNGLGETINFOLOGARBPROC glGetInfoLogARB;
+PFNGLGETUNIFORMLOCATIONARBPROC glGetUniformLocationARB;
+
+/*
+ * GL_ARB_vertex_shader
+ */
+PFNGLVERTEXATTRIB4FVARBPROC glVertexAttrib4fvARB;
+PFNGLVERTEXATTRIBPOINTERARBPROC glVertexAttribPointerARB;
+PFNGLENABLEVERTEXATTRIBARRAYARBPROC glEnableVertexAttribArrayARB;
+PFNGLDISABLEVERTEXATTRIBARRAYARBPROC glDisableVertexAttribArrayARB;
+PFNGLBINDATTRIBLOCATIONARBPROC glBindAttribLocationARB;
+PFNGLGETATTRIBLOCATIONARBPROC glGetAttribLocationARB;
+
+/*
+ * GL_EXT_fog_coord
+ */
+PFNGLFOGCOORDFVEXTPROC glFogCoordfvEXT;
+PFNGLFOGCOORDPOINTEREXTPROC glFogCoordPointerEXT;
+
+/*
+ * GL_EXT_secondary_color
+ */
+PFNGLSECONDARYCOLOR3FVEXTPROC glSecondaryColor3fvEXT;
+PFNGLSECONDARYCOLORPOINTEREXTPROC glSecondaryColorPointerEXT;
+
+static void Display (void)
+{
+ glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ RenderScene ();
+ glutSwapBuffers ();
+}
+
+static void Idle (void)
+{
+ glutPostRedisplay ();
+}
+
+void InitFramework (int *argc, char *argv[])
+{
+ glutInit (argc, argv);
+ glutInitWindowPosition (0, 0);
+ glutInitWindowSize (200, 200);
+ glutInitDisplayMode (GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
+ glutCreateWindow (argv[0]);
+
+#ifndef GL_ARB_multitexture
+ GETPROCADDR(glClientActiveTextureARB, PFNGLCLIENTACTIVETEXTUREARBPROC);
+ GETPROCADDR(glMultiTexCoord4fvARB, PFNGLMULTITEXCOORD4FVARBPROC);
+#endif
+
+ GETPROCADDR(glDeleteObjectARB, PFNGLDELETEOBJECTARBPROC);
+ GETPROCADDR(glGetHandleARB, PFNGLGETHANDLEARBPROC);
+ GETPROCADDR(glDetachObjectARB, PFNGLDETACHOBJECTARBPROC);
+ GETPROCADDR(glCreateShaderObjectARB, PFNGLCREATESHADEROBJECTARBPROC);
+ GETPROCADDR(glShaderSourceARB, PFNGLSHADERSOURCEARBPROC);
+ GETPROCADDR(glCompileShaderARB, PFNGLCOMPILESHADERARBPROC);
+ GETPROCADDR(glCreateProgramObjectARB, PFNGLCREATEPROGRAMOBJECTARBPROC);
+ GETPROCADDR(glAttachObjectARB, PFNGLATTACHOBJECTARBPROC);
+ GETPROCADDR(glLinkProgramARB, PFNGLLINKPROGRAMARBPROC);
+ GETPROCADDR(glUseProgramObjectARB, PFNGLUSEPROGRAMOBJECTARBPROC);
+ GETPROCADDR(glGetObjectParameterivARB, PFNGLGETOBJECTPARAMETERIVARBPROC);
+ GETPROCADDR(glGetInfoLogARB, PFNGLGETINFOLOGARBPROC);
+ GETPROCADDR(glGetUniformLocationARB, PFNGLGETUNIFORMLOCATIONARBPROC);
+
+ GETPROCADDR(glVertexAttrib4fvARB, PFNGLVERTEXATTRIB4FVARBPROC);
+ GETPROCADDR(glVertexAttribPointerARB, PFNGLVERTEXATTRIBPOINTERARBPROC);
+ GETPROCADDR(glEnableVertexAttribArrayARB, PFNGLENABLEVERTEXATTRIBARRAYARBPROC);
+ GETPROCADDR(glDisableVertexAttribArrayARB, PFNGLDISABLEVERTEXATTRIBARRAYARBPROC);
+ GETPROCADDR(glBindAttribLocationARB, PFNGLBINDATTRIBLOCATIONARBPROC);
+ GETPROCADDR(glGetAttribLocationARB, PFNGLGETATTRIBLOCATIONARBPROC);
+
+ GETPROCADDR(glFogCoordfvEXT, PFNGLFOGCOORDFVEXTPROC);
+ GETPROCADDR(glFogCoordPointerEXT, PFNGLFOGCOORDPOINTEREXTPROC);
+
+ GETPROCADDR(glSecondaryColor3fvEXT, PFNGLSECONDARYCOLOR3FVEXTPROC);
+ GETPROCADDR(glSecondaryColorPointerEXT, PFNGLSECONDARYCOLORPOINTEREXTPROC);
+
+ printf ("VENDOR: %s\n", glGetString (GL_VENDOR));
+ printf ("RENDERER: %s\n", glGetString (GL_RENDERER));
+
+ InitScene ();
+
+ glutDisplayFunc (Display);
+ glutIdleFunc (Idle);
+ glutMainLoop ();
+}
+
+GLboolean CheckObjectStatus (GLhandleARB handle)
+{
+ GLint type, status, length;
+ GLcharARB *infolog;
+
+ glGetObjectParameterivARB (handle, GL_OBJECT_TYPE_ARB, &type);
+ if (type == GL_SHADER_OBJECT_ARB)
+ glGetObjectParameterivARB (handle, GL_OBJECT_COMPILE_STATUS_ARB, &status);
+ else if (type == GL_PROGRAM_OBJECT_ARB)
+ glGetObjectParameterivARB (handle, GL_OBJECT_LINK_STATUS_ARB, &status);
+ else {
+ assert (0);
+ return GL_FALSE;
+ }
+
+ if (status)
+ return GL_TRUE;
+
+ printf ("\n%s FAILED. INFO LOG FOLLOWS:\n",
+ type == GL_SHADER_OBJECT_ARB ? "SHADER COMPILE" : "PROGRAM LINK");
+
+ glGetObjectParameterivARB (handle, GL_OBJECT_INFO_LOG_LENGTH_ARB, &length);
+ infolog = (GLcharARB *) (malloc (length));
+ if (infolog != NULL) {
+ glGetInfoLogARB (handle, length, NULL, infolog);
+ printf ("%s", infolog);
+ free (infolog);
+ }
+
+ printf ("\n");
+
+ return GL_FALSE;
+}
+
diff --git a/progs/slang/framework.h b/progs/slang/framework.h
new file mode 100644
index 00000000000..e023f7da8a6
--- /dev/null
+++ b/progs/slang/framework.h
@@ -0,0 +1,82 @@
+#ifndef _FRAMEWORK_H_
+#define _FRAMEWORK_H_
+
+#ifdef WIN32
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#endif
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <assert.h>
+#include <math.h>
+#include <GL/gl.h>
+#include <GL/glut.h>
+#include <GL/glext.h>
+
+#ifdef WIN32
+#define GETPROCADDRESS(x) wglGetProcAddress (x)
+#else
+#define GETPROCADDRESS(x) glutGetProcAddress (x)
+#endif
+
+#define GETPROCADDR(x,T) do { x = (T) (GETPROCADDRESS(#x)); assert (x != NULL); } while (0)
+
+/*
+ * GL_ARB_multitexture
+ */
+#ifndef GL_ARB_multitexture
+extern PFNGLCLIENTACTIVETEXTUREARBPROC glClientActiveTextureARB;
+extern PFNGLMULTITEXCOORD4FVARBPROC glMultiTexCoord4fvARB;
+#endif
+
+/*
+ * GL_ARB_shader_objects
+ */
+extern PFNGLDELETEOBJECTARBPROC glDeleteObjectARB;
+extern PFNGLGETHANDLEARBPROC glGetHandleARB;
+extern PFNGLDETACHOBJECTARBPROC glDetachObjectARB;
+extern PFNGLCREATESHADEROBJECTARBPROC glCreateShaderObjectARB;
+extern PFNGLSHADERSOURCEARBPROC glShaderSourceARB;
+extern PFNGLCOMPILESHADERARBPROC glCompileShaderARB;
+extern PFNGLCREATEPROGRAMOBJECTARBPROC glCreateProgramObjectARB;
+extern PFNGLATTACHOBJECTARBPROC glAttachObjectARB;
+extern PFNGLLINKPROGRAMARBPROC glLinkProgramARB;
+extern PFNGLUSEPROGRAMOBJECTARBPROC glUseProgramObjectARB;
+extern PFNGLGETOBJECTPARAMETERIVARBPROC glGetObjectParameterivARB;
+extern PFNGLGETINFOLOGARBPROC glGetInfoLogARB;
+extern PFNGLGETUNIFORMLOCATIONARBPROC glGetUniformLocationARB;
+/*static PFNGLUNIFORM4FVARBPROC glUniform4fvARB = NULL;*/
+
+/*
+ * GL_ARB_vertex_shader
+ */
+extern PFNGLVERTEXATTRIB4FVARBPROC glVertexAttrib4fvARB;
+extern PFNGLVERTEXATTRIBPOINTERARBPROC glVertexAttribPointerARB;
+extern PFNGLENABLEVERTEXATTRIBARRAYARBPROC glEnableVertexAttribArrayARB;
+extern PFNGLDISABLEVERTEXATTRIBARRAYARBPROC glDisableVertexAttribArrayARB;
+extern PFNGLBINDATTRIBLOCATIONARBPROC glBindAttribLocationARB;
+extern PFNGLGETATTRIBLOCATIONARBPROC glGetAttribLocationARB;
+
+/*
+ * GL_EXT_fog_coord
+ */
+extern PFNGLFOGCOORDFVEXTPROC glFogCoordfvEXT;
+extern PFNGLFOGCOORDPOINTEREXTPROC glFogCoordPointerEXT;
+
+/*
+ * GL_EXT_secondary_color
+ */
+extern PFNGLSECONDARYCOLOR3FVEXTPROC glSecondaryColor3fvEXT;
+extern PFNGLSECONDARYCOLORPOINTEREXTPROC glSecondaryColorPointerEXT;
+
+extern void InitFramework (int *argc, char *argv[]);
+
+extern void InitScene (void);
+extern void RenderScene (void);
+
+extern GLboolean CheckObjectStatus (GLhandleARB);
+
+#endif
+
diff --git a/progs/slang/sotest.c b/progs/slang/sotest.c
new file mode 100644
index 00000000000..4bd3bc23c92
--- /dev/null
+++ b/progs/slang/sotest.c
@@ -0,0 +1,439 @@
+/*
+ * GL_ARB_shader_objects & GL_ARB_vertex_shader interface test application.
+ * Neither compiler nor executor is being tested here, although some simple shader
+ * compilation tests are performed.
+ *
+ * Perfectly valid behaviour produces output that does not have a line
+ * beginning with three stars (***).
+ *
+ * Author: Michal Krol
+ */
+
+#include "framework.h"
+
+enum TEST_TYPE
+{
+ TT_GETERROR_NOERROR,
+ TT_GETERROR_INVALIDVALUE,
+ TT_GETERROR_INVALIDOPERATION,
+ TT_PARAM1_ZERO,
+ TT_PARAM1_NONZERO
+};
+
+static enum TEST_TYPE current_test;
+
+static void begintest (enum TEST_TYPE type, const char *name)
+{
+ current_test = type;
+ printf ("\n BEGIN TEST: %s\n", name);
+ while (glGetError () != GL_NO_ERROR)
+ ;
+}
+
+static void endtest1 (GLuint param1)
+{
+ const char *msg = NULL;
+
+ switch (current_test)
+ {
+ case TT_GETERROR_NOERROR:
+ if (glGetError () != GL_NO_ERROR)
+ msg = "glGetError () does not return GL_NO_ERROR";
+ break;
+ case TT_GETERROR_INVALIDVALUE:
+ if (glGetError () != GL_INVALID_VALUE)
+ msg = "glGetError () does not return GL_INVALID_VALUE";
+ break;
+ case TT_GETERROR_INVALIDOPERATION:
+ if (glGetError () != GL_INVALID_OPERATION)
+ msg = "glGetError () does not return GL_INVALID_OPERATION";
+ break;
+ case TT_PARAM1_ZERO:
+ if (param1)
+ msg = "The parameter is not zero";
+ break;
+ case TT_PARAM1_NONZERO:
+ if (!param1)
+ msg = "The parameter is not non-zero";
+ break;
+ default:
+ assert (0);
+ }
+
+ if (msg == NULL)
+ printf (" OK\n");
+ else
+ printf ("*** %s\n", msg);
+
+ while (glGetError () != GL_NO_ERROR)
+ ;
+}
+
+static void endtest ()
+{
+ endtest1 (0);
+}
+
+static GLhandleARB vert = 0;
+static GLhandleARB frag = 0;
+static GLhandleARB prog = 0;
+
+static GLhandleARB find_invalid_handle ()
+{
+ GLhandleARB handle;
+
+ for (handle = 1; handle < 16; handle++)
+ if (handle != vert && handle != frag && handle != prog)
+ return handle;
+ assert (0);
+ return 0;
+}
+
+static const char *invsynvertsrc =
+ "void main () {\n"
+ " gl_Position = gl_ModelViewMatrix ! gl_Vertex;\n" /* unexpected token */
+ "}\n"
+;
+
+static const char *invsemvertsrc =
+ "void main () {\n"
+ " gl_Position = gl_ModelviewMatrix * gl_Vertex;\n" /* undeclared identifier */
+ "}\n"
+;
+
+static const char *uniforms =
+ "uniform vec4 CommonUniform;\n"
+;
+
+static const char *validvertsrc =
+ "uniform vec4 VertexUniform;\n"
+ "attribute vec4 FirstAttrib;\n"
+ "attribute vec4 SecondAttrib;\n"
+ "void main () {\n"
+ " gl_Position = gl_ModelViewMatrix * gl_Vertex + CommonUniform + VertexUniform\n"
+ " + FirstAttrib + SecondAttrib;\n"
+ "}\n"
+;
+
+static const char *invsynfragsrc =
+ "void main () {\n"
+ " gl_FragColor = gl_Color\n" /* missing ; */
+ "}\n"
+;
+
+static const char *invsemfragsrc =
+ "void main () {\n"
+ " gl_FragColor = gl_FrontColor;\n" /* gl_FrontColor only in vertex shader */
+ "}\n"
+;
+
+static const char *validfragsrc =
+ "uniform vec4 FragmentUniform;\n"
+ "void main () {\n"
+ " gl_FragColor = gl_Color + CommonUniform + FragmentUniform;\n"
+ "}\n"
+;
+
+void InitScene (void)
+{
+ GLint params[1];
+ const char *tab[2];
+
+ /*
+ * GL should silently ignore calls that delete object 0.
+ */
+ begintest (TT_GETERROR_NOERROR, "glDeleteObject(0)");
+ glDeleteObjectARB (0);
+ endtest ();
+
+ /*
+ * GL generates an error on invalid object handle.
+ */
+ begintest (TT_GETERROR_INVALIDVALUE, "Pass invalid non-zero object handle");
+ glDeleteObjectARB (find_invalid_handle ());
+ endtest ();
+ glUseProgramObjectARB (find_invalid_handle ());
+ endtest ();
+
+ /*
+ * Create object. GL should return unique non-zero values.
+ */
+ begintest (TT_PARAM1_NONZERO, "Create object");
+ vert = glCreateShaderObjectARB (GL_VERTEX_SHADER_ARB);
+ endtest1 (vert);
+ frag = glCreateShaderObjectARB (GL_FRAGMENT_SHADER_ARB);
+ endtest1 (frag);
+ prog = glCreateProgramObjectARB ();
+ endtest1 (prog);
+ endtest1 (vert != frag && frag != prog && prog != vert);
+
+ /*
+ * Link empty program.
+ */
+ begintest (TT_PARAM1_NONZERO, "Link empty program");
+ glLinkProgramARB (prog);
+ endtest1 (CheckObjectStatus (prog));
+
+ /*
+ * Use empty program object. Empty program objects are valid.
+ */
+ begintest (TT_GETERROR_NOERROR, "Use empty program object");
+ glUseProgramObjectARB (prog);
+ endtest ();
+
+ /*
+ * Attach invalid object handles. Program object 0 should not be accepted.
+ */
+ begintest (TT_GETERROR_INVALIDVALUE, "Attach invalid object handle");
+ glAttachObjectARB (0, find_invalid_handle ());
+ endtest ();
+ glAttachObjectARB (0, frag);
+ endtest ();
+ glAttachObjectARB (find_invalid_handle (), find_invalid_handle ());
+ endtest ();
+ glAttachObjectARB (find_invalid_handle (), frag);
+ endtest ();
+ glAttachObjectARB (prog, find_invalid_handle ());
+ endtest ();
+
+ /*
+ * Attach valid object handles with wrong semantics.
+ */
+ begintest (TT_GETERROR_INVALIDOPERATION, "Attach object badly");
+ glAttachObjectARB (vert, frag);
+ endtest ();
+ glAttachObjectARB (vert, prog);
+ endtest ();
+ glAttachObjectARB (prog, prog);
+ endtest ();
+
+ /*
+ * Detach non-attached object.
+ */
+ begintest (TT_GETERROR_INVALIDOPERATION, "Detach non-attached object");
+ glDetachObjectARB (prog, vert);
+ endtest ();
+ glDetachObjectARB (prog, frag);
+ endtest ();
+
+ /*
+ * Attach shader.
+ */
+ begintest (TT_GETERROR_NOERROR, "Attach shader to program object");
+ glAttachObjectARB (prog, vert);
+ endtest ();
+ glAttachObjectARB (prog, frag);
+ endtest ();
+
+ /*
+ * Attach object twice.
+ */
+ begintest (TT_GETERROR_INVALIDOPERATION, "Attach object twice");
+ glAttachObjectARB (prog, vert);
+ endtest ();
+ glAttachObjectARB (prog, frag);
+ endtest ();
+
+ /*
+ * Detach attached object.
+ */
+ begintest (TT_GETERROR_NOERROR, "Detach attached object");
+ glDetachObjectARB (prog, vert);
+ endtest ();
+ glDetachObjectARB (prog, frag);
+ endtest ();
+
+ /*
+ * Attach shader again.
+ */
+ begintest (TT_GETERROR_NOERROR, "Attach shader again");
+ glAttachObjectARB (prog, vert);
+ endtest ();
+ glAttachObjectARB (prog, frag);
+ endtest ();
+
+ /*
+ * Delete attached object.
+ */
+ begintest (TT_GETERROR_NOERROR, "Delete attached object");
+ glDeleteObjectARB (vert);
+ endtest ();
+ glDeleteObjectARB (frag);
+ endtest ();
+
+ /*
+ * Query delete status. It should return TRUE. Object handles are still valid
+ * as they are referenced by program object container.
+ */
+ begintest (TT_PARAM1_NONZERO, "Query delete status");
+ glGetObjectParameterivARB (vert, GL_OBJECT_DELETE_STATUS_ARB, params);
+ endtest1 (params[0]);
+ glGetObjectParameterivARB (frag, GL_OBJECT_DELETE_STATUS_ARB, params);
+ endtest1 (params[0]);
+
+ /*
+ * Delete already deleted attached object. The behaviour is undefined, but we
+ * check for no errors. The object still exists, so the handle value is okay.
+ * In other words, these calls should be silently ignored by GL.
+ */
+ begintest (TT_GETERROR_NOERROR, "Delete already deleted attached object");
+ glDeleteObjectARB (vert);
+ endtest ();
+ glDeleteObjectARB (frag);
+ endtest ();
+
+ /*
+ * Compile shader source with syntax error.
+ */
+ begintest (TT_PARAM1_ZERO, "Compile shader source with syntax error");
+ glShaderSourceARB (vert, 1, &invsynvertsrc, NULL);
+ glCompileShaderARB (vert);
+ endtest1 (CheckObjectStatus (vert));
+ glShaderSourceARB (frag, 1, &invsynfragsrc, NULL);
+ glCompileShaderARB (frag);
+ endtest1 (CheckObjectStatus (frag));
+
+ /*
+ * Compile shader source with semantic error.
+ */
+ begintest (TT_PARAM1_ZERO, "Compile shader source with semantic error");
+ glShaderSourceARB (vert, 1, &invsemvertsrc, NULL);
+ glCompileShaderARB (vert);
+ endtest1 (CheckObjectStatus (vert));
+ glShaderSourceARB (frag, 1, &invsemfragsrc, NULL);
+ glCompileShaderARB (frag);
+ endtest1 (CheckObjectStatus (frag));
+
+ /*
+ * Link ill-formed vertex-fragment program.
+ */
+ begintest (TT_PARAM1_ZERO, "Link ill-formed vertex-fragment program");
+ glLinkProgramARB (prog);
+ endtest1 (CheckObjectStatus (prog));
+
+ /*
+ * Use badly linked program object.
+ */
+ begintest (TT_GETERROR_INVALIDOPERATION, "Use badly linked program object");
+ glUseProgramObjectARB (prog);
+ endtest ();
+
+ /*
+ * Compile well-formed shader source. Check if multi-string sources can be handled.
+ */
+ begintest (TT_PARAM1_NONZERO, "Compile well-formed shader source");
+ tab[0] = uniforms;
+ tab[1] = validvertsrc;
+ glShaderSourceARB (vert, 2, tab, NULL);
+ glCompileShaderARB (vert);
+ endtest1 (CheckObjectStatus (vert));
+ tab[0] = uniforms;
+ tab[1] = validfragsrc;
+ glShaderSourceARB (frag, 2, tab, NULL);
+ glCompileShaderARB (frag);
+ endtest1 (CheckObjectStatus (frag));
+
+ /*
+ * Link vertex-fragment program.
+ */
+ begintest (TT_PARAM1_NONZERO, "Link vertex-fragment program");
+ glLinkProgramARB (prog);
+ endtest1 (CheckObjectStatus (prog));
+
+ /*
+ * Use valid linked program object.
+ */
+ begintest (TT_GETERROR_NOERROR, "Use linked program object");
+ glUseProgramObjectARB (prog);
+ endtest ();
+
+ /*
+ * Get current program.
+ */
+ begintest (TT_PARAM1_NONZERO, "Get current program");
+ endtest1 (glGetHandleARB (GL_PROGRAM_OBJECT_ARB) == prog);
+
+ /*
+ * Use 0 program object.
+ */
+ begintest (TT_GETERROR_NOERROR, "Use 0 program object");
+ glUseProgramObjectARB (0);
+ endtest ();
+
+ /*
+ * Query uniform location. Uniforms with gl_ prefix cannot be queried.
+ */
+ begintest (TT_PARAM1_NONZERO, "Query uniform location");
+ endtest1 (glGetUniformLocationARB (prog, "gl_ModelViewMatrix") == -1);
+ endtest1 (glGetUniformLocationARB (prog, "UniformThatDoesNotExist") == -1);
+ endtest1 (glGetUniformLocationARB (prog, "") == -1);
+ endtest1 (glGetUniformLocationARB (prog, "CommonUniform") != -1);
+ endtest1 (glGetUniformLocationARB (prog, "VertexUniform") != -1);
+ endtest1 (glGetUniformLocationARB (prog, "FragmentUniform") != -1);
+
+ /*
+ * Query attrib location. Attribs with gl_ prefix cannot be queried.
+ * When gl_Vertex is used, none of the generic attribs can have index 0.
+ */
+ begintest (TT_PARAM1_NONZERO, "Query attrib location");
+ endtest1 (glGetAttribLocationARB (prog, "gl_Vertex") == -1);
+ endtest1 (glGetAttribLocationARB (prog, "AttribThatDoesNotExist") == -1);
+ endtest1 (glGetAttribLocationARB (prog, "") == -1);
+ endtest1 (glGetAttribLocationARB (prog, "FirstAttrib") > 0);
+ endtest1 (glGetAttribLocationARB (prog, "SecondAttrib") > 0);
+
+ /*
+ * Bind attrib locations, link and check if locations are correct.
+ */
+ begintest (TT_PARAM1_NONZERO, "Bind attrib location #1");
+ glBindAttribLocationARB (prog, 1, "FirstAttrib");
+ glBindAttribLocationARB (prog, 2, "SecondAttrib");
+ glLinkProgramARB (prog);
+ endtest1 (CheckObjectStatus (prog));
+ endtest1 (glGetAttribLocationARB (prog, "FirstAttrib") == 1);
+ endtest1 (glGetAttribLocationARB (prog, "SecondAttrib") == 2);
+
+ /*
+ * Bind attrib locations in different order. Link and check if locations are correct.
+ */
+ begintest (TT_PARAM1_NONZERO, "Bind attrib location #2");
+ glBindAttribLocationARB (prog, 1, "SecondAttrib");
+ glBindAttribLocationARB (prog, 2, "FirstAttrib");
+ glLinkProgramARB (prog);
+ endtest1 (CheckObjectStatus (prog));
+ endtest1 (glGetAttribLocationARB (prog, "SecondAttrib") == 1);
+ endtest1 (glGetAttribLocationARB (prog, "FirstAttrib") == 2);
+
+ /*
+ * Detach deleted object.
+ */
+ begintest (TT_GETERROR_NOERROR, "Detach deleted object");
+ glDetachObjectARB (prog, vert);
+ endtest ();
+ glDetachObjectARB (prog, frag);
+ endtest ();
+
+ /*
+ * Delete deleted detached object.
+ */
+ begintest (TT_GETERROR_INVALIDVALUE, "Delete deleted detached object");
+ glDeleteObjectARB (vert);
+ endtest ();
+ glDeleteObjectARB (frag);
+ endtest ();
+
+ exit (0);
+}
+
+void RenderScene (void)
+{
+ /* never reached */
+ assert (0);
+}
+
+int main (int argc, char *argv[])
+{
+ InitFramework (&argc, argv);
+ return 0;
+}
+
diff --git a/progs/slang/vstest.c b/progs/slang/vstest.c
new file mode 100644
index 00000000000..5108d157428
--- /dev/null
+++ b/progs/slang/vstest.c
@@ -0,0 +1,340 @@
+/*
+ * GL_ARB_vertex_shader test application. Feeds a vertex shader with attributes that
+ * that have magic values and check if the values received by the shader are the same.
+ *
+ * Requires specific support on the GL implementation side. A special function printMESA()
+ * must be supported in the language that prints variable's current value of generic type
+ * to the appropriate shader's info log, and optionally to the screen.
+ *
+ * Perfectly valid behaviour produces output that does not have a line
+ * beginning with three stars (***).
+ *
+ * Author: Michal Krol
+ */
+
+#include "framework.h"
+
+#define EPSILON 0.0001f
+
+static GLhandleARB vert = 0;
+static GLhandleARB prog = 0;
+
+enum SUBMIT_MODE
+{
+ SM_IM,
+ SM_VA,
+ SM_IM_DL,
+ SM_VA_DL,
+ SM_MAX
+};
+
+static enum SUBMIT_MODE submit_method = SM_IM;
+
+#define C 0
+#define S 1
+#define N 2
+#define V 3
+#define T 4
+#define F 5
+#define A 6
+
+struct ATTRIB_DATA
+{
+ const char *name;
+ GLuint dispatch;
+ GLint index;
+ GLint bind;
+ GLuint size;
+ GLfloat data[4];
+};
+
+static struct ATTRIB_DATA attribs[] = {
+ { "gl_Color", C, -1, -1, 4, { 4.2f, 0.56f, -2.1f, 0.29f } },
+ { "gl_SecondaryColor", S, -1, -1, 4, { 0.38f, 2.0f, 0.99f, 1.0f } },
+ { "gl_Normal", N, -1, -1, 3, { 54.0f, 77.0f, 1.15f, 0.0f } },
+ { "gl_MultiTexCoord0", T, 0, -1, 4, { 11.1f, 11.2f, 11.3f, 11.4f } },
+ { "gl_MultiTexCoord1", T, 1, -1, 4, { 22.1f, 22.2f, 22.3f, 22.4f } },
+ { "gl_MultiTexCoord2", T, 2, -1, 4, { 33.1f, 33.2f, 33.3f, 33.4f } },
+ { "gl_MultiTexCoord3", T, 3, -1, 4, { 44.1f, 44.2f, 44.3f, 44.4f } },
+ { "gl_MultiTexCoord4", T, 4, -1, 4, { 55.1f, 55.2f, 55.3f, 55.4f } },
+ { "gl_MultiTexCoord5", T, 5, -1, 4, { 66.1f, 66.2f, 66.3f, 66.4f } },
+ { "gl_MultiTexCoord6", T, 6, -1, 4, { 77.1f, 77.2f, 77.3f, 77.4f } },
+ { "gl_MultiTexCoord7", T, 7, -1, 4, { 88.1f, 88.2f, 88.3f, 88.4f } },
+ { "gl_FogCoord", F, -1, -1, 1, { 0.63f, 0.0f, 0.0f, 0.0f } },
+ { "Attribute1", A, 1, 1, 4, { 1.11f, 1.22f, 1.33f, 1.44f } },
+ { "Attribute2", A, 2, 2, 4, { 2.11f, 2.22f, 2.33f, 2.44f } },
+ { "Attribute3", A, 3, 3, 4, { 3.11f, 3.22f, 3.33f, 3.44f } },
+ { "Attribute4", A, 4, 4, 1, { 4.11f, 0.0f, 0.0f, 0.0f } },
+ { "Attribute5", A, 5, 5, 2, { 5.11f, 5.22f, 0.0f, 0.0f } },
+ { "Attribute6", A, 6, 6, 3, { 6.11f, 6.22f, 6.33f, 0.0f } },
+ { "Attribute7", A, 7, 7, 2, { 7.11f, 7.22f, 0.0f, 0.0f } },
+ { "Attribute7", A, 8, -1, 2, { 8.11f, 8.22f, 0.0f, 0.0f } },
+ { "Attribute9", A, 9, 9, 3, { 9.11f, 9.22f, 9.33f, 0.0f } },
+ { "Attribute9", A, 10, -1, 3, { 10.11f, 10.22f, 10.33f, 0.0f } },
+ { "Attribute9", A, 11, -1, 3, { 11.11f, 11.22f, 11.33f, 0.0f } },
+ { "Attribute12", A, 12, 12, 4, { 12.11f, 12.22f, 12.33f, 12.44f } },
+ { "Attribute12", A, 13, -1, 4, { 13.11f, 13.22f, 13.33f, 13.44f } },
+ { "Attribute12", A, 14, -1, 4, { 14.11f, 14.22f, 14.33f, 14.44f } },
+ { "Attribute12", A, 15, -1, 4, { 15.11f, 15.22f, 15.33f, 15.44f } },
+ { "gl_Vertex", V, 16, -1, 4, { 0.25f, -0.14f, 0.01f, 1.0f } }
+};
+
+static void im_render ()
+{
+ GLint i;
+
+ glBegin (GL_POINTS);
+ for (i = 0; i < sizeof (attribs) / sizeof (*attribs); i++) {
+ struct ATTRIB_DATA *att = &attribs[i];
+ switch (att->dispatch)
+ {
+ case C:
+ glColor4fv (att->data);
+ break;
+ case S:
+ glSecondaryColor3fvEXT (att->data);
+ break;
+ case N:
+ glNormal3fv (att->data);
+ break;
+ case V:
+ glVertex4fv (att->data);
+ break;
+ case T:
+ assert (att->index >= 0 && att->index < 8);
+ glMultiTexCoord4fvARB (GL_TEXTURE0_ARB + att->index, att->data);
+ break;
+ case F:
+ glFogCoordfvEXT (att->data);
+ break;
+ case A:
+ assert (att->index > 0 && att->index < 16);
+ glVertexAttrib4fvARB (att->index, att->data);
+ break;
+ default:
+ assert (0);
+ }
+ }
+ glEnd ();
+}
+
+static void va_render ()
+{
+ GLint i;
+
+ for (i = 0; i < sizeof (attribs) / sizeof (*attribs); i++) {
+ struct ATTRIB_DATA *att = &attribs[i];
+ switch (att->dispatch)
+ {
+ case C:
+ glColorPointer (4, GL_FLOAT, 0, att->data);
+ glEnable (GL_COLOR_ARRAY);
+ break;
+ case S:
+ glSecondaryColorPointerEXT (4, GL_FLOAT, 0, att->data);
+ glEnable (GL_SECONDARY_COLOR_ARRAY_EXT);
+ break;
+ case N:
+ glNormalPointer (GL_FLOAT, 0, att->data);
+ glEnable (GL_NORMAL_ARRAY);
+ break;
+ case V:
+ glVertexPointer (4, GL_FLOAT, 0, att->data);
+ glEnable (GL_VERTEX_ARRAY);
+ break;
+ case T:
+ assert (att->index >= 0 && att->index < 8);
+ glClientActiveTextureARB (GL_TEXTURE0_ARB + att->index);
+ glTexCoordPointer (4, GL_FLOAT, 0, att->data);
+ glEnable (GL_TEXTURE_COORD_ARRAY);
+ break;
+ case F:
+ glFogCoordPointerEXT (GL_FLOAT, 0, att->data);
+ glEnable (GL_FOG_COORDINATE_ARRAY_EXT);
+ break;
+ case A:
+ assert (att->index > 0 && att->index < 16);
+ glVertexAttribPointerARB (att->index, 4, GL_FLOAT, GL_FALSE, 0, att->data);
+ glEnableVertexAttribArrayARB (att->index);
+ break;
+ default:
+ assert (0);
+ }
+ }
+
+ glDrawArrays (GL_POINTS, 0, 1);
+
+ for (i = 0; i < sizeof (attribs) / sizeof (*attribs); i++) {
+ struct ATTRIB_DATA *att = &attribs[i];
+ switch (att->dispatch)
+ {
+ case C:
+ glDisable (GL_COLOR_ARRAY);
+ break;
+ case S:
+ glDisable (GL_SECONDARY_COLOR_ARRAY_EXT);
+ break;
+ case N:
+ glDisable (GL_NORMAL_ARRAY);
+ break;
+ case V:
+ glDisable (GL_VERTEX_ARRAY);
+ break;
+ case T:
+ glClientActiveTextureARB (GL_TEXTURE0_ARB + att->index);
+ glDisable (GL_TEXTURE_COORD_ARRAY);
+ break;
+ case F:
+ glDisable (GL_FOG_COORDINATE_ARRAY_EXT);
+ break;
+ case A:
+ glDisableVertexAttribArrayARB (att->index);
+ break;
+ default:
+ assert (0);
+ }
+ }
+}
+
+static void dl_start ()
+{
+ glNewList (GL_COMPILE, 1);
+}
+
+static void dl_end ()
+{
+ glEndList ();
+ glCallList (1);
+}
+
+static void load_test_file (const char *filename)
+{
+ FILE *f;
+ GLint size;
+ char *code;
+ GLint i;
+
+ f = fopen (filename, "r");
+ if (f == NULL)
+ return;
+
+ fseek (f, 0, SEEK_END);
+ size = ftell (f);
+ fseek (f, 0, SEEK_SET);
+
+ code = (char *) (malloc (size));
+ if (code == NULL) {
+ fclose (f);
+ return;
+ }
+ size = fread (code, 1, size, f);
+ fclose (f);
+
+ glShaderSourceARB (vert, 1, (const GLcharARB **) (&code), &size);
+ glCompileShaderARB (vert);
+ if (!CheckObjectStatus (vert))
+ exit (0);
+
+ for (i = 0; i < sizeof (attribs) / sizeof (*attribs); i++)
+ if (attribs[i].dispatch == A && attribs[i].bind != -1)
+ glBindAttribLocationARB (prog, attribs[i].bind, attribs[i].name);
+}
+
+void InitScene (void)
+{
+ prog = glCreateProgramObjectARB ();
+ vert = glCreateShaderObjectARB (GL_VERTEX_SHADER_ARB);
+ glAttachObjectARB (prog, vert);
+ glDeleteObjectARB (vert);
+ load_test_file ("vstest.txt");
+ glLinkProgramARB (prog);
+ if (!CheckObjectStatus (prog))
+ exit (0);
+ glUseProgramObjectARB (prog);
+}
+
+void RenderScene (void)
+{
+ GLint info_length, length;
+ char output[65000], *p;
+ GLint i;
+
+ if (submit_method == SM_MAX)
+ exit (0);
+
+ /*
+ * Get the current size of the info log. Any text output produced by executed
+ * shader will be appended to the end of log.
+ */
+ glGetObjectParameterivARB (vert, GL_OBJECT_INFO_LOG_LENGTH_ARB, &info_length);
+
+ switch (submit_method)
+ {
+ case SM_IM:
+ printf ("\n--- TESTING IMMEDIATE MODE\n");
+ im_render ();
+ break;
+ case SM_VA:
+ printf ("\n--- TESTING VERTEX ARRAY MODE\n");
+ va_render ();
+ break;
+ case SM_IM_DL:
+ printf ("\n--- TESTING IMMEDIATE + DISPLAY LIST MODE\n");
+ dl_start ();
+ im_render ();
+ dl_end ();
+ break;
+ case SM_VA_DL:
+ printf ("\n--- TESTING VERTEX ARRAY + DISPLAY LIST MODE\n");
+ dl_start ();
+ va_render ();
+ dl_end ();
+ break;
+ default:
+ assert (0);
+ }
+
+ glFlush ();
+
+ /*
+ * Get the info log and set the pointer to the beginning of the output.
+ */
+ glGetInfoLogARB (vert, sizeof (output), &length, output);
+ p = output + info_length - 1;
+
+ for (i = 0; i < sizeof (attribs) / sizeof (*attribs); i++) {
+ GLuint j;
+ for (j = 0; j < attribs[i].size; j++) {
+ GLfloat value;
+ if (p == NULL) {
+ printf ("*** %s\n", "I/O error");
+ break;
+ }
+ if (strncmp (p, "true", 4) == 0)
+ value = 1.0f;
+ else if (strncmp (p, "false", 5) == 0)
+ value = 0.0f;
+ else if (sscanf (p, "%f", &value) != 1) {
+ printf ("*** %s\n", "I/O error");
+ p = NULL;
+ break;
+ }
+ if (fabs (value - attribs[i].data[j]) > EPSILON)
+ printf ("*** %s, is %f, should be %f\n", "Values are different", value, attribs[i].data[j]);
+ p = strchr (p, '\n');
+ if (p != NULL)
+ p++;
+ }
+ if (p == NULL)
+ break;
+ }
+
+ submit_method++;
+}
+
+int main (int argc, char *argv[])
+{
+ InitFramework (&argc, argv);
+ return 0;
+}
+
diff --git a/progs/slang/vstest.txt b/progs/slang/vstest.txt
new file mode 100644
index 00000000000..7f51d0bc810
--- /dev/null
+++ b/progs/slang/vstest.txt
@@ -0,0 +1,68 @@
+/*
+ * Vertex shader test.
+ * Uses all conventional attributes and 15 generic attributes to print
+ * their values, using printMESA() extension function, to the debugger
+ * to compare them with the actual passed-in values.
+ * Use different types for generic attributes to check matrix handling.
+ *
+ * Author: Michal Krol
+ */
+
+#version 110
+
+#extension MESA_shader_debug: require
+
+attribute vec4 Attribute1;
+attribute vec4 Attribute2;
+attribute vec4 Attribute3;
+attribute float Attribute4;
+attribute vec2 Attribute5;
+attribute vec3 Attribute6;
+attribute mat2 Attribute7;
+attribute mat3 Attribute9;
+attribute mat4 Attribute12;
+
+void main ()
+{
+ //
+ // Do some legal stuff.
+ //
+ gl_Position = gl_ModelViewMatrix * gl_Vertex;
+ gl_FrontColor = vec4 (1.0);
+
+ //
+ // Conventional attributes - except for gl_Vertex.
+ //
+ printMESA (gl_Color);
+ printMESA (gl_SecondaryColor);
+ printMESA (gl_Normal);
+ printMESA (gl_MultiTexCoord0);
+ printMESA (gl_MultiTexCoord1);
+ printMESA (gl_MultiTexCoord2);
+ printMESA (gl_MultiTexCoord3);
+ printMESA (gl_MultiTexCoord4);
+ printMESA (gl_MultiTexCoord5);
+ printMESA (gl_MultiTexCoord6);
+ printMESA (gl_MultiTexCoord7);
+ printMESA (gl_FogCoord);
+
+ //
+ // Generic attributes - attrib with index 0 is not used because it would
+ // alias with gl_Vertex, which is not allowed.
+ //
+ printMESA (Attribute1);
+ printMESA (Attribute2);
+ printMESA (Attribute3);
+ printMESA (Attribute4);
+ printMESA (Attribute5);
+ printMESA (Attribute6);
+ printMESA (Attribute7);
+ printMESA (Attribute9);
+ printMESA (Attribute12);
+
+ //
+ // Vertex position goes last.
+ //
+ printMESA (gl_Vertex);
+}
+
diff --git a/progs/slang/windows/vc60/cltest.dsp b/progs/slang/windows/vc60/cltest.dsp
new file mode 100644
index 00000000000..4c0c2e26b46
--- /dev/null
+++ b/progs/slang/windows/vc60/cltest.dsp
@@ -0,0 +1,94 @@
+# Microsoft Developer Studio Project File - Name="cltest" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Console Application" 0x0103
+
+CFG=cltest - 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 "cltest.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 "cltest.mak" CFG="cltest - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "cltest - Win32 Release" (based on "Win32 (x86) Console Application")
+!MESSAGE "cltest - 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)" == "cltest - 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 "cltest_release"
+# PROP Intermediate_Dir "cltest_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 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD BASE RSC /l 0x415 /d "NDEBUG"
+# ADD RSC /l 0x415 /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 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
+
+!ELSEIF "$(CFG)" == "cltest - 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 "cltest_debug"
+# PROP Intermediate_Dir "cltest_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 /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
+# ADD BASE RSC /l 0x415 /d "_DEBUG"
+# ADD RSC /l 0x415 /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 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
+
+!ENDIF
+
+# Begin Target
+
+# Name "cltest - Win32 Release"
+# Name "cltest - Win32 Debug"
+# Begin Source File
+
+SOURCE=..\..\cltest.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\cltest.txt
+# End Source File
+# End Target
+# End Project
diff --git a/progs/slang/windows/vc60/framework.dsp b/progs/slang/windows/vc60/framework.dsp
new file mode 100644
index 00000000000..76ed7d388c1
--- /dev/null
+++ b/progs/slang/windows/vc60/framework.dsp
@@ -0,0 +1,92 @@
+# Microsoft Developer Studio Project File - Name="framework" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Static Library" 0x0104
+
+CFG=framework - 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 "framework.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 "framework.mak" CFG="framework - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "framework - Win32 Release" (based on "Win32 (x86) Static Library")
+!MESSAGE "framework - Win32 Debug" (based on "Win32 (x86) Static Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "framework - 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 "framework_release"
+# PROP Intermediate_Dir "framework_release"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
+# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
+# ADD BASE RSC /l 0x415 /d "NDEBUG"
+# ADD RSC /l 0x415 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LIB32=link.exe -lib
+# ADD BASE LIB32 /nologo
+# ADD LIB32 /nologo
+
+!ELSEIF "$(CFG)" == "framework - 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 "framework_debug"
+# PROP Intermediate_Dir "framework_debug"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
+# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
+# ADD BASE RSC /l 0x415 /d "_DEBUG"
+# ADD RSC /l 0x415 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LIB32=link.exe -lib
+# ADD BASE LIB32 /nologo
+# ADD LIB32 /nologo
+
+!ENDIF
+
+# Begin Target
+
+# Name "framework - Win32 Release"
+# Name "framework - Win32 Debug"
+# Begin Source File
+
+SOURCE=..\..\framework.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\framework.h
+# End Source File
+# End Target
+# End Project
diff --git a/progs/slang/windows/vc60/slang.dsw b/progs/slang/windows/vc60/slang.dsw
new file mode 100644
index 00000000000..60536c1b0d9
--- /dev/null
+++ b/progs/slang/windows/vc60/slang.dsw
@@ -0,0 +1,74 @@
+Microsoft Developer Studio Workspace File, Format Version 6.00
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
+
+###############################################################################
+
+Project: "cltest"=".\cltest.dsp" - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+ Begin Project Dependency
+ Project_Dep_Name framework
+ End Project Dependency
+}}}
+
+###############################################################################
+
+Project: "framework"=".\framework.dsp" - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Project: "sotest"=".\sotest.dsp" - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+ Begin Project Dependency
+ Project_Dep_Name framework
+ End Project Dependency
+}}}
+
+###############################################################################
+
+Project: "vstest"=".\vstest.dsp" - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+ Begin Project Dependency
+ Project_Dep_Name framework
+ End Project Dependency
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+
diff --git a/progs/slang/windows/vc60/sotest.dsp b/progs/slang/windows/vc60/sotest.dsp
new file mode 100644
index 00000000000..105924943b7
--- /dev/null
+++ b/progs/slang/windows/vc60/sotest.dsp
@@ -0,0 +1,90 @@
+# Microsoft Developer Studio Project File - Name="sotest" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Console Application" 0x0103
+
+CFG=sotest - 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 "sotest.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 "sotest.mak" CFG="sotest - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "sotest - Win32 Release" (based on "Win32 (x86) Console Application")
+!MESSAGE "sotest - 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)" == "sotest - 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 "sotest_release"
+# PROP Intermediate_Dir "sotest_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 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD BASE RSC /l 0x415 /d "NDEBUG"
+# ADD RSC /l 0x415 /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 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
+
+!ELSEIF "$(CFG)" == "sotest - 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 "sotest_debug"
+# PROP Intermediate_Dir "sotest_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 /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
+# ADD BASE RSC /l 0x415 /d "_DEBUG"
+# ADD RSC /l 0x415 /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 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
+
+!ENDIF
+
+# Begin Target
+
+# Name "sotest - Win32 Release"
+# Name "sotest - Win32 Debug"
+# Begin Source File
+
+SOURCE=..\..\sotest.c
+# End Source File
+# End Target
+# End Project
diff --git a/progs/slang/windows/vc60/vstest.dsp b/progs/slang/windows/vc60/vstest.dsp
new file mode 100644
index 00000000000..a3a2c707f0c
--- /dev/null
+++ b/progs/slang/windows/vc60/vstest.dsp
@@ -0,0 +1,93 @@
+# Microsoft Developer Studio Project File - Name="vstest" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Console Application" 0x0103
+
+CFG=vstest - 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 "vstest.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 "vstest.mak" CFG="vstest - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "vstest - Win32 Release" (based on "Win32 (x86) Console Application")
+!MESSAGE "vstest - 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)" == "vstest - 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 "vstest_release"
+# PROP Intermediate_Dir "vstest_release"
+# 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 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD BASE RSC /l 0x415 /d "NDEBUG"
+# ADD RSC /l 0x415 /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 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
+
+!ELSEIF "$(CFG)" == "vstest - 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 "vstest_debug"
+# PROP Intermediate_Dir "vstest_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 /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
+# ADD BASE RSC /l 0x415 /d "_DEBUG"
+# ADD RSC /l 0x415 /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 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
+
+!ENDIF
+
+# Begin Target
+
+# Name "vstest - Win32 Release"
+# Name "vstest - Win32 Debug"
+# Begin Source File
+
+SOURCE=..\..\vstest.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\vstest.txt
+# End Source File
+# End Target
+# End Project
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..3a22285250c
--- /dev/null
+++ b/progs/tests/Makefile
@@ -0,0 +1,158 @@
+# 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 \
+ arbnpot-mipmap.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 \
+ prog_parameter.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 \
+ vao-01.c \
+ vao-02.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..0de6c42e398
--- /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 <win32.mak>
+
+##### 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 <math.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+#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..79b5ab75c57
--- /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 <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <GL/glut.h>
+
+
+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 <[email protected]>
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/gl.h>
+#include <GL/glext.h>
+#include <GL/glut.h>
+
+#define inline __inline__
+#include <asm/timex.h>
+
+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 <[email protected]>
+
+
+# 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 <assert.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+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..7949f87eddb
--- /dev/null
+++ b/progs/tests/arbfptest1.c
@@ -0,0 +1,210 @@
+/* Test GL_ARB_fragment_program */
+
+#include <assert.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+
+
+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[0], 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 <assert.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+#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 <assert.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+#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-mipmap.c b/progs/tests/arbnpot-mipmap.c
new file mode 100644
index 00000000000..4ed84e7acee
--- /dev/null
+++ b/progs/tests/arbnpot-mipmap.c
@@ -0,0 +1,184 @@
+
+/* 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 <stdlib.h>
+#include <stdio.h>
+#include <GL/glut.h>
+
+GLubyte mipmapImage32[40][46][3];
+GLubyte mipmapImage16[20][23][3];
+GLubyte mipmapImage8[10][11][3];
+GLubyte mipmapImage4[5][5][3];
+GLubyte mipmapImage2[2][2][3];
+GLubyte mipmapImage1[1][1][3];
+
+static void makeImages(void)
+{
+ int i, j;
+
+ for (i = 0; i < 40; i++) {
+ for (j = 0; j < 46; j++) {
+ mipmapImage32[i][j][0] = 255;
+ mipmapImage32[i][j][1] = 255;
+ mipmapImage32[i][j][2] = 0;
+ }
+ }
+ for (i = 0; i < 20; i++) {
+ for (j = 0; j < 23; j++) {
+ mipmapImage16[i][j][0] = 255;
+ mipmapImage16[i][j][1] = 0;
+ mipmapImage16[i][j][2] = 255;
+ }
+ }
+ for (i = 0; i < 10; i++) {
+ for (j = 0; j < 11; j++) {
+ mipmapImage8[i][j][0] = 255;
+ mipmapImage8[i][j][1] = 0;
+ mipmapImage8[i][j][2] = 0;
+ }
+ }
+ for (i = 0; i < 5; i++) {
+ for (j = 0; j < 5; 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;
+}
+
+static void myinit(void)
+{
+ if (!glutExtensionSupported("GL_ARB_texture_non_power_of_two")) {
+ printf("Sorry, this program requires GL_ARB_texture_non_power_of_two\n");
+ exit(1);
+ }
+
+ 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, 40, 46, 0,
+ GL_RGB, GL_UNSIGNED_BYTE, &mipmapImage32[0][0][0]);
+ glTexImage2D(GL_TEXTURE_2D, 1, 3, 20, 23, 0,
+ GL_RGB, GL_UNSIGNED_BYTE, &mipmapImage16[0][0][0]);
+ glTexImage2D(GL_TEXTURE_2D, 2, 3, 10, 11, 0,
+ GL_RGB, GL_UNSIGNED_BYTE, &mipmapImage8[0][0][0]);
+ glTexImage2D(GL_TEXTURE_2D, 3, 3, 5, 5, 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);
+}
+
+static 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();
+}
+
+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)
+{
+ 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/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 <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <GL/glut.h>
+#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 <assert.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+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 <assert.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+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..9d19ef90da5
--- /dev/null
+++ b/progs/tests/arbvptorus.c
@@ -0,0 +1,186 @@
+/*
+ * A lit, rotating torus via vertex program
+ */
+
+#include <assert.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+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"
+ "OPTION ARB_position_invariant ;"
+ "TEMP R0, R1; \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 <assert.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+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 <math.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <X11/Xlib.h>
+#include <X11/keysym.h>
+#include <GL/gl.h>
+#include <GL/glx.h>
+
+
+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 <[email protected]>
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+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 <[email protected]>
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+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..50ab5cdfa89
--- /dev/null
+++ b/progs/tests/bufferobj.c
@@ -0,0 +1,371 @@
+/*
+ * Test GL_ARB_vertex_buffer_object
+ *
+ * Brian Paul
+ * 16 Sep 2003
+ */
+
+
+#define GL_GLEXT_PROTOTYPES
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <GL/glut.h>
+
+#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 GLuint Win;
+
+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 FreeBuffers(void)
+{
+ int i;
+ for (i = 0; i < NUM_OBJECTS; i++)
+ glDeleteBuffersARB(1, &Objects[i].BufferID);
+}
+
+
+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:
+ FreeBuffers();
+ glutDestroyWindow(Win);
+ 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 );
+ Win = 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 <[email protected]>
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <GL/glut.h>
+
+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 <[email protected]>
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+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 <[email protected]>
+ */
+
+#include <assert.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <math.h>
+#include <GL/glut.h>
+#include <GL/glext.h>
+
+#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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+#include <GL/glut.h>
+
+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 <[email protected]>
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <GL/glut.h>
+
+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..c7677990bff
--- /dev/null
+++ b/progs/tests/cva.c
@@ -0,0 +1,164 @@
+/* $Id: cva.c,v 1.8 2006/11/22 19:37:21 sroland Exp $ */
+
+/*
+ * Trivial CVA test, good for testing driver fastpaths (especially
+ * indexed vertex buffers if they are supported).
+ *
+ * Gareth Hughes
+ * November 2000
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#ifdef __VMS
+# include <stddef.h> /* for ptrdiff_t, referenced by GL.h when GL_GLEXT_LEGACY defined */
+#else
+# include <malloc.h> /* for ptrdiff_t, referenced by GL.h when GL_GLEXT_LEGACY defined */
+#endif
+#ifdef _WIN32
+#include <windows.h>
+#endif
+#define GL_GLEXT_LEGACY
+#include <GL/glut.h>
+
+
+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;
+ double version;
+
+ 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 );
+
+ version = atof(string);
+ if ( version < 1.2 ) {
+ 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 <assert.h>
+#include <ctype.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+
+/*
+ * 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 [email protected]
+
+
+.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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <math.h> /* for cos(), sin(), and sqrt() */
+#ifdef __VMS
+# include <stddef.h> /* for ptrdiff_t, referenced by GL.h when GL_GLEXT_LEGACY defined */
+#else
+# include <malloc.h> /* for ptrdiff_t, referenced by GL.h when GL_GLEXT_LEGACY defined */
+#endif
+#ifdef _WIN32
+#include <windows.h>
+#endif
+#define GL_GLEXT_LEGACY
+#include <GL/glut.h> /* OpenGL Utility Toolkit header */
+
+/* Some <math.h> 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<argc; i++) {
+ if (!strcmp("-linear", argv[i])) {
+ linearFiltering = 1;
+ } else if (!strcmp("-mipmap", argv[i])) {
+ useMipmaps = 1;
+ } else if (!strcmp("-ext", argv[i])) {
+ forceExtension = 1;
+ }
+ }
+
+ glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH | GLUT_STENCIL);
+
+#if 0
+ /* In GLUT 4.0, you'll be able to do this an be sure to
+ get 2 bits of stencil if the machine has it for you. */
+ glutInitDisplayString("samples stencil>=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 <math.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+#include <assert.h>
+
+#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 <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <GL/glut.h>
+
+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 <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <GL/glut.h>
+
+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 <GL/glut.h>
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+
+/* 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 <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <GL/glut.h>
+
+
+/* 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 <[email protected]>
+ * 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 <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <GL/glut.h>
+
+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 <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <GL/glut.h>
+
+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 <assert.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+
+
+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 <assert.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+#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..8b000d234a3
--- /dev/null
+++ b/progs/tests/getprocaddress.c
@@ -0,0 +1,530 @@
+/*
+ * 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 <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <GL/gl.h>
+#include <GL/glx.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+
+
+typedef void (*generic_func)();
+
+#define EQUAL(X, Y) (fabs((X) - (Y)) < 0.001)
+
+/**
+ * The following functions are used to check that the named OpenGL function
+ * actually does what it's supposed to do.
+ * The naming of these functions is signficant. The getprocaddress.py script
+ * scans this file and extracts these function names.
+ */
+
+
+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;
+}
+
+
+static GLboolean
+test_StencilFuncSeparate(generic_func func)
+{
+#ifdef GL_VERSION_2_0
+ PFNGLSTENCILFUNCSEPARATEPROC stencilFuncSeparate = (PFNGLSTENCILFUNCSEPARATEPROC) func;
+ GLint frontFunc, backFunc;
+ GLint frontRef, backRef;
+ GLint frontMask, backMask;
+ (*stencilFuncSeparate)(GL_BACK, GL_GREATER, 2, 0xa);
+ glGetIntegerv(GL_STENCIL_FUNC, &frontFunc);
+ glGetIntegerv(GL_STENCIL_BACK_FUNC, &backFunc);
+ glGetIntegerv(GL_STENCIL_REF, &frontRef);
+ glGetIntegerv(GL_STENCIL_BACK_REF, &backRef);
+ glGetIntegerv(GL_STENCIL_VALUE_MASK, &frontMask);
+ glGetIntegerv(GL_STENCIL_BACK_VALUE_MASK, &backMask);
+ if (frontFunc != GL_ALWAYS ||
+ backFunc != GL_GREATER ||
+ frontRef != 0 ||
+ backRef != 2 ||
+ frontMask == 0xa || /* might be 0xff or ~0 */
+ backMask != 0xa)
+ return GL_FALSE;
+#endif
+ return GL_TRUE;
+}
+
+static GLboolean
+test_StencilOpSeparate(generic_func func)
+{
+#ifdef GL_VERSION_2_0
+ PFNGLSTENCILOPSEPARATEPROC stencilOpSeparate = (PFNGLSTENCILOPSEPARATEPROC) func;
+ GLint frontFail, backFail;
+ GLint frontZFail, backZFail;
+ GLint frontZPass, backZPass;
+ (*stencilOpSeparate)(GL_BACK, GL_INCR, GL_DECR, GL_INVERT);
+ glGetIntegerv(GL_STENCIL_FAIL, &frontFail);
+ glGetIntegerv(GL_STENCIL_BACK_FAIL, &backFail);
+ glGetIntegerv(GL_STENCIL_PASS_DEPTH_FAIL, &frontZFail);
+ glGetIntegerv(GL_STENCIL_BACK_PASS_DEPTH_FAIL, &backZFail);
+ glGetIntegerv(GL_STENCIL_PASS_DEPTH_PASS, &frontZPass);
+ glGetIntegerv(GL_STENCIL_BACK_PASS_DEPTH_PASS, &backZPass);
+ if (frontFail != GL_KEEP ||
+ backFail != GL_INCR ||
+ frontZFail != GL_KEEP ||
+ backZFail != GL_DECR ||
+ frontZPass != GL_KEEP ||
+ backZPass != GL_INVERT)
+ return GL_FALSE;
+#endif
+ return GL_TRUE;
+}
+
+static GLboolean
+test_StencilMaskSeparate(generic_func func)
+{
+#ifdef GL_VERSION_2_0
+ PFNGLSTENCILMASKSEPARATEPROC stencilMaskSeparate = (PFNGLSTENCILMASKSEPARATEPROC) func;
+ GLint frontMask, backMask;
+ (*stencilMaskSeparate)(GL_BACK, 0x1b);
+ glGetIntegerv(GL_STENCIL_WRITEMASK, &frontMask);
+ glGetIntegerv(GL_STENCIL_BACK_WRITEMASK, &backMask);
+ if (frontMask == 0x1b ||
+ backMask != 0x1b)
+ return GL_FALSE;
+#endif
+ return GL_TRUE;
+}
+
+
+/*
+ * The following file is auto-generated with Python.
+ */
+#include "getproclist.h"
+
+
+
+static int
+extension_supported(const char *haystack, const char *needle)
+{
+ const char *p = strstr(haystack, needle);
+ if (p) {
+ /* found string, make sure next char is space or zero */
+ const int len = strlen(needle);
+ if (p[len] == ' ' || p[len] == 0)
+ return 1;
+ else
+ return 0;
+ }
+ 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] == '-') {
+ const char *version = (const char *) glGetString(GL_VERSION);
+ if (entry->name[1] == '1') {
+ /* check GL version 1.x */
+ if (version[0] == '1' &&
+ version[1] == '.' &&
+ version[2] >= entry->name[3])
+ doTests = 1;
+ else
+ doTests = 0;
+ }
+ else if (entry->name[1] == '2') {
+ if (version[0] == '2' &&
+ version[1] == '.' &&
+ 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,
+ GLX_STENCIL_SIZE, 1,
+ None };
+ int attribDouble[] = {
+ GLX_RGBA,
+ GLX_RED_SIZE, 1,
+ GLX_GREEN_SIZE, 1,
+ GLX_BLUE_SIZE, 1,
+ GLX_STENCIL_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..d16b2d93d0e
--- /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 <[email protected]>
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <GL/glut.h>
+
+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 <[email protected]>
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <GL/glut.h>
+
+#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..85bda8d0152
--- /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 <[email protected]>
+ */
+
+#include <GL/glx.h>
+#include <GL/gl.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <math.h>
+
+#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>\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..61a1519ae6b
--- /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 <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+#include <GL/glut.h>
+
+
+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 <number of texture objects>\n");
+ printf(" -size <width> <height> - 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 <n> - Set lower priority on <n> 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..3bcb8a88584
--- /dev/null
+++ b/progs/tests/mipmap_limits.c
@@ -0,0 +1,252 @@
+/* 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 <stdlib.h>
+#include <stdio.h>
+#include <GL/glut.h>
+
+static GLint BaseLevel = 0, MaxLevel = 8;
+static GLfloat MinLod = -1, MaxLod = 9;
+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("BASE_LEVEL = %d MAX_LEVEL = %d MIN_LOD = %f MAX_LOD = %f Bias = %.2g filter = %s\n",
+ BaseLevel, MaxLevel, MinLod, MaxLod, LodBias,
+ NearestFilter ? "LINEAR" : "NEAREST");
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, BaseLevel);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, MaxLevel);
+
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_LOD, MinLod);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LOD, MaxLod);
+
+ if (NearestFilter) {
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
+ GL_NEAREST_MIPMAP_NEAREST);
+ }
+ else {
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
+ GL_LINEAR_MIPMAP_LINEAR);
+ }
+
+ glTexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, LodBias);
+
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ glBegin(GL_QUADS);
+ glTexCoord2f(0.0, 0.0); glVertex3f(-2.0, -1.0, 0.0);
+ glTexCoord2f(0.0, tcm); glVertex3f(-2.0, 1.0, 0.0);
+ glTexCoord2f(tcm, 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 'n':
+ MinLod -= 0.02;
+ break;
+ case 'N':
+ MinLod += 0.02;
+ break;
+ case 'x':
+ MaxLod -= 0.02;
+ break;
+ case 'X':
+ MaxLod += 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(" n/N decrease/increase GL_TEXTURE_MIN_LOD\n");
+ printf(" x/X decrease/increase GL_TEXTURE_MAX_LOD\n");
+ printf(" l/L decrease/increase GL_TEXTURE_LOD_BIAS\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..c824b38703a
--- /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 <assert.h>
+#include <math.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#ifdef __VMS
+# include <stddef.h> /* for ptrdiff_t, referenced by GL.h when GL_GLEXT_LEGACY defined */
+#else
+# include <malloc.h> /* for ptrdiff_t, referenced by GL.h when GL_GLEXT_LEGACY defined */
+#endif
+#ifdef _WIN32
+#include <windows.h>
+#endif
+#define GL_GLEXT_LEGACY
+#include <GL/glut.h>
+
+#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 <assert.h>
+#include <math.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#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<height;i++) {
+ for (j=0;j<width;j++) {
+ int p = i*width+j;
+ if (i < height / 2) {
+ tex[p][0] = 0; tex[p][1] = 0; tex[p][2] = 0;
+ }
+ else {
+ tex[p][0] = 255; tex[p][1] = 0; tex[p][2] = 0;
+ }
+ }
+ }
+
+ glTexImage2D( GL_TEXTURE_2D, 0, 3, width, height, 0,
+ GL_RGB, GL_UNSIGNED_BYTE, tex );
+ 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_REPEAT );
+ glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
+
+
+ /*
+ * setup second texture object
+ */
+ glActiveTextureARB(GL_TEXTURE1_ARB);
+ glEnable( GL_TEXTURE_2D );
+ glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_ADD );
+
+ glBindTexture( GL_TEXTURE_2D, TexObj[1] );
+ assert(glIsTexture(TexObj[1]));
+
+ /* left=green, right = blue */
+ for (i=0;i<height;i++) {
+ for (j=0;j<width;j++) {
+ int p = i*width+j;
+ if (j < width / 2) {
+ tex[p][0] = 0; tex[p][1] = 255; tex[p][2] = 0;
+ }
+ else {
+ tex[p][0] = 0; tex[p][1] = 0; tex[p][2] = 255;
+ }
+ }
+ }
+ glTexImage2D( GL_TEXTURE_2D, 0, 3, width, height, 0,
+ GL_RGB, GL_UNSIGNED_BYTE, tex );
+ 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_REPEAT );
+ glTexParameteri( GL_TEXTURE_2D, 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_DOUBLE );
+
+ Window = glutCreateWindow("Texture Objects");
+ if (!Window) {
+ exit(1);
+ }
+
+ init();
+ init_arrays();
+
+ glutReshapeFunc( reshape );
+ glutKeyboardFunc( key );
+ if (Anim)
+ glutIdleFunc( idle );
+ glutDisplayFunc( draw );
+ glutMainLoop();
+ return 0;
+}
diff --git a/progs/tests/multiwindow.c b/progs/tests/multiwindow.c
new file mode 100644
index 00000000000..e004b0336ca
--- /dev/null
+++ b/progs/tests/multiwindow.c
@@ -0,0 +1,169 @@
+/* $Id: multiwindow.c,v 1.1 2001/08/21 14:25:31 brianp Exp $ */
+
+/*
+ * A skeleton/template GLUT program
+ *
+ * Written by Brian Paul and in the public domain.
+ */
+
+
+/*
+ * $Log: multiwindow.c,v $
+ * Revision 1.1 2001/08/21 14:25:31 brianp
+ * simple multi-window GLUT test prog
+ *
+ * Revision 1.1.1.1 1999/08/19 00:55:42 jtg
+ * Imported sources
+ *
+ * Revision 1.2 1998/11/07 14:20:14 brianp
+ * added simple rotation, animation of cube
+ *
+ * Revision 1.1 1998/11/07 14:14:37 brianp
+ * Initial revision
+ *
+ */
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <GL/glut.h>
+
+
+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 <[email protected]>
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <GL/glut.h>
+#include <GL/glext.h>
+
+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 <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <string.h>
+#include <GL/glut.h>
+
+
+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 <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <GL/glut.h>
+
+#include "../util/readtex.c" /* a hack, I know */
+
+#define IMAGE_FILE "../images/girl.rgb"
+
+static int ImgWidth, ImgHeight;
+static GLenum ImgFormat;
+static GLubyte *Image = NULL;
+
+static int APosX, APosY; /* simple drawpixels */
+static int BPosX, BPosY; /* read/draw pixels */
+static int CPosX, CPosY; /* copypixels */
+
+static GLboolean DrawFront = GL_FALSE;
+static GLboolean ScaleAndBias = GL_FALSE;
+static GLboolean Benchmark = GL_FALSE;
+
+static 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/prog_parameter.c b/progs/tests/prog_parameter.c
new file mode 100644
index 00000000000..96697e5bda6
--- /dev/null
+++ b/progs/tests/prog_parameter.c
@@ -0,0 +1,285 @@
+/*
+ * (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
+ * 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 prog_parameter.c
+ *
+ * Test various aspects of setting (and getting) low-level program parameters.
+ * This is primarilly intended as a test for GL_EXT_gpu_program_parameters,
+ * but it turns out that it hits some other functionality along the way.
+ *
+ * \author Ian Romanick <[email protected]>
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <GL/glut.h>
+
+#ifndef GL_EXT_gpu_program_parameters
+typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERS4FVEXTPROC)(GLenum,
+ GLuint, GLsizei, const GLfloat *);
+typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERS4FVEXTPROC)(GLenum,
+ GLuint, GLsizei, const GLfloat *);
+#endif
+
+static PFNGLPROGRAMLOCALPARAMETER4FVARBPROC program_local_parameter4fv = NULL;
+static PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC get_program_local_parameterfv = NULL;
+static PFNGLPROGRAMENVPARAMETER4FVARBPROC program_env_parameter4fv = NULL;
+static PFNGLGETPROGRAMENVPARAMETERFVARBPROC get_program_env_parameterfv = NULL;
+static PFNGLBINDPROGRAMARBPROC bind_program = NULL;
+static PFNGLGETPROGRAMIVARBPROC get_program = NULL;
+
+static PFNGLPROGRAMLOCALPARAMETERS4FVEXTPROC program_local_parameters4fv = NULL;
+static PFNGLPROGRAMENVPARAMETERS4FVEXTPROC program_env_parameters4fv = NULL;
+
+static int Width = 400;
+static int Height = 200;
+static const GLfloat Near = 5.0, Far = 25.0;
+
+
+static void Display( void )
+{
+}
+
+
+static void Idle( void )
+{
+}
+
+
+static void Visible( int vis )
+{
+ if ( vis == GLUT_VISIBLE ) {
+ glutIdleFunc( Idle );
+ }
+ else {
+ glutIdleFunc( NULL );
+ }
+}
+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 );
+}
+
+
+static void Key( unsigned char key, int x, int y )
+{
+ (void) x;
+ (void) y;
+ switch (key) {
+ case 27:
+ exit(0);
+ break;
+ }
+ glutPostRedisplay();
+}
+
+
+static int set_parameter_batch( GLsizei count, GLfloat * param,
+ const char * name,
+ PFNGLPROGRAMLOCALPARAMETER4FVARBPROC set_parameter,
+ PFNGLPROGRAMLOCALPARAMETERS4FVEXTPROC set_parameters,
+ PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC get_parameter
+ )
+{
+ unsigned i;
+ int pass = 1;
+
+
+ for ( i = 0 ; i < (4 * count) ; i++ ) {
+ param[i] = (GLfloat) random() / (GLfloat) random();
+ }
+
+ /* Try using the "classic" interface.
+ */
+ printf("Testing glProgram%sParameter4fvARB (count = %u)...\n", name, count);
+ for ( i = 0 ; i < count ; i++ ) {
+ (*set_parameter)(GL_VERTEX_PROGRAM_ARB, i, & param[i * 4]);
+ }
+
+ for ( i = 0 ; i < count ; i++ ) {
+ GLfloat temp[4];
+
+ (*get_parameter)(GL_VERTEX_PROGRAM_ARB, i, temp);
+
+ if ( (temp[0] != param[(i * 4) + 0])
+ || (temp[1] != param[(i * 4) + 1])
+ || (temp[2] != param[(i * 4) + 2])
+ || (temp[3] != param[(i * 4) + 3]) ) {
+ printf("Mismatch in glProgram%sParameter4fvARB index %u!\n", name, i);
+ printf("Got { %f, %f, %f, %f }, expected { %f, %f, %f, %f }!\n",
+ temp[0], temp[1],
+ temp[2], temp[3],
+ param[(i * 4) + 0], param[(i * 4) + 1],
+ param[(i * 4) + 2], param[(i * 4) + 3]);
+ pass = 0;
+ break;
+ }
+ }
+
+
+ if ( set_parameters == NULL ) {
+ return pass;
+ }
+
+
+ for ( i = 0 ; i < (4 * count) ; i++ ) {
+ param[i] = (GLfloat) random() / (GLfloat) random();
+ }
+
+ printf("Testing glProgram%sParameters4fvEXT (count = %u)...\n", name, count);
+ (*set_parameters)(GL_VERTEX_PROGRAM_ARB, 0, count, param);
+
+ for ( i = 0 ; i < count ; i++ ) {
+ GLfloat temp[4];
+
+ (*get_parameter)(GL_VERTEX_PROGRAM_ARB, i, temp);
+
+ if ( (temp[0] != param[(i * 4) + 0])
+ || (temp[1] != param[(i * 4) + 1])
+ || (temp[2] != param[(i * 4) + 2])
+ || (temp[3] != param[(i * 4) + 3]) ) {
+ printf("Mismatch in glProgram%sParameters4fvEXT index %u!\n", name, i);
+ printf("Got { %f, %f, %f, %f }, expected { %f, %f, %f, %f }!\n",
+ temp[0], temp[1],
+ temp[2], temp[3],
+ param[(i * 4) + 0], param[(i * 4) + 1],
+ param[(i * 4) + 2], param[(i * 4) + 3]);
+ pass = 0;
+ break;
+ }
+ }
+
+
+ return pass;
+}
+
+
+static void Init( void )
+{
+ const char * const ver_string = (const char * const)
+ glGetString( GL_VERSION );
+ int pass = 1;
+ GLfloat * params;
+ GLint max_program_env_parameters;
+ GLint max_program_local_parameters;
+
+
+ printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+ printf("GL_VERSION = %s\n\n", ver_string);
+
+ if ( !glutExtensionSupported("GL_ARB_vertex_program") ) {
+ printf("Sorry, this program requires GL_ARB_vertex_program\n");
+ exit(2);
+ }
+
+
+ program_local_parameter4fv = glutGetProcAddress( "glProgramLocalParameter4fvARB" );
+ program_env_parameter4fv = glutGetProcAddress( "glProgramEnvParameter4fvARB" );
+
+ get_program_local_parameterfv = glutGetProcAddress( "glGetProgramLocalParameterfvARB" );
+ get_program_env_parameterfv = glutGetProcAddress( "glGetProgramEnvParameterfvARB" );
+
+ bind_program = glutGetProcAddress( "glBindProgramARB" );
+ get_program = glutGetProcAddress( "glGetProgramivARB" );
+
+ if ( glutExtensionSupported("GL_EXT_gpu_program_parameters") ) {
+ printf("GL_EXT_gpu_program_parameters available, testing that path.\n");
+
+ program_local_parameters4fv = glutGetProcAddress( "glProgramLocalParameters4fvEXT" );
+ program_env_parameters4fv = glutGetProcAddress( "glProgramEnvParameters4fvEXT" );
+ }
+ else {
+ printf("GL_EXT_gpu_program_parameters not available.\n");
+
+ program_local_parameters4fv = NULL;
+ program_env_parameters4fv = NULL;
+ }
+
+
+
+ /* Since the test sets program local parameters, a program must be bound.
+ * Program source, however, is not needed.
+ */
+ (*bind_program)(GL_VERTEX_PROGRAM_ARB, 1);
+
+
+ (*get_program)(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_ENV_PARAMETERS_ARB,
+ & max_program_env_parameters);
+
+ params = malloc(max_program_env_parameters * 4 * sizeof(GLfloat));
+
+ pass &= set_parameter_batch(max_program_env_parameters, params, "Env",
+ program_env_parameter4fv,
+ program_env_parameters4fv,
+ get_program_env_parameterfv);
+
+
+ (*get_program)(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB,
+ & max_program_local_parameters);
+
+ if (max_program_local_parameters > max_program_env_parameters) {
+ params = realloc(params,
+ max_program_local_parameters * 4 * sizeof(GLfloat));
+ }
+
+ pass &= set_parameter_batch(max_program_local_parameters, params, "Local",
+ program_local_parameter4fv,
+ program_local_parameters4fv,
+ get_program_local_parameterfv);
+
+ free(params);
+
+ if (! pass) {
+ printf("FAIL!\n");
+ exit(1);
+ }
+
+ printf("PASS!\n");
+}
+
+
+int main( int argc, char *argv[] )
+{
+ glutInit( &argc, argv );
+ glutInitWindowPosition( 0, 0 );
+ glutInitWindowSize( Width, Height );
+ glutInitDisplayMode( GLUT_RGB );
+ glutCreateWindow( "Program Parameters Test" );
+ glutReshapeFunc( Reshape );
+ glutKeyboardFunc( Key );
+ glutDisplayFunc( Display );
+ glutVisibilityFunc( Visible );
+
+ Init();
+
+ 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 <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <GL/glut.h>
+#if 0
+#include "texture.h"
+#else
+#include "../util/readtex.c"
+#endif
+
+
+/* Some <math.h> 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 <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <GL/glut.h>
+
+/* 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 <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <GL/glut.h>
+
+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..ebe73f19f42
--- /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 <GL/gl.h>
+#include <GL/glx.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+
+
+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 <[email protected]>
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+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 <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <GL/glut.h>
+
+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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+#include <GL/glut.h>
+
+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 <assert.h>
+#include <math.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#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 <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <string.h>
+#define GL_GLEXT_PROTOTYPES 1
+#include <GL/glut.h>
+
+#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 <assert.h>
+#include <stdio.h>
+#include <GL/glut.h>
+#include <GL/glx.h>
+#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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+#include <GL/glut.h>
+
+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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <GL/glut.h>
+
+#undef max
+#undef min
+#define max( a, b ) ((a) >= (b) ? (a) : (b))
+#define min( a, b ) ((a) <= (b) ? (a) : (b))
+
+GLfloat 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..3d59d9ac264
--- /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 <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <GL/glut.h>
+#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 <GL/gl.h>
+#include <GL/glx.h>
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <X11/keysym.h>
+
+
+/*
+ * 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..61c1fdd6b4f
--- /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 <math.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <GL/glut.h>
+#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..6e9fbe0c70f
--- /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 <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <GL/glut.h>
+
+
+#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/vao-01.c b/progs/tests/vao-01.c
new file mode 100644
index 00000000000..c2d70885f05
--- /dev/null
+++ b/progs/tests/vao-01.c
@@ -0,0 +1,177 @@
+/*
+ * (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
+ * 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 vao-01.c
+ *
+ * Simple test of APPLE_vertex_array_object functionality. This test creates
+ * a VAO, pushed it (via \c glPushClientAttrib), modifies the VAO, then pops
+ * it (via \c glPopClientAttrib). After popping, the state of the VAO is
+ * examined.
+ *
+ * According the the APPLE_vertex_array_object spec, the contents of the VAO
+ * should be restored to the values that they had when pushed.
+ *
+ * \author Ian Romanick <[email protected]>
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+#ifdef __darwin__
+#include <GLUT/glut.h>
+
+typedef void (* PFNGLBINDVERTEXARRAYAPPLEPROC) (GLuint array);
+typedef void (* PFNGLDELETEVERTEXARRAYSAPPLEPROC) (GLsizei n, const GLuint *arrays);
+typedef void (* PFNGLGENVERTEXARRAYSAPPLEPROC) (GLsizei n, GLuint *arrays);
+typedef GLboolean (* PFNGLISVERTEXARRAYAPPLEPROC) (GLuint array);
+
+#else
+#include <GL/glut.h>
+#endif
+
+static PFNGLBINDVERTEXARRAYAPPLEPROC bind_vertex_array = NULL;
+static PFNGLGENVERTEXARRAYSAPPLEPROC gen_vertex_arrays = NULL;
+static PFNGLDELETEVERTEXARRAYSAPPLEPROC delete_vertex_arrays = NULL;
+static PFNGLISVERTEXARRAYAPPLEPROC is_vertex_array = NULL;
+
+static int Width = 400;
+static int Height = 200;
+static const GLfloat Near = 5.0, Far = 25.0;
+
+
+static void Display( void )
+{
+}
+
+
+static void Idle( void )
+{
+}
+
+
+static void Visible( int vis )
+{
+ if ( vis == GLUT_VISIBLE ) {
+ glutIdleFunc( Idle );
+ }
+ else {
+ glutIdleFunc( NULL );
+ }
+}
+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 );
+}
+
+
+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 );
+ GLuint obj;
+ int pass = 1;
+ void * ptr;
+
+
+ printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+ printf("GL_VERSION = %s\n\n", ver_string);
+
+ if ( !glutExtensionSupported("GL_APPLE_vertex_array_object") ) {
+ printf("Sorry, this program requires GL_APPLE_vertex_array_object\n");
+ exit(2);
+ }
+
+ bind_vertex_array = glutGetProcAddress( "glBindVertexArrayAPPLE" );
+ gen_vertex_arrays = glutGetProcAddress( "glGenVertexArraysAPPLE" );
+ delete_vertex_arrays = glutGetProcAddress( "glDeleteVertexArraysAPPLE" );
+ is_vertex_array = glutGetProcAddress( "glIsVertexArrayAPPLE" );
+
+
+ (*gen_vertex_arrays)( 1, & obj );
+ (*bind_vertex_array)( obj );
+ glVertexPointer( 4, GL_FLOAT, sizeof(GLfloat) * 4, (void *) 0xDEADBEEF);
+ glEnableClientState( GL_VERTEX_ARRAY );
+
+ glPushClientAttrib( GL_CLIENT_VERTEX_ARRAY_BIT );
+
+ glVertexPointer( 4, GL_FLOAT, sizeof(GLfloat) * 4, (void *) 0xBADDC0DE);
+ glDisableClientState( GL_VERTEX_ARRAY );
+
+ glPopClientAttrib();
+
+ if ( ! glIsEnabled( GL_VERTEX_ARRAY ) ) {
+ printf( "Array state is incorrectly disabled.\n" );
+ pass = 0;
+ }
+
+ glGetPointerv( GL_VERTEX_ARRAY_POINTER, & ptr );
+ if ( ptr != (void *) 0xDEADBEEF ) {
+ printf( "Array pointer is incorrectly set to 0x%p.\n", ptr );
+ pass = 0;
+ }
+
+ if ( ! pass ) {
+ printf( "FAIL!\n" );
+ exit(1);
+ }
+}
+
+
+int main( int argc, char *argv[] )
+{
+ glutInit( &argc, argv );
+ glutInitWindowPosition( 0, 0 );
+ glutInitWindowSize( Width, Height );
+ glutInitDisplayMode( GLUT_RGB );
+ glutCreateWindow( "GL_APPLE_vertex_array_object demo" );
+ glutReshapeFunc( Reshape );
+ glutKeyboardFunc( Key );
+ glutDisplayFunc( Display );
+ glutVisibilityFunc( Visible );
+
+ Init();
+
+ return 0;
+}
diff --git a/progs/tests/vao-02.c b/progs/tests/vao-02.c
new file mode 100644
index 00000000000..993bc368d40
--- /dev/null
+++ b/progs/tests/vao-02.c
@@ -0,0 +1,205 @@
+/*
+ * (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
+ * 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 vao-02.c
+ *
+ * Simple test of APPLE_vertex_array_object functionality. This test creates
+ * a VAO, pushed it (via \c glPushClientAttrib), deletes the VAO, then pops
+ * it (via \c glPopClientAttrib). After popping, the state of the VAO is
+ * examined.
+ *
+ * According the the APPLE_vertex_array_object spec, the contents of the VAO
+ * should be restored to the values that they had when pushed.
+ *
+ * \author Ian Romanick <[email protected]>
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+#ifdef __darwin__
+#include <GLUT/glut.h>
+
+typedef void (* PFNGLBINDVERTEXARRAYAPPLEPROC) (GLuint array);
+typedef void (* PFNGLDELETEVERTEXARRAYSAPPLEPROC) (GLsizei n, const GLuint *arrays);
+typedef void (* PFNGLGENVERTEXARRAYSAPPLEPROC) (GLsizei n, GLuint *arrays);
+typedef GLboolean (* PFNGLISVERTEXARRAYAPPLEPROC) (GLuint array);
+
+#else
+#include <GL/glut.h>
+#endif
+
+static PFNGLBINDVERTEXARRAYAPPLEPROC bind_vertex_array = NULL;
+static PFNGLGENVERTEXARRAYSAPPLEPROC gen_vertex_arrays = NULL;
+static PFNGLDELETEVERTEXARRAYSAPPLEPROC delete_vertex_arrays = NULL;
+static PFNGLISVERTEXARRAYAPPLEPROC is_vertex_array = NULL;
+
+static int Width = 400;
+static int Height = 200;
+static const GLfloat Near = 5.0, Far = 25.0;
+
+
+static void Display( void )
+{
+}
+
+
+static void Idle( void )
+{
+}
+
+
+static void Visible( int vis )
+{
+ if ( vis == GLUT_VISIBLE ) {
+ glutIdleFunc( Idle );
+ }
+ else {
+ glutIdleFunc( NULL );
+ }
+}
+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 );
+}
+
+
+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 );
+ GLuint obj;
+ int pass = 1;
+ void * ptr;
+ GLenum err;
+
+
+ printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+ printf("GL_VERSION = %s\n\n", ver_string);
+
+ if ( !glutExtensionSupported("GL_APPLE_vertex_array_object") ) {
+ printf("Sorry, this program requires GL_APPLE_vertex_array_object\n");
+ exit(2);
+ }
+
+ bind_vertex_array = glutGetProcAddress( "glBindVertexArrayAPPLE" );
+ gen_vertex_arrays = glutGetProcAddress( "glGenVertexArraysAPPLE" );
+ delete_vertex_arrays = glutGetProcAddress( "glDeleteVertexArraysAPPLE" );
+ is_vertex_array = glutGetProcAddress( "glIsVertexArrayAPPLE" );
+
+
+ (*gen_vertex_arrays)( 1, & obj );
+ (*bind_vertex_array)( obj );
+ glVertexPointer( 4, GL_FLOAT, sizeof(GLfloat) * 4, (void *) 0xDEADBEEF);
+ glEnableClientState( GL_VERTEX_ARRAY );
+
+ glPushClientAttrib( GL_CLIENT_VERTEX_ARRAY_BIT );
+
+ (*delete_vertex_arrays)( 1, & obj );
+
+ err = glGetError();
+ if (err) {
+ printf( "glGetError incorrectly returned 0x%04x.\n", err );
+ pass = 0;
+ }
+
+ if ( (*is_vertex_array)( obj ) ) {
+ printf( "Array object is incorrectly still valid.\n" );
+ pass = 0;
+ }
+
+ err = glGetError();
+ if (err) {
+ printf( "glGetError incorrectly returned 0x%04x.\n", err );
+ pass = 0;
+ }
+
+ glPopClientAttrib();
+
+ err = glGetError();
+ if (err) {
+ printf( "glGetError incorrectly returned 0x%04x.\n", err );
+ pass = 0;
+ }
+
+ if ( ! (*is_vertex_array)( obj ) ) {
+ printf( "Array object is incorrectly invalid.\n" );
+ pass = 0;
+ }
+
+ if ( ! glIsEnabled( GL_VERTEX_ARRAY ) ) {
+ printf( "Array state is incorrectly disabled.\n" );
+ pass = 0;
+ }
+
+ glGetPointerv( GL_VERTEX_ARRAY_POINTER, & ptr );
+ if ( ptr != (void *) 0xDEADBEEF ) {
+ printf( "Array pointer is incorrectly set to 0x%p.\n", ptr );
+ pass = 0;
+ }
+
+ if ( ! pass ) {
+ printf( "FAIL!\n" );
+ exit(1);
+ }
+}
+
+
+int main( int argc, char *argv[] )
+{
+ glutInit( &argc, argv );
+ glutInitWindowPosition( 0, 0 );
+ glutInitWindowSize( Width, Height );
+ glutInitDisplayMode( GLUT_RGB );
+ glutCreateWindow( "GL_APPLE_vertex_array_object demo" );
+ glutReshapeFunc( Reshape );
+ glutKeyboardFunc( Key );
+ glutDisplayFunc( Display );
+ glutVisibilityFunc( Visible );
+
+ Init();
+
+ 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 <assert.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+#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 <assert.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+
+/*
+ * 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 <assert.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+
+
+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 <assert.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+
+
+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 <assert.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+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 <assert.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+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 <assert.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+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 <assert.h>
+#include <math.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+#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 <math.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+#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 <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+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/tools/trace/Makefile b/progs/tools/trace/Makefile
new file mode 100644
index 00000000000..3f7bdcbc935
--- /dev/null
+++ b/progs/tools/trace/Makefile
@@ -0,0 +1,30 @@
+# Makefile for Thomas Sondergaard's API tracer
+
+TOP = ../../..
+
+include $(TOP)/configs/current
+
+
+OBJECTS = gltrace.o gltrace_support.o
+
+TRACER = gltrace.so
+
+.cc.o:
+ $(CXX) -c $(INCDIRS) $(CXXFLAGS) $< -o $@
+
+
+default: $(TRACER)
+
+$(TRACER): $(OBJECTS)
+ $(TOP)/bin/mklib -o $(TRACER) -noprefix -cplusplus \
+ $(MKLIB_OPTIONS) $(OBJECTS)
+
+gltrace.cc: gltrace.py
+ PYTHONPATH=$(TOP)/src/mesa/glapi python gltrace.py -f $(TOP)/src/mesa/glapi/gl_API.xml > gltrace.cc
+
+
+clean:
+ rm -f $(OBJECTS)
+ rm -f $(TRACER)
+ rm -f *~
+ rm -f gltrace.cc
diff --git a/progs/tools/trace/README b/progs/tools/trace/README
new file mode 100644
index 00000000000..7b3141dba7b
--- /dev/null
+++ b/progs/tools/trace/README
@@ -0,0 +1,23 @@
+NAME
+ gltrace - trace opengl calls
+
+SYNOPSIS
+ gltrace [OPTION] command [arg ...]
+
+DESCRIPTION
+ -h help (this text)
+ -c log gl calls
+ -t time stamp log entries
+ -e check for and log errors. errors occurring between
+ glBegin() and glEnd() are checked at glEnd()
+ -v verbose. Shows configuration settings passed to
+ gltrace.so
+ -l LOGFILE logfile. Default is stderr
+
+PROBLEMS
+ Not all OpenGL extensions are known and traced by gltrace. Extension
+ functions not initialized using glXGetProcAddress(ARB) will not be
+ traced.
+
+AUTHOR
+ Thomas Sondergaard (ts_news1 'at' sondergaard.cc)
diff --git a/progs/tools/trace/gltrace b/progs/tools/trace/gltrace
new file mode 100755
index 00000000000..d386912cf25
--- /dev/null
+++ b/progs/tools/trace/gltrace
@@ -0,0 +1,82 @@
+#!/bin/bash
+
+# Copyright (C) 2006 Thomas Sondergaard
+# 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:
+# Thomas Sondergaard <[email protected]>
+
+usage="usage: $0 [ -hctev ] [-l LOGFILE] program [args...]\n\t-h\t\thelp (this text)\n\t-c\t\tlog gl calls\n\t-t\t\ttime stamp log entries\n\t-e\t\tcheck for and log errors. errors occurring between\n\t\t\tglBegin() and glEnd() are checked at glEnd()\n\t-v\t\tverbose. Shows configuration settings passed to\n\t\t\tgltrace.so\n\t-l LOGFILE\tlogfile. Default is stderr"
+
+# Path to gltrace.so - must not be relative
+#GLTRACE_SO=/home/ts/Mesa_gltrace/src/mesa/glapi/gltrace.so
+# This seems to work:
+GLTRACE_SO=./gltrace.so
+
+# Set options from command line
+
+VERBOSE=0
+GLTRACE_LOG_CALLS=0
+GLTRACE_LOG_TIME=0
+GLTRACE_CHECK_ERRORS=0
+export GLTRACE_LOG_CALLS GLTRACE_LOG_TIME GLTRACE_CHECK_ERRORS
+
+if [ $# -eq 0 ]; then
+ echo -e $usage
+ exit
+fi
+
+while getopts "hctevl:" options; do
+ case $options in
+ h) echo -e $usage
+ exit 1;;
+ c) GLTRACE_LOG_CALLS=1;;
+ t) GLTRACE_LOG_TIME=1;;
+ e) GLTRACE_CHECK_ERRORS=1;;
+ l) GLTRACE_LOGFILE=$OPTARG
+ export GLTRACE_LOGFILE;;
+ v) VERBOSE=1;;
+ *) echo -e $usage
+ exit 1;;
+ esac
+done
+
+# Remove the parsed args
+shift $(($OPTIND-1))
+
+if [ ! -r $GLTRACE_SO ]; then
+ echo "Error: The gltrace.so file '$GLTRACE_SO' is missing!"
+ exit 1
+fi
+
+export LD_PRELOAD=$GLTRACE_SO
+
+if [ $VERBOSE -eq 1 ]; then
+ echo GLTRACE_LOG_CALLS=$GLTRACE_LOG_CALLS
+ echo GLTRACE_LOG_TIME=$GLTRACE_LOG_TIME
+ echo GLTRACE_CHECK_ERRORS=$GLTRACE_CHECK_ERRORS
+ echo GLTRACE_LOGFILE=$GLTRACE_LOGFILE
+ echo LD_PRELOAD=$LD_PRELOAD
+ echo command=$*
+fi
+
+exec $*
diff --git a/progs/tools/trace/gltrace.py b/progs/tools/trace/gltrace.py
new file mode 100644
index 00000000000..973881ac94d
--- /dev/null
+++ b/progs/tools/trace/gltrace.py
@@ -0,0 +1,189 @@
+#!/usr/bin/env python
+
+# Copyright (C) 2006 Thomas Sondergaard
+# 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:
+# Thomas Sondergaard <[email protected]>
+
+import gl_XML, glX_XML, glX_proto_common, license
+import sys, getopt, copy, string
+
+def create_argument_string(parameters):
+ """Create a parameter string from a list of gl_parameters."""
+
+ list = []
+ for p in parameters:
+ list.append( p.name )
+ #if len(list) == 0: list = ["void"]
+
+ return string.join(list, ", ")
+
+def create_logfunc_string(func, name):
+ """Create a parameter string from a list of gl_parameters."""
+
+ list = []
+ list.append('"gl' + name + '("')
+ sep = None
+ for p in func.parameters:
+ if (sep):
+ list.append(sep)
+ list.append( p.name )
+ sep = '", "'
+ list.append('");"')
+ #if len(list) == 0: list = ["void"]
+
+ return "if (config.logCalls) GLTRACE_LOG(" + string.join(list, " << ")+");";
+
+class PrintGltrace(glX_proto_common.glx_print_proto): #(gl_XML.gl_print_base):
+ def __init__(self):
+ gl_XML.gl_print_base.__init__(self)
+
+ self.name = "gltrace.py"
+ self.license = license.bsd_license_template % ( \
+"""Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+(C) Copyright IBM Corporation 2004""", "PRECISION INSIGHT, IBM")
+ #self.header_tag = "_INDIRECT_H_"
+
+ self.last_category = ""
+ return
+
+
+ def printRealHeader(self):
+ print """/**
+ * \\file
+ * gl and glX wrappers for tracing
+ *
+ * \\author Thomas Sondergaard <[email protected]>
+ */
+"""
+ #self.printVisibility( "HIDDEN", "hidden" )
+ #self.printFastcall()
+ #self.printNoinline()
+
+ print """
+#include <GL/gl.h>
+#include <GL/glx.h>
+#include <GL/glu.h>
+#include <dlfcn.h>
+#include "gltrace_support.h"
+
+using namespace gltrace;
+
+static GLenum real_glGetError() {
+ static GLenum (*real_func)(void) = 0;
+ if (!real_func) real_func = (GLenum (*)(void)) dlsym(RTLD_NEXT, "glGetError");
+ return real_func();
+}
+
+bool betweenGLBeginEnd = false;
+
+extern "C" {
+
+
+__GLXextFuncPtr real_glXGetProcAddressARB(const GLubyte *func_name) {
+ static __GLXextFuncPtr (*real_func)(const GLubyte *func_name) = 0;
+ if (!real_func) real_func = (__GLXextFuncPtr (*)(const GLubyte *func_name)) dlsym(RTLD_NEXT, "glXGetProcAddressARB");
+
+ return real_func(func_name);
+}
+
+__GLXextFuncPtr glXGetProcAddressARB(const GLubyte *func_name_ubyte) {
+ std::string func_name =
+ std::string("gltrace_")+reinterpret_cast<const char*>(func_name_ubyte);
+
+ __GLXextFuncPtr f = (__GLXextFuncPtr) dlsym(RTLD_DEFAULT, func_name.c_str());
+ if (!f) {
+ GLTRACE_LOG("warning: Could not resolve '" << func_name << "' - function will not be intercepted");
+ return real_glXGetProcAddressARB(func_name_ubyte);
+ }
+ return f;
+}
+
+"""
+
+ def printRealFooter(self):
+ print "} // Extern \"C\""
+
+ def printBody(self, api):
+ for func in api.functionIterateGlx():
+ for func_name in func.entry_points:
+ functionPrefix = ""
+ use_dlsym = True
+ if (api.get_category_for_name(func.name)[1] != None):
+ functionPrefix = "gltrace_"
+ use_dlsym = False
+
+ print '%s %sgl%s(%s) {' % (func.return_type, functionPrefix, func_name, func.get_parameter_string())
+ if (use_dlsym):
+ print ' static %s (*real_func)(%s) = 0;' % (func.return_type, func.get_parameter_string())
+ print ' if (!real_func) real_func = (%s (*)(%s)) dlsym(RTLD_NEXT, "gl%s");' % (func.return_type, func.get_parameter_string(), func_name)
+ else: # use glXGetProcAddressArb
+ print ' static %s (*real_func)(%s) = 0;' % (func.return_type, func.get_parameter_string())
+ print ' if (!real_func) real_func = (%s (*)(%s)) real_glXGetProcAddressARB((GLubyte *)"gl%s");' % (func.return_type, func.get_parameter_string(), func_name)
+ print ' ' + create_logfunc_string(func, func_name)
+ if (func.return_type == "void"):
+ print ' real_func(%s);' % (create_argument_string(func.parameters))
+ else:
+ print ' %s retval = real_func(%s);' % (func.return_type, create_argument_string(func.parameters))
+ if (func.name == "Begin"):
+ print ' betweenGLBeginEnd = true;'
+ elif (func.name == "End"):
+ print ' betweenGLBeginEnd = false;'
+ print ' if (!betweenGLBeginEnd && config.checkErrors) {'
+ print ' GLenum res;'
+ print ' while ((res = real_glGetError ()) != GL_NO_ERROR) '
+ print ' GLTRACE_LOG("OpenGL Error (" << res << "): <" << gluErrorString(res) << "> at " << gltrace::getStackTrace());'
+ print ' }'
+ if (func.return_type != "void"):
+ print " return retval;"
+ print '}'
+
+
+def show_usage():
+ print "Usage: %s [-f input_file_name] [-m output_mode] [-d]" % sys.argv[0]
+ print " -m output_mode Output mode can be one of 'proto', 'init_c' or 'init_h'."
+ print " -d Enable extra debug information in the generated code."
+ sys.exit(1)
+
+
+if __name__ == '__main__':
+ file_name = "gl_API.xml"
+
+ try:
+ (args, trail) = getopt.getopt(sys.argv[1:], "f:d")
+ except Exception,e:
+ show_usage()
+
+ debug = 0
+ for (arg,val) in args:
+ if arg == "-f":
+ file_name = val
+ elif arg == "-d":
+ debug = 1
+
+ printer = PrintGltrace()
+
+ printer.debug = debug
+ api = gl_XML.parse_GL_API( file_name, glX_XML.glx_item_factory() )
+
+ printer.Print( api )
diff --git a/progs/tools/trace/gltrace_support.cc b/progs/tools/trace/gltrace_support.cc
new file mode 100644
index 00000000000..fb0404c450e
--- /dev/null
+++ b/progs/tools/trace/gltrace_support.cc
@@ -0,0 +1,190 @@
+/*
+ * Copyright (C) 2006 Thomas Sondergaard 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 "gltrace_support.h"
+#include <sstream>
+#include <fstream>
+#include <iomanip>
+#include <execinfo.h>
+#include <cxxabi.h>
+#include <sys/time.h>
+
+namespace {
+
+ const char *
+ demangle (const char * mangled) throw()
+ {
+ static char buf[4096];
+ int status;
+ unsigned int length = sizeof(buf)-1;
+
+ memset (buf, 0, sizeof(buf));
+
+ if (!mangled)
+ return 0;
+
+ char * demangled = __cxxabiv1::__cxa_demangle(mangled,
+ buf,
+ &length,
+ &status);
+ if (demangled && !status)
+ return demangled;
+ else
+ return mangled;
+ }
+
+ void
+ printStackTrace (void **stackframes,
+ int stackframe_size,
+ std::ostream & out )
+ {
+ char **strings = 0;
+ std::stringstream ss;
+
+ // this might actually fail if memory is tight or we are in a
+ // signal handler
+ strings = backtrace_symbols (stackframes, stackframe_size);
+
+ ss << "Backtrace :";
+
+ if (stackframe_size == gltrace::MAX_STACKFRAMES)
+ ss << "(possibly incomplete maximal number of frames exceeded):" << std::endl;
+ else
+ ss << std::endl;
+
+ out << ss.str();
+
+ // the first frame is the constructor of the exception
+ // the last frame always seem to be bogus?
+ for (int i = 0; strings && i < stackframe_size-1; ++i) {
+ char libname[257], funcname[2049];
+ unsigned int address=0, funcoffset = 0x0;
+
+ memset (libname,0,sizeof(libname));
+ memset (funcname,0,sizeof(funcname));
+
+ strcpy (funcname,"??");
+ strcpy (libname, "??");
+
+ int scanned = sscanf (strings[i], "%256[^(] ( %2048[^+] + %x ) [ %x ]",
+ libname,
+ funcname,
+ &funcoffset,
+ &address);
+
+ /* ok, so no function was mentioned in the backtrace */
+ if (scanned < 4) {
+ scanned = sscanf (strings[i], "%256[^([] [ %x ]",
+ libname,
+ &address);
+ }
+
+ if (funcname[0] == '_') {
+ const char * demangled;
+ if ((demangled = demangle(funcname) ) != funcname) {
+ strncpy (funcname, demangled, sizeof(funcname)-1);
+ }
+ }
+ else
+ strcat (funcname," ()");
+
+ out << "\t#" << i << std::hex << " 0x" << address << " in " << funcname
+ << " at 0x" << funcoffset << " (from " << libname << ")" << std::endl;
+ }
+
+ free (strings);
+ }
+
+
+} // anon namespace
+
+namespace gltrace {
+
+ std::string getStackTrace(int count, int first) {
+ ++first;
+ std::stringstream ss;
+ const int BA_MAX = 1000;
+ assert(count + first <= BA_MAX);
+ void *ba[BA_MAX];
+ int n = backtrace(ba, count+first);
+
+ printStackTrace( &ba[first], n-first, ss);
+
+ return ss.str();
+ }
+
+ std::ostream &timeNow(std::ostream &os) {
+
+ struct timeval now;
+ struct tm t;
+ static char *months[12] =
+ {
+ "Jan", "Feb", "Mar", "Apr", "May", "Jun",
+ "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
+ };
+
+ gettimeofday (&now, 0);
+ localtime_r ((time_t*) &now.tv_sec, &t);
+
+ os
+ << months[t.tm_mon] << " "
+ << std::setw(2) << t.tm_mday << " "
+ << std::setw(2) << t.tm_hour << ":"
+ << std::setw(2) << t.tm_min << ":"
+ << std::setw(2) << t.tm_sec << "."
+ << std::setw(3) << now.tv_usec/1000;
+ return os;
+ }
+
+ logstream::logstream(const char *filename) {
+ if (!filename)
+ init(std::cerr.rdbuf());
+ else {
+ file_os.reset(new std::ofstream(filename));
+ if (file_os->good())
+ init(file_os->rdbuf());
+ else {
+ std::cerr << "ERROR: gltrace: Failed to open '" << filename
+ << "' for writing. Falling back to stderr." << std::endl;
+ init(std::cerr.rdbuf());
+ }
+ }
+ *this << std::setfill('0'); // setw used in timeNow
+ }
+
+
+ Config::Config() :
+ logCalls(true),
+ checkErrors(true),
+ logTime(true),
+ log(getenv("GLTRACE_LOGFILE")) {
+ if (const char *v = getenv("GLTRACE_LOG_CALLS"))
+ logCalls = strncmp("1", v, 1) == 0;
+ if (const char *v = getenv("GLTRACE_CHECK_ERRORS"))
+ checkErrors = strncmp("1", v, 1) == 0;
+ if (const char *v = getenv("GLTRACE_LOG_TIME"))
+ logTime = strncmp("1", v, 1) == 0;
+ }
+
+ // *The* config
+ Config config;
+
+} // namespace gltrace
diff --git a/progs/tools/trace/gltrace_support.h b/progs/tools/trace/gltrace_support.h
new file mode 100644
index 00000000000..de28669a989
--- /dev/null
+++ b/progs/tools/trace/gltrace_support.h
@@ -0,0 +1,65 @@
+// -*- c++ -*- (emacs c++ mode)
+/*
+ * Copyright (C) 2006 Thomas Sondergaard 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.
+ */
+#ifndef GLTRACE_SUPPORT_H
+#define GLTRACE_SUPPORT_H
+
+#include <string>
+#include <iostream>
+#include <memory>
+
+namespace gltrace {
+
+ const int MAX_STACKFRAMES = 100;
+
+ /// Returns the stack trace of the current thread
+ std::string getStackTrace(int count = MAX_STACKFRAMES, int first = 0);
+
+ std::ostream &timeNow(std::ostream &os);
+
+ struct logstream : public std::ostream {
+
+ /// Opens a logstream - if filename is null, stderr will be used
+ logstream(const char *filename = 0);
+
+ private:
+ std::auto_ptr<std::ofstream> file_os;
+ };
+
+ struct Config {
+ bool logCalls;
+ bool checkErrors;
+ bool logTime;
+ logstream log;
+
+ Config();
+ };
+
+ extern Config config;
+
+} // namespace gltrace
+
+#define GLTRACE_LOG(x) \
+ { if (config.logTime) config.log << timeNow << ": "; config.log << x << "\n"; }
+
+#endif // GLTRACE_SUPPORT_H
+
+
diff --git a/progs/trivial/Makefile b/progs/trivial/Makefile
new file mode 100644
index 00000000000..b9ed5c70dc5
--- /dev/null
+++ b/progs/trivial/Makefile
@@ -0,0 +1,136 @@
+# 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 = \
+ clear.c \
+ line-clip.c \
+ line-cull.c \
+ line-userclip-clip.c \
+ line-userclip-nop-clip.c \
+ line-userclip-nop.c \
+ line-userclip.c \
+ line.c \
+ lineloop-clip.c \
+ lineloop.c \
+ point.c \
+ point-clip.c \
+ point-param.c \
+ point-wide.c \
+ poly-flat.c \
+ poly-unfilled.c \
+ poly.c \
+ quad-clip.c \
+ quad-clip-all-vertices.c \
+ quad-clip-nearplane.c \
+ quad-degenerate.c \
+ quad-flat.c \
+ quad-offset-factor.c \
+ quad-offset-units.c \
+ quad-offset-unfilled.c \
+ quad-unfilled.c \
+ quad-tex-2d.c \
+ quad-tex-pbo.c \
+ quad-tex-3d.c \
+ quad-tex-dep.c \
+ quad.c \
+ quads.c \
+ quadstrip.c \
+ quadstrip-flat.c \
+ tri-blend.c \
+ tri-tex-3d.c \
+ tri-clip.c \
+ tri-cull.c \
+ tri-edgeflag.c \
+ tri-flat-clip.c \
+ tri-flat.c \
+ tri-unfilled-clip.c \
+ tri-unfilled-smooth.c \
+ tri-unfilled-userclip.c \
+ tri-unfilled.c \
+ tri-userclip.c \
+ tri-dlist.c \
+ tri.c \
+ tristrip-clip.c \
+ tristrip.c \
+ vp-clip.c \
+ vp-tri.c \
+ vp-line-clip.c \
+ vp-unfilled.c \
+ vp-array.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/trivial/clear.c b/progs/trivial/clear.c
new file mode 100644
index 00000000000..7e7ca588c31
--- /dev/null
+++ b/progs/trivial/clear.c
@@ -0,0 +1,126 @@
+/*
+ * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the name of
+ * Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
+ * ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+
+#define CI_OFFSET_1 16
+#define CI_OFFSET_2 32
+
+
+GLenum doubleBuffer;
+
+static void Init(void)
+{
+ fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+ fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
+ fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
+
+ glClearColor(0.0, 0.0, 1.0, 0.0);
+}
+
+static void Reshape(int width, int height)
+{
+
+ glViewport(0, 0, (GLint)width, (GLint)height);
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
+ glMatrixMode(GL_MODELVIEW);
+}
+
+static void Key(unsigned char key, int x, int y)
+{
+
+ switch (key) {
+ case 27:
+ exit(1);
+ default:
+ return;
+ }
+
+ glutPostRedisplay();
+}
+
+static void Draw(void)
+{
+ glClear(GL_COLOR_BUFFER_BIT);
+ glFlush();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ fprintf(stderr, "%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ GLenum type;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : 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/trivial/line-clip.c b/progs/trivial/line-clip.c
new file mode 100644
index 00000000000..9acd12acc7b
--- /dev/null
+++ b/progs/trivial/line-clip.c
@@ -0,0 +1,140 @@
+/*
+ * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the name of
+ * Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
+ * ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+
+#define CI_OFFSET_1 16
+#define CI_OFFSET_2 32
+
+
+GLenum doubleBuffer;
+
+static void Init(void)
+{
+ fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+ fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
+ fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
+
+ glClearColor(0.0, 0.0, 1.0, 0.0);
+}
+
+static void Reshape(int width, int height)
+{
+
+ glViewport(0, 0, (GLint)width, (GLint)height);
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
+ glMatrixMode(GL_MODELVIEW);
+}
+
+static void Key(unsigned char key, int x, int y)
+{
+
+ switch (key) {
+ case 27:
+ exit(1);
+ default:
+ return;
+ }
+
+ glutPostRedisplay();
+}
+
+static void Draw(void)
+{
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ glBegin(GL_LINE_STRIP);
+ glColor3f(0,0,.7);
+ glVertex3f( 0.9, -0.9, -30.0);
+ glColor3f(.8,0,0);
+ glVertex3f( 0.9, 0.9, -30.0);
+ glColor3f(0,.9,0);
+ glVertex3f(-1.9, 0.0, -30.0);
+ /* Repeat - no loop support yet:
+ */
+ glColor3f(0,0,.7);
+ glVertex3f( 0.9, -0.9, -30.0);
+ glEnd();
+
+ glFlush();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ fprintf(stderr, "%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ GLenum type;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : 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/trivial/line-cull.c b/progs/trivial/line-cull.c
new file mode 100644
index 00000000000..8999a8f0b1c
--- /dev/null
+++ b/progs/trivial/line-cull.c
@@ -0,0 +1,136 @@
+/*
+ * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the name of
+ * Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
+ * ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+
+#define CI_OFFSET_1 16
+#define CI_OFFSET_2 32
+
+
+GLenum doubleBuffer;
+
+static void Init(void)
+{
+ fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+ fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
+ fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
+
+ glClearColor(0.0, 0.0, 1.0, 0.0);
+}
+
+static void Reshape(int width, int height)
+{
+
+ glViewport(0, 0, (GLint)width, (GLint)height);
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
+ glMatrixMode(GL_MODELVIEW);
+}
+
+static void Key(unsigned char key, int x, int y)
+{
+
+ switch (key) {
+ case 27:
+ exit(1);
+ default:
+ return;
+ }
+
+ glutPostRedisplay();
+}
+
+static void Draw(void)
+{
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ glBegin(GL_LINE_STRIP);
+ glColor3f(0,0,1);
+ glVertex3f( -1.5, 0.5, -30.0);
+ glColor3f(1,0,0);
+ glVertex3f( 0, 2.0, -30.0);
+ glColor3f(0,1,0);
+ glVertex3f(-1.5, 2.0, -30.0);
+ glEnd();
+
+ glFlush();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ fprintf(stderr, "%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ GLenum type;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : 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/trivial/line-userclip-clip.c b/progs/trivial/line-userclip-clip.c
new file mode 100644
index 00000000000..b24d8452bcd
--- /dev/null
+++ b/progs/trivial/line-userclip-clip.c
@@ -0,0 +1,142 @@
+/*
+ * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the name of
+ * Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
+ * ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+
+#define CI_OFFSET_1 16
+#define CI_OFFSET_2 32
+
+
+GLenum doubleBuffer;
+
+static void Init(void)
+{
+ static GLdouble plane[4] = { -.5, 0, 1, 0 };
+
+ fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+ fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
+ fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
+
+ glClearColor(0.0, 0.0, 1.0, 0.0);
+ glClipPlane(GL_CLIP_PLANE0, plane);
+ glEnable(GL_CLIP_PLANE0);
+}
+
+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_LINE_STRIP);
+ glColor3f(0,0,.7);
+ glVertex3f( 0.9, -0.9, 0.0);
+ glColor3f(.8,0,0);
+ glVertex3f( 0.9, 0.9, 0.0);
+ glColor3f(0,.9,0);
+ glVertex3f(-1.9, 0.0, 0.0);
+ glColor3f(0,0,.7);
+ glVertex3f( 0.9, -0.9, 0.0);
+ glEnd();
+
+ glFlush();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ fprintf(stderr, "%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ GLenum type;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : 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/trivial/line-userclip-nop-clip.c b/progs/trivial/line-userclip-nop-clip.c
new file mode 100644
index 00000000000..e2e0b85a522
--- /dev/null
+++ b/progs/trivial/line-userclip-nop-clip.c
@@ -0,0 +1,142 @@
+/*
+ * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the name of
+ * Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
+ * ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+
+#define CI_OFFSET_1 16
+#define CI_OFFSET_2 32
+
+
+GLenum doubleBuffer;
+
+static void Init(void)
+{
+ static GLdouble plane[4] = { 0, 0, 1, 0 };
+
+ fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+ fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
+ fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
+
+ glClearColor(0.0, 0.0, 1.0, 0.0);
+ glClipPlane(GL_CLIP_PLANE0, plane);
+ glEnable(GL_CLIP_PLANE0);
+}
+
+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_LINE_STRIP);
+ glColor3f(0,0,.7);
+ glVertex3f( 0.9, -0.9, 0.0);
+ glColor3f(.8,0,0);
+ glVertex3f( 0.9, 0.9, 0.0);
+ glColor3f(0,.9,0);
+ glVertex3f(-1.9, 0.0, 0.0);
+ glColor3f(0,0,.7);
+ glVertex3f( 0.9, -0.9, 0.0);
+ glEnd();
+
+ glFlush();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ fprintf(stderr, "%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ GLenum type;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : 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/trivial/line-userclip-nop.c b/progs/trivial/line-userclip-nop.c
new file mode 100644
index 00000000000..eacee069789
--- /dev/null
+++ b/progs/trivial/line-userclip-nop.c
@@ -0,0 +1,142 @@
+/*
+ * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the name of
+ * Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
+ * ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+
+#define CI_OFFSET_1 16
+#define CI_OFFSET_2 32
+
+
+GLenum doubleBuffer;
+
+static void Init(void)
+{
+ static GLdouble plane[4] = { 0, 0, 1, 0 };
+
+ fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+ fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
+ fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
+
+ glClearColor(0.0, 0.0, 1.0, 0.0);
+ glClipPlane(GL_CLIP_PLANE0, plane);
+ glEnable(GL_CLIP_PLANE0);
+}
+
+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_LINE_STRIP);
+ glColor3f(0,0,.7);
+ glVertex3f( 0.9, -0.9, 0.0);
+ glColor3f(.8,0,0);
+ glVertex3f( 0.9, 0.9, 0.0);
+ glColor3f(0,.9,0);
+ glVertex3f(-0.9, 0.0, 0.0);
+ glColor3f(0,0,.7);
+ glVertex3f( 0.9, -0.9, 0.0);
+ glEnd();
+
+ glFlush();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ fprintf(stderr, "%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ GLenum type;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : 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/trivial/line-userclip.c b/progs/trivial/line-userclip.c
new file mode 100644
index 00000000000..6af91431d08
--- /dev/null
+++ b/progs/trivial/line-userclip.c
@@ -0,0 +1,142 @@
+/*
+ * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the name of
+ * Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
+ * ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+
+#define CI_OFFSET_1 16
+#define CI_OFFSET_2 32
+
+
+GLenum doubleBuffer;
+
+static void Init(void)
+{
+ static GLdouble plane[4] = { -.5, 0, 1, 0 };
+
+ fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+ fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
+ fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
+
+ glClearColor(0.0, 0.0, 1.0, 0.0);
+ glClipPlane(GL_CLIP_PLANE0, plane);
+ glEnable(GL_CLIP_PLANE0);
+}
+
+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_LINE_STRIP);
+ glColor3f(0,0,.7);
+ glVertex3f( 0.9, -0.9, 0.0);
+ glColor3f(.8,0,0);
+ glVertex3f( 0.9, 0.9, 0.0);
+ glColor3f(0,.9,0);
+ glVertex3f(-0.9, 0.0, 0.0);
+ glColor3f(0,0,.7);
+ glVertex3f( 0.9, -0.9, 0.0);
+ glEnd();
+
+ glFlush();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ fprintf(stderr, "%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ GLenum type;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : 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/trivial/line.c b/progs/trivial/line.c
new file mode 100644
index 00000000000..58bad91b05a
--- /dev/null
+++ b/progs/trivial/line.c
@@ -0,0 +1,140 @@
+/*
+ * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the name of
+ * Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
+ * ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+
+#define CI_OFFSET_1 16
+#define CI_OFFSET_2 32
+
+
+GLenum doubleBuffer;
+
+static void Init(void)
+{
+ fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+ fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
+ fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
+
+ glClearColor(0.0, 0.0, 1.0, 0.0);
+}
+
+static void Reshape(int width, int height)
+{
+
+ glViewport(0, 0, (GLint)width, (GLint)height);
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
+ glMatrixMode(GL_MODELVIEW);
+}
+
+static void Key(unsigned char key, int x, int y)
+{
+
+ switch (key) {
+ case 27:
+ exit(1);
+ default:
+ return;
+ }
+
+ glutPostRedisplay();
+}
+
+static void Draw(void)
+{
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ glBegin(GL_LINE_STRIP);
+ glColor3f(0,0,.7);
+ glVertex3f( 0.9, -0.9, -30.0);
+ glColor3f(.8,0,0);
+ glVertex3f( 0.9, 0.9, -30.0);
+ glColor3f(0,.9,0);
+ glVertex3f(-0.9, 0.0, -30.0);
+ /* Repeat the first vertex - don't have lineloop support in GS yet
+ */
+ glColor3f(0,0,.7);
+ glVertex3f( 0.9, -0.9, -30.0);
+ glEnd();
+
+ glFlush();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ fprintf(stderr, "%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ GLenum type;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : 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/trivial/lineloop-clip.c b/progs/trivial/lineloop-clip.c
new file mode 100644
index 00000000000..d8645ee3477
--- /dev/null
+++ b/progs/trivial/lineloop-clip.c
@@ -0,0 +1,136 @@
+/*
+ * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the name of
+ * Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
+ * ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+
+#define CI_OFFSET_1 16
+#define CI_OFFSET_2 32
+
+
+GLenum doubleBuffer;
+
+static void Init(void)
+{
+ fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+ fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
+ fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
+
+ glClearColor(0.0, 0.0, 1.0, 0.0);
+}
+
+static void Reshape(int width, int height)
+{
+
+ glViewport(0, 0, (GLint)width, (GLint)height);
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
+ glMatrixMode(GL_MODELVIEW);
+}
+
+static void Key(unsigned char key, int x, int y)
+{
+
+ switch (key) {
+ case 27:
+ exit(1);
+ default:
+ return;
+ }
+
+ glutPostRedisplay();
+}
+
+static void Draw(void)
+{
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ glBegin(GL_LINE_LOOP);
+ glColor3f(0,0,.7);
+ glVertex3f( 0.9, -0.9, -30.0);
+ glColor3f(.8,0,0);
+ glVertex3f( 0.9, 0.9, -30.0);
+ glColor3f(0,.9,0);
+ glVertex3f(-1.9, 0.0, -30.0);
+ glEnd();
+
+ glFlush();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ fprintf(stderr, "%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ GLenum type;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : 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/trivial/lineloop.c b/progs/trivial/lineloop.c
new file mode 100644
index 00000000000..7500c54fc26
--- /dev/null
+++ b/progs/trivial/lineloop.c
@@ -0,0 +1,136 @@
+/*
+ * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the name of
+ * Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
+ * ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+
+#define CI_OFFSET_1 16
+#define CI_OFFSET_2 32
+
+
+GLenum doubleBuffer;
+
+static void Init(void)
+{
+ fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+ fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
+ fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
+
+ glClearColor(0.0, 0.0, 1.0, 0.0);
+}
+
+static void Reshape(int width, int height)
+{
+
+ glViewport(0, 0, (GLint)width, (GLint)height);
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
+ glMatrixMode(GL_MODELVIEW);
+}
+
+static void Key(unsigned char key, int x, int y)
+{
+
+ switch (key) {
+ case 27:
+ exit(1);
+ default:
+ return;
+ }
+
+ glutPostRedisplay();
+}
+
+static void Draw(void)
+{
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ glBegin(GL_LINE_LOOP);
+ glColor3f(0,0,.7);
+ glVertex3f( 0.9, -0.9, -30.0);
+ glColor3f(.8,0,0);
+ glVertex3f( 0.9, 0.9, -30.0);
+ glColor3f(0,.9,0);
+ glVertex3f(-0.9, 0.0, -30.0);
+ glEnd();
+
+ glFlush();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ fprintf(stderr, "%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ GLenum type;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : 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/trivial/point-clip.c b/progs/trivial/point-clip.c
new file mode 100644
index 00000000000..32792047c64
--- /dev/null
+++ b/progs/trivial/point-clip.c
@@ -0,0 +1,138 @@
+/*
+ * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the name of
+ * Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
+ * ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+
+#define CI_OFFSET_1 16
+#define CI_OFFSET_2 32
+
+
+GLenum doubleBuffer;
+
+static void Init(void)
+{
+ fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+ fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
+ fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
+
+ glClearColor(0.0, 0.0, 1.0, 0.0);
+}
+
+static void Reshape(int width, int height)
+{
+
+ glViewport(0, 0, (GLint)width, (GLint)height);
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
+ glMatrixMode(GL_MODELVIEW);
+}
+
+static void Key(unsigned char key, int x, int y)
+{
+
+ switch (key) {
+ case 27:
+ exit(1);
+ default:
+ return;
+ }
+
+ glutPostRedisplay();
+}
+
+static void Draw(void)
+{
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ glBegin(GL_POINTS);
+ glColor3f(1,0,0);
+ glVertex3f( 0.9, -0.9, -30.0);
+ glColor3f(1,1,0);
+ glVertex3f( 0.9, 0.9, -30.0);
+ glColor3f(1,0,1);
+ glVertex3f(-1.9, 0.9, -30.0);
+ glColor3f(0,1,1);
+ glVertex3f(-0.9, -0.9, -30.0);
+ glEnd();
+
+ glFlush();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ fprintf(stderr, "%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ GLenum type;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : 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/trivial/point-param.c b/progs/trivial/point-param.c
new file mode 100644
index 00000000000..c5424682b85
--- /dev/null
+++ b/progs/trivial/point-param.c
@@ -0,0 +1,145 @@
+/*
+ * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the name of
+ * Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
+ * ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+
+#define CI_OFFSET_1 16
+#define CI_OFFSET_2 32
+
+
+GLenum doubleBuffer;
+
+static void Init(void)
+{
+ fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+ fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
+ fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
+
+ glClearColor(0.0, 0.0, 1.0, 0.0);
+}
+
+static void Reshape(int width, int height)
+{
+
+ glViewport(0, 0, (GLint)width, (GLint)height);
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
+ glMatrixMode(GL_MODELVIEW);
+}
+
+static void Key(unsigned char key, int x, int y)
+{
+
+ switch (key) {
+ case 27:
+ exit(1);
+ default:
+ return;
+ }
+
+ glutPostRedisplay();
+}
+
+static void Draw(void)
+{
+ static GLfloat theQuad[3] = { 0.25, 0.0, 1/60.0 };
+
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glPointSize(8.0);
+ glPointParameterfvARB(GL_POINT_DISTANCE_ATTENUATION_ARB, theQuad);
+
+
+ glBegin(GL_POINTS);
+ glColor3f(1,0,0);
+ glVertex3f( 0.9, -0.9, -30.0);
+ glColor3f(1,1,0);
+ glVertex3f( 0.9, 0.9, -30.0);
+ glColor3f(1,0,1);
+ glVertex3f(-0.9, 0.9, -30.0);
+ glColor3f(0,1,1);
+ glVertex3f(-0.9, -0.9, -30.0);
+ glEnd();
+
+ glFlush();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ fprintf(stderr, "%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ GLenum type;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : 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/trivial/point-wide.c b/progs/trivial/point-wide.c
new file mode 100644
index 00000000000..473ca043f1d
--- /dev/null
+++ b/progs/trivial/point-wide.c
@@ -0,0 +1,140 @@
+/*
+ * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the name of
+ * Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
+ * ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+
+#define CI_OFFSET_1 16
+#define CI_OFFSET_2 32
+
+
+GLenum doubleBuffer;
+
+static void Init(void)
+{
+ fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+ fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
+ fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
+
+ glClearColor(0.0, 0.0, 1.0, 0.0);
+}
+
+static void Reshape(int width, int height)
+{
+
+ glViewport(0, 0, (GLint)width, (GLint)height);
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
+ glMatrixMode(GL_MODELVIEW);
+}
+
+static void Key(unsigned char key, int x, int y)
+{
+
+ switch (key) {
+ case 27:
+ exit(1);
+ default:
+ return;
+ }
+
+ glutPostRedisplay();
+}
+
+static void Draw(void)
+{
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ glPointSize(8.0);
+
+ glBegin(GL_POINTS);
+ glColor3f(1,0,0);
+ glVertex3f( 0.9, -0.9, -30.0);
+ glColor3f(1,1,0);
+ glVertex3f( 0.9, 0.9, -30.0);
+ glColor3f(1,0,1);
+ glVertex3f(-0.9, 0.9, -30.0);
+ glColor3f(0,1,1);
+ glVertex3f(-0.9, -0.9, -30.0);
+ glEnd();
+
+ glFlush();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ fprintf(stderr, "%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ GLenum type;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : 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/trivial/point.c b/progs/trivial/point.c
new file mode 100644
index 00000000000..87465bfb2c1
--- /dev/null
+++ b/progs/trivial/point.c
@@ -0,0 +1,138 @@
+/*
+ * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the name of
+ * Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
+ * ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+
+#define CI_OFFSET_1 16
+#define CI_OFFSET_2 32
+
+
+GLenum doubleBuffer;
+
+static void Init(void)
+{
+ fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+ fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
+ fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
+
+ glClearColor(0.0, 0.0, 1.0, 0.0);
+}
+
+static void Reshape(int width, int height)
+{
+
+ glViewport(0, 0, (GLint)width, (GLint)height);
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
+ glMatrixMode(GL_MODELVIEW);
+}
+
+static void Key(unsigned char key, int x, int y)
+{
+
+ switch (key) {
+ case 27:
+ exit(1);
+ default:
+ return;
+ }
+
+ glutPostRedisplay();
+}
+
+static void Draw(void)
+{
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ glBegin(GL_POINTS);
+ glColor3f(1,0,0);
+ glVertex3f( 0.9, -0.9, -30.0);
+ glColor3f(1,1,0);
+ glVertex3f( 0.9, 0.9, -30.0);
+ glColor3f(1,0,1);
+ glVertex3f(-0.9, 0.9, -30.0);
+ glColor3f(0,1,1);
+ glVertex3f(-0.9, -0.9, -30.0);
+ glEnd();
+
+ glFlush();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ fprintf(stderr, "%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ GLenum type;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : 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/trivial/poly-flat.c b/progs/trivial/poly-flat.c
new file mode 100644
index 00000000000..747b24dc0ce
--- /dev/null
+++ b/progs/trivial/poly-flat.c
@@ -0,0 +1,140 @@
+/*
+ * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the name of
+ * Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
+ * ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+
+#define CI_OFFSET_1 16
+#define CI_OFFSET_2 32
+
+
+GLenum doubleBuffer;
+
+static void Init(void)
+{
+ fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+ fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
+ fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
+
+ glClearColor(0.0, 0.0, 1.0, 0.0);
+}
+
+static void Reshape(int width, int height)
+{
+
+ glViewport(0, 0, (GLint)width, (GLint)height);
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
+ glMatrixMode(GL_MODELVIEW);
+}
+
+static void Key(unsigned char key, int x, int y)
+{
+
+ switch (key) {
+ case 27:
+ exit(1);
+ default:
+ return;
+ }
+
+ glutPostRedisplay();
+}
+
+static void Draw(void)
+{
+ glClear(GL_COLOR_BUFFER_BIT);
+ glShadeModel(GL_FLAT);
+
+
+ glBegin(GL_POLYGON);
+ glColor3f(1,0,0);
+ glVertex3f( 0.9, -0.9, -30.0);
+ glColor3f(1,1,0);
+ glVertex3f( 0.9, 0.9, -30.0);
+ glColor3f(1,0,1);
+ glVertex3f(-0.9, 0.9, -30.0);
+ glColor3f(0,1,1);
+ glVertex3f(-0.9, -0.9, -30.0);
+ glEnd();
+
+ glFlush();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ fprintf(stderr, "%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ GLenum type;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : 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/trivial/poly-unfilled.c b/progs/trivial/poly-unfilled.c
new file mode 100644
index 00000000000..e0ae463b083
--- /dev/null
+++ b/progs/trivial/poly-unfilled.c
@@ -0,0 +1,139 @@
+/*
+ * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the name of
+ * Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
+ * ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+
+#define CI_OFFSET_1 16
+#define CI_OFFSET_2 32
+
+
+GLenum doubleBuffer;
+
+static void Init(void)
+{
+ fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+ fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
+ fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
+
+ glClearColor(0.0, 0.0, 1.0, 0.0);
+}
+
+static void Reshape(int width, int height)
+{
+
+ glViewport(0, 0, (GLint)width, (GLint)height);
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
+ glMatrixMode(GL_MODELVIEW);
+}
+
+static void Key(unsigned char key, int x, int y)
+{
+
+ switch (key) {
+ case 27:
+ exit(1);
+ default:
+ return;
+ }
+
+ glutPostRedisplay();
+}
+
+static void Draw(void)
+{
+ glClear(GL_COLOR_BUFFER_BIT);
+ glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
+
+ glBegin(GL_POLYGON);
+ glColor3f(1,0,0);
+ glVertex3f( 0.9, -0.9, -30.0);
+ glColor3f(1,1,0);
+ glVertex3f( 0.9, 0.9, -30.0);
+ glColor3f(1,0,1);
+ glVertex3f(-0.9, 0.9, -30.0);
+ glColor3f(0,1,1);
+ glVertex3f(-0.9, -0.9, -30.0);
+ glEnd();
+
+ glFlush();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ fprintf(stderr, "%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ GLenum type;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : 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/trivial/poly.c b/progs/trivial/poly.c
new file mode 100644
index 00000000000..bdb9e27aa91
--- /dev/null
+++ b/progs/trivial/poly.c
@@ -0,0 +1,138 @@
+/*
+ * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the name of
+ * Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
+ * ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+
+#define CI_OFFSET_1 16
+#define CI_OFFSET_2 32
+
+
+GLenum doubleBuffer;
+
+static void Init(void)
+{
+ fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+ fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
+ fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
+
+ glClearColor(0.0, 0.0, 1.0, 0.0);
+}
+
+static void Reshape(int width, int height)
+{
+
+ glViewport(0, 0, (GLint)width, (GLint)height);
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
+ glMatrixMode(GL_MODELVIEW);
+}
+
+static void Key(unsigned char key, int x, int y)
+{
+
+ switch (key) {
+ case 27:
+ exit(1);
+ default:
+ return;
+ }
+
+ glutPostRedisplay();
+}
+
+static void Draw(void)
+{
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ glBegin(GL_POLYGON);
+ glColor3f(1,0,0);
+ glVertex3f( 0.9, -0.9, -30.0);
+ glColor3f(1,1,0);
+ glVertex3f( 0.9, 0.9, -30.0);
+ glColor3f(1,0,1);
+ glVertex3f(-0.9, 0.9, -30.0);
+ glColor3f(0,1,1);
+ glVertex3f(-0.9, -0.9, -30.0);
+ glEnd();
+
+ glFlush();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ fprintf(stderr, "%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ GLenum type;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : 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/trivial/quad-clip-all-vertices.c b/progs/trivial/quad-clip-all-vertices.c
new file mode 100644
index 00000000000..019ef0c479a
--- /dev/null
+++ b/progs/trivial/quad-clip-all-vertices.c
@@ -0,0 +1,138 @@
+/*
+ * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the name of
+ * Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
+ * ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+
+#define CI_OFFSET_1 16
+#define CI_OFFSET_2 32
+
+
+GLenum doubleBuffer;
+
+static void Init(void)
+{
+ fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+ fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
+ fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
+
+ glClearColor(0.0, 0.0, 1.0, 0.0);
+}
+
+static void Reshape(int width, int height)
+{
+
+ glViewport(0, 0, (GLint)width, (GLint)height);
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
+ glMatrixMode(GL_MODELVIEW);
+}
+
+static void Key(unsigned char key, int x, int y)
+{
+
+ switch (key) {
+ case 27:
+ exit(1);
+ default:
+ return;
+ }
+
+ glutPostRedisplay();
+}
+
+static void Draw(void)
+{
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ glBegin(GL_QUADS);
+ glColor3f(1,0,0);
+ glVertex3f( 1.9, -1.9, -30.0);
+ glColor3f(1,1,0);
+ glVertex3f( 1.9, 1.9, -30.0);
+ glColor3f(1,0,1);
+ glVertex3f(-1.9, 1.9, -30.0);
+ glColor3f(0,1,1);
+ glVertex3f(-1.9, -1.9, -30.0);
+ glEnd();
+
+ glFlush();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ fprintf(stderr, "%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ GLenum type;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : 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/trivial/quad-clip-nearplane.c b/progs/trivial/quad-clip-nearplane.c
new file mode 100644
index 00000000000..7e12e58a196
--- /dev/null
+++ b/progs/trivial/quad-clip-nearplane.c
@@ -0,0 +1,138 @@
+/*
+ * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the name of
+ * Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
+ * ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+
+#define CI_OFFSET_1 16
+#define CI_OFFSET_2 32
+
+
+GLenum doubleBuffer;
+
+static void Init(void)
+{
+ fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+ fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
+ fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
+
+ glClearColor(0.0, 0.0, 1.0, 0.0);
+}
+
+static void Reshape(int width, int height)
+{
+
+ glViewport(0, 0, (GLint)width, (GLint)height);
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
+ glMatrixMode(GL_MODELVIEW);
+}
+
+static void Key(unsigned char key, int x, int y)
+{
+
+ switch (key) {
+ case 27:
+ exit(1);
+ default:
+ return;
+ }
+
+ glutPostRedisplay();
+}
+
+static void Draw(void)
+{
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ glBegin(GL_QUADS);
+ glColor3f(1,0,0);
+ glVertex3f( 0.9, -0.9, 30.0);
+ glColor3f(1,1,0);
+ glVertex3f( 0.9, 0.9, 30.0);
+ glColor3f(1,0,1);
+ glVertex3f(-1.9, 0.9, 30.0);
+ glColor3f(0,1,1);
+ glVertex3f(-1.9, -0.9, -30.0);
+ glEnd();
+
+ glFlush();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ fprintf(stderr, "%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ GLenum type;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : 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/trivial/quad-clip.c b/progs/trivial/quad-clip.c
new file mode 100644
index 00000000000..9f3a45caec3
--- /dev/null
+++ b/progs/trivial/quad-clip.c
@@ -0,0 +1,138 @@
+/*
+ * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the name of
+ * Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
+ * ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+
+#define CI_OFFSET_1 16
+#define CI_OFFSET_2 32
+
+
+GLenum doubleBuffer;
+
+static void Init(void)
+{
+ fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+ fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
+ fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
+
+ glClearColor(0.0, 0.0, 1.0, 0.0);
+}
+
+static void Reshape(int width, int height)
+{
+
+ glViewport(0, 0, (GLint)width, (GLint)height);
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
+ glMatrixMode(GL_MODELVIEW);
+}
+
+static void Key(unsigned char key, int x, int y)
+{
+
+ switch (key) {
+ case 27:
+ exit(1);
+ default:
+ return;
+ }
+
+ glutPostRedisplay();
+}
+
+static void Draw(void)
+{
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ glBegin(GL_QUADS);
+ glColor3f(1,0,0);
+ glVertex3f( 0.9, -0.9, -30.0);
+ glColor3f(1,1,0);
+ glVertex3f( 0.9, 0.9, -30.0);
+ glColor3f(1,0,1);
+ glVertex3f(-1.9, 0.9, -30.0);
+ glColor3f(0,1,1);
+ glVertex3f(-0.9, -0.9, -30.0);
+ glEnd();
+
+ glFlush();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ fprintf(stderr, "%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ GLenum type;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : 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/trivial/quad-degenerate.c b/progs/trivial/quad-degenerate.c
new file mode 100644
index 00000000000..b14b0f1d879
--- /dev/null
+++ b/progs/trivial/quad-degenerate.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 <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+
+#define CI_OFFSET_1 16
+#define CI_OFFSET_2 32
+
+
+GLenum doubleBuffer;
+
+static void Init(void)
+{
+ fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+ fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
+ fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
+
+ glClearColor(0.0, 0.0, 1.0, 0.0);
+}
+
+static void Reshape(int width, int height)
+{
+
+ glViewport(0, 0, (GLint)width, (GLint)height);
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
+ glMatrixMode(GL_MODELVIEW);
+}
+
+static void Key(unsigned char key, int x, int y)
+{
+
+ switch (key) {
+ case 27:
+ exit(1);
+ default:
+ return;
+ }
+
+ glutPostRedisplay();
+}
+
+static void Draw(void)
+{
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ glBegin(GL_QUADS);
+ glColor3f(1,0,0);
+ glVertex3f( 0.9, -0.9, -30.0);
+ glColor3f(1,1,0);
+ glVertex3f( 0.9, 0.9, -30.0);
+ glColor3f(1,0,1);
+ glVertex3f(-0.9, 0.9, -30.0);
+ glColor3f(0,1,1);
+ glVertex3f(-0.9, -0.9, -30.0);
+ glColor3f(1,0,0);
+ glVertex3f( 0.9, -0.9, -30.0);
+ glColor3f(1,1,0);
+ glVertex3f( 0.9, 0.9, -30.0);
+ glColor3f(1,0,1);
+ glEnd();
+
+ glFlush();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ fprintf(stderr, "%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ GLenum type;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : 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/trivial/quad-flat.c b/progs/trivial/quad-flat.c
new file mode 100644
index 00000000000..d6e9f021206
--- /dev/null
+++ b/progs/trivial/quad-flat.c
@@ -0,0 +1,148 @@
+/*
+ * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the name of
+ * Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
+ * ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+
+#define CI_OFFSET_1 16
+#define CI_OFFSET_2 32
+
+
+GLenum doubleBuffer;
+
+static void Init(void)
+{
+ fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+ fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
+ fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
+
+ glClearColor(0.0, 0.0, 1.0, 0.0);
+}
+
+static void Reshape(int width, int height)
+{
+
+ glViewport(0, 0, (GLint)width, (GLint)height);
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
+ glMatrixMode(GL_MODELVIEW);
+}
+
+static void Key(unsigned char key, int x, int y)
+{
+
+ switch (key) {
+ case 27:
+ exit(1);
+ default:
+ return;
+ }
+
+ glutPostRedisplay();
+}
+
+static void Draw(void)
+{
+ glClear(GL_COLOR_BUFFER_BIT);
+ glShadeModel(GL_FLAT);
+
+ if (1) {
+ glBegin(GL_LINES);
+ glColor3f(1,0,0);
+ glVertex3f( 0.95, -0.9, -30.0);
+ glColor3f(1,1,0);
+ glVertex3f( 0.95, 0.9, -30.0);
+ glEnd();
+ }
+
+ glBegin(GL_QUADS);
+ glColor3f(1,0,0);
+ glVertex3f( 0.9, -0.9, -30.0);
+ glColor3f(1,1,0);
+ glVertex3f( 0.9, 0.9, -30.0);
+ glColor3f(1,0,1);
+ glVertex3f(-0.9, 0.9, -30.0);
+ glColor3f(0,1,1);
+ glVertex3f(-0.9, -0.9, -30.0);
+ glEnd();
+
+ glFlush();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ fprintf(stderr, "%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ GLenum type;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : 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/trivial/quad-offset-factor.c b/progs/trivial/quad-offset-factor.c
new file mode 100644
index 00000000000..861d3461c04
--- /dev/null
+++ b/progs/trivial/quad-offset-factor.c
@@ -0,0 +1,167 @@
+/*
+ * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the name of
+ * Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
+ * ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+
+#define CI_OFFSET_1 16
+#define CI_OFFSET_2 32
+
+
+GLenum doubleBuffer;
+
+static void Init(void)
+{
+ fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+ fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
+ fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
+
+ glClearColor(1.0, 1.0, 1.0, 0.0);
+}
+
+static void Reshape(int width, int height)
+{
+
+ glViewport(0, 0, (GLint)width, (GLint)height);
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
+ glMatrixMode(GL_MODELVIEW);
+}
+
+static void Key(unsigned char key, int x, int y)
+{
+
+ switch (key) {
+ case 27:
+ exit(1);
+ default:
+ return;
+ }
+
+ glutPostRedisplay();
+}
+
+static void quad( float half )
+{
+ glBegin(GL_QUADS);
+ glVertex3f( half/9.0, -half/9.0, -25.0 + half);
+ glVertex3f( half/9.0, half/9.0, -25.0 + half);
+ glVertex3f(-half/9.0, half/9.0, -25.0 - half);
+ glVertex3f(-half/9.0, -half/9.0, -25.0 - half);
+ glEnd();
+
+}
+
+static void Draw(void)
+{
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ glEnable(GL_DEPTH_TEST);
+
+
+
+ glEnable(GL_POLYGON_OFFSET_FILL);
+ glPolygonOffset(1, 0);
+
+ glColor3f(1,0,0);
+ quad(9);
+
+ glDisable(GL_POLYGON_OFFSET_FILL);
+ glColor3f(0,1,0);
+ quad(6);
+
+
+ glEnable(GL_POLYGON_OFFSET_FILL);
+ glPolygonOffset(0, 0);
+
+ /* Black - should not be visible
+ */
+ glColor3f(0,0,0);
+ quad(6);
+
+ glEnable(GL_POLYGON_OFFSET_FILL);
+ glPolygonOffset(-1, 0);
+ glColor3f(0,0,1);
+ quad(3);
+
+ glDisable(GL_POLYGON_OFFSET_FILL);
+
+ glFlush();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ fprintf(stderr, "%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ GLenum type;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB | GLUT_DEPTH;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : 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/trivial/quad-offset-unfilled.c b/progs/trivial/quad-offset-unfilled.c
new file mode 100644
index 00000000000..1cecf3c1cef
--- /dev/null
+++ b/progs/trivial/quad-offset-unfilled.c
@@ -0,0 +1,167 @@
+/*
+ * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the name of
+ * Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
+ * ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+
+#define CI_OFFSET_1 16
+#define CI_OFFSET_2 32
+
+
+GLenum doubleBuffer;
+
+static void Init(void)
+{
+ fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+ fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
+ fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
+
+ glClearColor(1.0, 1.0, 1.0, 0.0);
+}
+
+static void Reshape(int width, int height)
+{
+
+ glViewport(0, 0, (GLint)width, (GLint)height);
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
+ glMatrixMode(GL_MODELVIEW);
+}
+
+static void Key(unsigned char key, int x, int y)
+{
+
+ switch (key) {
+ case 27:
+ exit(1);
+ default:
+ return;
+ }
+
+ glutPostRedisplay();
+}
+
+static void Draw(void)
+{
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ glEnable(GL_DEPTH_TEST);
+
+
+
+ glEnable(GL_POLYGON_OFFSET_FILL);
+ glPolygonOffset(1, 0);
+
+ glBegin(GL_QUADS);
+ glColor3f(1,0,0);
+ glVertex3f( 0.9, -0.9, -10.0);
+ glVertex3f( 0.9, 0.9, -10.0);
+ glVertex3f(-0.9, 0.9, -40.0);
+ glVertex3f(-0.9, -0.9, -40.0);
+ glEnd();
+
+ glDisable(GL_POLYGON_OFFSET_FILL);
+
+ glBegin(GL_QUADS);
+ glColor3f(0,1,0);
+ glVertex3f( 0.6, -0.6, -15.0);
+ glVertex3f( 0.6, 0.6, -15.0);
+ glVertex3f(-0.6, 0.6, -35.0);
+ glVertex3f(-0.6, -0.6, -35.0);
+ glEnd();
+
+ glEnable(GL_POLYGON_OFFSET_FILL);
+ glPolygonOffset(-1, 0);
+
+ glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
+
+ glBegin(GL_QUADS);
+ glColor3f(0,0,1);
+ glVertex3f( 0.3, -0.3, -20.0);
+ glVertex3f( 0.3, 0.3, -20.0);
+ glVertex3f(-0.3, 0.3, -30.0);
+ glVertex3f(-0.3, -0.3, -30.0);
+ glEnd();
+
+
+ glDisable(GL_POLYGON_OFFSET_FILL);
+
+ glFlush();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ fprintf(stderr, "%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ GLenum type;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB | GLUT_DEPTH;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : 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/trivial/quad-offset-units.c b/progs/trivial/quad-offset-units.c
new file mode 100644
index 00000000000..5c41be308ee
--- /dev/null
+++ b/progs/trivial/quad-offset-units.c
@@ -0,0 +1,166 @@
+/*
+ * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the name of
+ * Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
+ * ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+
+#define CI_OFFSET_1 16
+#define CI_OFFSET_2 32
+
+
+GLenum doubleBuffer;
+
+static void Init(void)
+{
+ fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+ fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
+ fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
+
+ glClearColor(1.0, 1.0, 1.0, 0.0);
+}
+
+static void Reshape(int width, int height)
+{
+
+ glViewport(0, 0, (GLint)width, (GLint)height);
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glOrtho(-1.2, 1.2, -1.2, 1.2, -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 quad( float half )
+{
+ glBegin(GL_QUADS);
+ glVertex3f( half/9.0, -half/9.0, -25.0 + half);
+ glVertex3f( half/9.0, half/9.0, -25.0 + half);
+ glVertex3f(-half/9.0, half/9.0, -25.0 - half);
+ glVertex3f(-half/9.0, -half/9.0, -25.0 - half);
+ glEnd();
+
+}
+
+static void Draw(void)
+{
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ glEnable(GL_DEPTH_TEST);
+
+
+
+ glEnable(GL_POLYGON_OFFSET_FILL);
+ glPolygonOffset(0, 4);
+
+ glColor3f(1,0,0);
+ quad(9);
+
+ glDisable(GL_POLYGON_OFFSET_FILL);
+ glColor3f(0,0,0);
+ quad(6);
+
+ glEnable(GL_POLYGON_OFFSET_FILL);
+ glPolygonOffset(0, 0);
+
+ glDepthFunc( GL_EQUAL );
+ glColor3f(0,1,0);
+ quad(6);
+ glDepthFunc( GL_LESS );
+
+
+ glPolygonOffset(0, -4);
+ glColor3f(0,0,1);
+ quad(3);
+
+ glDisable(GL_POLYGON_OFFSET_FILL);
+
+ glFlush();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ fprintf(stderr, "%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ GLenum type;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB | GLUT_DEPTH;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : 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/trivial/quad-tex-2d.c b/progs/trivial/quad-tex-2d.c
new file mode 100644
index 00000000000..70b9fbf8c61
--- /dev/null
+++ b/progs/trivial/quad-tex-2d.c
@@ -0,0 +1,169 @@
+/*
+ * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the name of
+ * Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
+ * ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+
+#define CI_OFFSET_1 16
+#define CI_OFFSET_2 32
+
+GLenum doubleBuffer;
+
+static void Init(void)
+{
+ fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+ fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
+ fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
+
+ glClearColor(0.0, 0.0, 1.0, 0.0);
+
+#define SIZE 16
+ {
+ GLubyte tex2d[SIZE][SIZE][3];
+ GLint s, t;
+
+ for (s = 0; s < SIZE; s++) {
+ for (t = 0; t < SIZE; t++) {
+#if 0
+ tex2d[t][s][0] = (s < SIZE/2) ? 0 : 255;
+ tex2d[t][s][1] = (t < SIZE/2) ? 0 : 255;
+ tex2d[t][s][2] = 0;
+#else
+ tex2d[t][s][0] = s*255/(SIZE-1);
+ tex2d[t][s][1] = t*255/(SIZE-1);
+ tex2d[t][s][2] = 0;
+#endif
+ }
+ }
+
+ glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_R, GL_REPEAT);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+ glTexImage2D(GL_TEXTURE_2D, 0, 3, SIZE, SIZE, 0,
+ GL_RGB, GL_UNSIGNED_BYTE, tex2d);
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
+ glEnable(GL_TEXTURE_2D);
+ }
+
+}
+
+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_QUADS);
+ glTexCoord2f(1,0);
+ glVertex3f( 0.9, -0.9, -30.0);
+ glTexCoord2f(1,1);
+ glVertex3f( 0.9, 0.9, -30.0);
+ glTexCoord2f(0,1);
+ glVertex3f(-0.9, 0.9, -30.0);
+ glTexCoord2f(0,0);
+ glVertex3f(-0.9, -0.9, -30.0);
+ glEnd();
+
+ glFlush();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ fprintf(stderr, "%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ GLenum type;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : 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/trivial/quad-tex-3d.c b/progs/trivial/quad-tex-3d.c
new file mode 100644
index 00000000000..0b2dcc08a5f
--- /dev/null
+++ b/progs/trivial/quad-tex-3d.c
@@ -0,0 +1,177 @@
+/*
+ * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the name of
+ * Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
+ * ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+
+#define CI_OFFSET_1 16
+#define CI_OFFSET_2 32
+
+GLfloat z= 0;
+GLenum doubleBuffer;
+
+static void Init(void)
+{
+ fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+ fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
+ fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
+
+ glClearColor(0.0, 0.0, 1.0, 0.0);
+
+#define SIZE 16
+ {
+ GLubyte tex3d[SIZE][SIZE][SIZE][3];
+ GLint r, s, t;
+
+ for (s = 0; s < SIZE; s++) {
+ for (t = 0; t < SIZE; t++) {
+ for (r = 0; r < SIZE; r++) {
+#if 0
+ tex3d[r][t][s][0] = (s < SIZE/2) ? 0 : 255;
+ tex3d[r][t][s][1] = (t < SIZE/2) ? 0 : 255;
+ tex3d[r][t][s][2] = (r < SIZE/2) ? 0 : 255;
+#else
+ tex3d[r][t][s][0] = s*255/(SIZE-1);
+ tex3d[r][t][s][1] = t*255/(SIZE-1);
+ tex3d[r][t][s][2] = r*255/(SIZE-1);
+#endif
+ }
+ }
+ }
+
+ glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
+ glTexParameterf(GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, GL_REPEAT);
+ glTexParameterf(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameterf(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+ glTexImage3D(GL_TEXTURE_3D, 0, 3, SIZE, SIZE, SIZE, 0,
+ GL_RGB, GL_UNSIGNED_BYTE, tex3d);
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
+ glEnable(GL_TEXTURE_3D);
+ }
+
+}
+
+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 ' ':
+ z += 1.0/SIZE;
+ break;
+ case 27:
+ exit(1);
+ default:
+ return;
+ }
+
+ glutPostRedisplay();
+}
+
+static void Draw(void)
+{
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ fprintf(stderr, "z: %f\n", z);
+
+ glBegin(GL_QUADS);
+ glTexCoord3f(1,0,z);
+ glVertex3f( 0.9, -0.9, -30.0);
+ glTexCoord3f(1,1,z);
+ glVertex3f( 0.9, 0.9, -30.0);
+ glTexCoord3f(0,1,z);
+ glVertex3f(-0.9, 0.9, -30.0);
+ glTexCoord3f(0,0,z);
+ glVertex3f(-0.9, -0.9, -30.0);
+ glEnd();
+
+ glFlush();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ fprintf(stderr, "%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ GLenum type;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : 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/trivial/quad-tex-pbo.c b/progs/trivial/quad-tex-pbo.c
new file mode 100644
index 00000000000..5b63c698a7e
--- /dev/null
+++ b/progs/trivial/quad-tex-pbo.c
@@ -0,0 +1,181 @@
+/*
+ * 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.
+ */
+
+#define GL_GLEXT_PROTOTYPES
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+
+#define CI_OFFSET_1 16
+#define CI_OFFSET_2 32
+
+GLenum doubleBuffer;
+
+static GLuint DrawPBO;
+
+static void Init(void)
+{
+ fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+ fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
+ fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
+
+ glClearColor(0.0, 0.0, 1.0, 0.0);
+
+#define SIZE 16
+ {
+ GLubyte tex2d[SIZE][SIZE][4];
+ GLint s, t;
+
+ for (s = 0; s < SIZE; s++) {
+ for (t = 0; t < SIZE; t++) {
+ /* bgra:
+ */
+ tex2d[t][s][0] = 0x30;
+ tex2d[t][s][1] = t*255/(SIZE-1);
+ tex2d[t][s][2] = s*255/(SIZE-1);
+ tex2d[t][s][3] = 0xff;
+ }
+ }
+
+
+ /* put image into DrawPBO */
+ glGenBuffersARB(1, &DrawPBO);
+ glBindBufferARB(GL_PIXEL_PACK_BUFFER_EXT, DrawPBO);
+ glBufferDataARB(GL_PIXEL_PACK_BUFFER_EXT,
+ SIZE * SIZE * 4, tex2d, GL_STATIC_DRAW);
+ glBindBufferARB(GL_PIXEL_PACK_BUFFER_EXT, 0);
+
+
+ glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_R, GL_REPEAT);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+ glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_EXT, DrawPBO);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, SIZE, SIZE, 0,
+ GL_BGRA, GL_UNSIGNED_BYTE, NULL);
+ glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_EXT, 0);
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
+ glEnable(GL_TEXTURE_2D);
+ }
+
+}
+
+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_QUADS);
+ glTexCoord2f(1,0);
+ glVertex3f( 0.9, -0.9, -30.0);
+ glTexCoord2f(1,1);
+ glVertex3f( 0.9, 0.9, -30.0);
+ glTexCoord2f(0,1);
+ glVertex3f(-0.9, 0.9, -30.0);
+ glTexCoord2f(0,0);
+ glVertex3f(-0.9, -0.9, -30.0);
+ glEnd();
+
+ glFlush();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ fprintf(stderr, "%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ GLenum type;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : 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/trivial/quad-unfilled.c b/progs/trivial/quad-unfilled.c
new file mode 100644
index 00000000000..9d63d2dfb95
--- /dev/null
+++ b/progs/trivial/quad-unfilled.c
@@ -0,0 +1,139 @@
+/*
+ * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the name of
+ * Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
+ * ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+
+#define CI_OFFSET_1 16
+#define CI_OFFSET_2 32
+
+
+GLenum doubleBuffer;
+
+static void Init(void)
+{
+ fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+ fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
+ fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
+
+ glClearColor(0.0, 0.0, 1.0, 0.0);
+}
+
+static void Reshape(int width, int height)
+{
+
+ glViewport(0, 0, (GLint)width, (GLint)height);
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
+ glMatrixMode(GL_MODELVIEW);
+}
+
+static void Key(unsigned char key, int x, int y)
+{
+
+ switch (key) {
+ case 27:
+ exit(1);
+ default:
+ return;
+ }
+
+ glutPostRedisplay();
+}
+
+static void Draw(void)
+{
+ glClear(GL_COLOR_BUFFER_BIT);
+ glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
+
+ glBegin(GL_QUADS);
+ glColor3f(1,0,0);
+ glVertex3f( 0.9, -0.9, -30.0);
+ glColor3f(1,1,0);
+ glVertex3f( 0.9, 0.9, -30.0);
+ glColor3f(1,0,1);
+ glVertex3f(-0.9, 0.9, -30.0);
+ glColor3f(0,1,1);
+ glVertex3f(-0.9, -0.9, -30.0);
+ glEnd();
+
+ glFlush();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ fprintf(stderr, "%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ GLenum type;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : 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/trivial/quad.c b/progs/trivial/quad.c
new file mode 100644
index 00000000000..85424b7b388
--- /dev/null
+++ b/progs/trivial/quad.c
@@ -0,0 +1,138 @@
+/*
+ * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the name of
+ * Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
+ * ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+
+#define CI_OFFSET_1 16
+#define CI_OFFSET_2 32
+
+
+GLenum doubleBuffer;
+
+static void Init(void)
+{
+ fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+ fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
+ fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
+
+ glClearColor(0.0, 0.0, 1.0, 0.0);
+}
+
+static void Reshape(int width, int height)
+{
+
+ glViewport(0, 0, (GLint)width, (GLint)height);
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
+ glMatrixMode(GL_MODELVIEW);
+}
+
+static void Key(unsigned char key, int x, int y)
+{
+
+ switch (key) {
+ case 27:
+ exit(1);
+ default:
+ return;
+ }
+
+ glutPostRedisplay();
+}
+
+static void Draw(void)
+{
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ glBegin(GL_QUADS);
+ glColor3f(1,0,0);
+ glVertex3f( 0.9, -0.9, -30.0);
+ glColor3f(1,1,0);
+ glVertex3f( 0.9, 0.9, -30.0);
+ glColor3f(1,0,1);
+ glVertex3f(-0.9, 0.9, -30.0);
+ glColor3f(0,1,1);
+ glVertex3f(-0.9, -0.9, -30.0);
+ glEnd();
+
+ glFlush();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ fprintf(stderr, "%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ GLenum type;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : 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/trivial/quads.c b/progs/trivial/quads.c
new file mode 100644
index 00000000000..1ca82cd9f8b
--- /dev/null
+++ b/progs/trivial/quads.c
@@ -0,0 +1,156 @@
+/*
+ * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the name of
+ * Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
+ * ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+
+#define CI_OFFSET_1 16
+#define CI_OFFSET_2 32
+
+
+GLenum doubleBuffer;
+
+static void Init(void)
+{
+ fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+ fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
+ fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
+
+ glClearColor(0.0, 0.0, 1.0, 0.0);
+}
+
+static void Reshape(int width, int height)
+{
+
+ glViewport(0, 0, (GLint)width, (GLint)height);
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
+ glMatrixMode(GL_MODELVIEW);
+}
+
+static void Key(unsigned char key, int x, int y)
+{
+
+ switch (key) {
+ case 27:
+ exit(1);
+ default:
+ return;
+ }
+
+ glutPostRedisplay();
+}
+
+static void Draw(void)
+{
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ glBegin(GL_QUADS);
+ glColor3f(1,0,0);
+ glVertex3f( 0.9, -0.9, -30.0);
+ glColor3f(1,1,0);
+ glVertex3f( 0.9, 0.9, -30.0);
+
+ glColor3f(1,1,1);
+ glVertex3f( 0.1, 0.9, -30.0);
+ glColor3f(1,0,1);
+ glVertex3f( 0.1, -0.9, -30.0);
+
+ if (0) {
+ glEnd();
+ glFlush();
+ glBegin(GL_QUADS);
+ }
+
+ glColor3f(0,1,0);
+ glVertex3f(-0.1, -0.9, -30.0);
+ glColor3f(1,0,0);
+ glVertex3f(-0.1, 0.9, -30.0);
+
+
+ glColor3f(1,0,1);
+ glVertex3f(-0.9, 0.9, -30.0);
+ glColor3f(0,1,1);
+ glVertex3f(-0.9, -0.9, -30.0);
+ glEnd();
+
+ glFlush();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ fprintf(stderr, "%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ GLenum type;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : 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/trivial/quadstrip-flat.c b/progs/trivial/quadstrip-flat.c
new file mode 100644
index 00000000000..061a0e409e4
--- /dev/null
+++ b/progs/trivial/quadstrip-flat.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 <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+
+#define CI_OFFSET_1 16
+#define CI_OFFSET_2 32
+
+
+GLenum doubleBuffer;
+
+static void Init(void)
+{
+ fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+ fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
+ fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
+
+ glClearColor(0.0, 0.0, 1.0, 0.0);
+}
+
+static void Reshape(int width, int height)
+{
+
+ glViewport(0, 0, (GLint)width, (GLint)height);
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
+ glMatrixMode(GL_MODELVIEW);
+}
+
+static void Key(unsigned char key, int x, int y)
+{
+
+ switch (key) {
+ case 27:
+ exit(1);
+ default:
+ return;
+ }
+
+ glutPostRedisplay();
+}
+
+static void Draw(void)
+{
+ glClear(GL_COLOR_BUFFER_BIT);
+ glShadeModel(GL_FLAT);
+
+ glBegin(GL_QUAD_STRIP);
+ glColor3f(1,0,0);
+ glVertex3f( 0.9, -0.9, -30.0);
+ glColor3f(1,1,0);
+ glVertex3f( 0.9, 0.9, -30.0);
+
+ glColor3f(1,0,0);
+ glVertex3f( 0.1, -0.8, -30.0);
+ glColor3f(1,1,0);
+ glVertex3f( 0.1, 0.8, -30.0);
+
+ glColor3f(0,1,1);
+ glVertex3f(-0.1, -0.9, -30.0);
+ glColor3f(1,0,1);
+ glVertex3f(-0.1, 0.9, -30.0);
+
+ glColor3f(0,1,1);
+ glVertex3f(-0.9, -0.8, -30.0);
+ glColor3f(1,0,1);
+ glVertex3f(-0.9, 0.8, -30.0);
+ glEnd();
+
+ glFlush();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ fprintf(stderr, "%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ GLenum type;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : 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/trivial/quadstrip.c b/progs/trivial/quadstrip.c
new file mode 100644
index 00000000000..342463f1a24
--- /dev/null
+++ b/progs/trivial/quadstrip.c
@@ -0,0 +1,144 @@
+/*
+ * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the name of
+ * Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
+ * ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+GLenum doubleBuffer;
+
+static void Init(void)
+{
+ fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+ fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
+ fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
+
+ glClearColor(0.0, 0.0, 1.0, 0.0);
+}
+
+static void Reshape(int width, int height)
+{
+
+ glViewport(0, 0, (GLint)width, (GLint)height);
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
+ glMatrixMode(GL_MODELVIEW);
+}
+
+static void Key(unsigned char key, int x, int y)
+{
+
+ switch (key) {
+ case 27:
+ exit(1);
+ default:
+ return;
+ }
+
+ glutPostRedisplay();
+}
+
+static void Draw(void)
+{
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ glBegin(GL_QUAD_STRIP);
+ glColor3f(1,0,0);
+ glVertex3f( 0.9, -0.9, -30.0);
+ glColor3f(1,1,0);
+ glVertex3f( 0.9, 0.9, -30.0);
+
+ glColor3f(1,0,0);
+ glVertex3f( 0.1, -0.8, -30.0);
+ glColor3f(1,1,0);
+ glVertex3f( 0.1, 0.8, -30.0);
+
+ glColor3f(0,1,1);
+ glVertex3f(-0.1, -0.9, -30.0);
+ glColor3f(1,0,1);
+ glVertex3f(-0.1, 0.9, -30.0);
+
+ glColor3f(0,1,1);
+ glVertex3f(-0.9, -0.8, -30.0);
+ glColor3f(1,0,1);
+ glVertex3f(-0.9, 0.8, -30.0);
+ glEnd();
+
+ glFlush();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ fprintf(stderr, "%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ GLenum type;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : 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/trivial/tri-blend.c b/progs/trivial/tri-blend.c
new file mode 100644
index 00000000000..284d15fd3c9
--- /dev/null
+++ b/progs/trivial/tri-blend.c
@@ -0,0 +1,144 @@
+/*
+ * 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 <GL/glut.h>
+#include <stdlib.h>
+
+static int leftFirst = GL_TRUE;
+
+/* Initialize alpha blending function.
+ */
+static void init(void)
+{
+ glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glShadeModel (GL_FLAT);
+ glClearColor (1.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 */
+
+ glEnable (GL_BLEND);
+ 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();
+ glDisable (GL_BLEND);
+}
+
+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/trivial/tri-clip.c b/progs/trivial/tri-clip.c
new file mode 100644
index 00000000000..bf48533adcc
--- /dev/null
+++ b/progs/trivial/tri-clip.c
@@ -0,0 +1,137 @@
+/*
+ * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the name of
+ * Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
+ * ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+
+#define CI_OFFSET_1 16
+#define CI_OFFSET_2 32
+
+
+GLenum doubleBuffer;
+
+static void Init(void)
+{
+ fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+ fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
+ fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
+
+ glClearColor(0.0, 0.0, 1.0, 0.0);
+}
+
+static void Reshape(int width, int height)
+{
+
+ glViewport(0, 0, (GLint)width, (GLint)height);
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
+ glMatrixMode(GL_MODELVIEW);
+}
+
+static void Key(unsigned char key, int x, int y)
+{
+
+ switch (key) {
+ case 27:
+ exit(1);
+ default:
+ return;
+ }
+
+ glutPostRedisplay();
+}
+
+static void Draw(void)
+{
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ glBegin(GL_TRIANGLES);
+ glColor3f(0,0,.7);
+ glVertex3f( 0.9, -0.9, -30.0);
+ glColor3f(.8,0,0);
+ glVertex3f( 0.9, 0.9, -30.0);
+ glColor3f(0,.9,0);
+ glVertex3f(-1.9, 0.0, -30.0);
+ glEnd();
+
+ glFlush();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ fprintf(stderr, "%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ GLenum type;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : 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/trivial/tri-cull.c b/progs/trivial/tri-cull.c
new file mode 100644
index 00000000000..20aeaf1d7cd
--- /dev/null
+++ b/progs/trivial/tri-cull.c
@@ -0,0 +1,136 @@
+/*
+ * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the name of
+ * Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
+ * ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+
+#define CI_OFFSET_1 16
+#define CI_OFFSET_2 32
+
+
+GLenum doubleBuffer;
+
+static void Init(void)
+{
+ fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+ fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
+ fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
+
+ glClearColor(0.0, 0.0, 1.0, 0.0);
+}
+
+static void Reshape(int width, int height)
+{
+
+ glViewport(0, 0, (GLint)width, (GLint)height);
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
+ glMatrixMode(GL_MODELVIEW);
+}
+
+static void Key(unsigned char key, int x, int y)
+{
+
+ switch (key) {
+ case 27:
+ exit(1);
+ default:
+ return;
+ }
+
+ glutPostRedisplay();
+}
+
+static void Draw(void)
+{
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ glBegin(GL_TRIANGLES);
+ glColor3f(0,0,1);
+ glVertex3f( -1.5, 0.5, -30.0);
+ glColor3f(1,0,0);
+ glVertex3f( 0, 2.0, -30.0);
+ glColor3f(0,1,0);
+ glVertex3f(-1.5, 2.0, -30.0);
+ glEnd();
+
+ glFlush();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ fprintf(stderr, "%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ GLenum type;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : 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/trivial/tri-dlist.c b/progs/trivial/tri-dlist.c
new file mode 100644
index 00000000000..e0ab285eff4
--- /dev/null
+++ b/progs/trivial/tri-dlist.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 <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+
+#define CI_OFFSET_1 16
+#define CI_OFFSET_2 32
+
+
+GLenum doubleBuffer;
+GLint list;
+
+static void Init(void)
+{
+ fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+ fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
+ fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
+
+ glClearColor(0.0, 0.0, 1.0, 0.0);
+
+ list = glGenLists(1);
+ glNewList(list, GL_COMPILE);
+ glBegin(GL_TRIANGLES);
+/* glColor3f(0,0,.7); */
+ glVertex3f( 0.9, -0.9, -30.0);
+/* glColor3f(.8,0,0); */
+ glVertex3f( 0.9, 0.9, -30.0);
+/* glColor3f(0,.9,0); */
+ glVertex3f(-0.9, 0.0, -30.0);
+ glEnd();
+ glEndList();
+}
+
+static void Reshape(int width, int height)
+{
+
+ glViewport(0, 0, (GLint)width, (GLint)height);
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
+ glMatrixMode(GL_MODELVIEW);
+}
+
+static void Key(unsigned char key, int x, int y)
+{
+
+ switch (key) {
+ case 27:
+ exit(1);
+ default:
+ return;
+ }
+
+ glutPostRedisplay();
+}
+
+
+
+
+static void Draw(void)
+{
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ glColor3f(0,.9,0);
+ glCallList(list);
+
+ glRotatef(45,0,0,1);
+ glColor3f(1,0,1);
+ glCallList(list);
+
+ glFlush();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ fprintf(stderr, "%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ GLenum type;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : 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/trivial/tri-edgeflag.c b/progs/trivial/tri-edgeflag.c
new file mode 100644
index 00000000000..bdc0eaa253a
--- /dev/null
+++ b/progs/trivial/tri-edgeflag.c
@@ -0,0 +1,141 @@
+/*
+ * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the name of
+ * Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
+ * ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+
+#define CI_OFFSET_1 16
+#define CI_OFFSET_2 32
+
+
+GLenum doubleBuffer;
+
+static void Init(void)
+{
+ fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+ fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
+ fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
+
+ glClearColor(0.0, 0.0, 1.0, 0.0);
+}
+
+static void Reshape(int width, int height)
+{
+
+ glViewport(0, 0, (GLint)width, (GLint)height);
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+/* glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0); */
+ glMatrixMode(GL_MODELVIEW);
+}
+
+static void Key(unsigned char key, int x, int y)
+{
+
+ switch (key) {
+ case 27:
+ exit(1);
+ default:
+ return;
+ }
+
+ glutPostRedisplay();
+}
+
+static void Draw(void)
+{
+ glClear(GL_COLOR_BUFFER_BIT);
+ glPolygonMode(GL_FRONT, GL_LINE);
+ glPolygonMode(GL_BACK, GL_POINT);
+
+ glBegin(GL_TRIANGLES);
+ glEdgeFlag(1);
+ glColor3f(0,0,.7);
+ glVertex3f( 0.9, -0.9, -0.0);
+ glEdgeFlag(0);
+ glColor3f(.8,0,0);
+ glVertex3f( 0.9, 0.9, -0.0);
+ glEdgeFlag(1);
+ glColor3f(0,.9,0);
+ glVertex3f(-0.9, 0.0, -0.0);
+ glEnd();
+
+ glFlush();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ fprintf(stderr, "%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ GLenum type;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : 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/trivial/tri-flat-clip.c b/progs/trivial/tri-flat-clip.c
new file mode 100644
index 00000000000..fafa64914d4
--- /dev/null
+++ b/progs/trivial/tri-flat-clip.c
@@ -0,0 +1,137 @@
+/*
+ * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the name of
+ * Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
+ * ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+
+#define CI_OFFSET_1 16
+#define CI_OFFSET_2 32
+
+
+GLenum doubleBuffer;
+
+static void Init(void)
+{
+ fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+ fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
+ fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
+
+ glClearColor(0.5, 0.5, 0.5, 0.0);
+}
+
+static void Reshape(int width, int height)
+{
+
+ glViewport(0, 0, (GLint)width, (GLint)height);
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
+ glMatrixMode(GL_MODELVIEW);
+}
+
+static void Key(unsigned char key, int x, int y)
+{
+
+ switch (key) {
+ case 27:
+ exit(1);
+ default:
+ return;
+ }
+
+ glutPostRedisplay();
+}
+
+static void Draw(void)
+{
+ glClear(GL_COLOR_BUFFER_BIT);
+ glShadeModel(GL_FLAT);
+
+ 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(-1.9, 0.0, -30.0);
+ glEnd();
+
+ glFlush();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ fprintf(stderr, "%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ GLenum type;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : 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/trivial/tri-flat.c b/progs/trivial/tri-flat.c
new file mode 100644
index 00000000000..fb2cdbd7bba
--- /dev/null
+++ b/progs/trivial/tri-flat.c
@@ -0,0 +1,137 @@
+/*
+ * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the name of
+ * Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
+ * ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+
+#define CI_OFFSET_1 16
+#define CI_OFFSET_2 32
+
+
+GLenum doubleBuffer;
+
+static void Init(void)
+{
+ fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+ fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
+ fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
+
+ glClearColor(0.5, 0.5, 0.5, 0.0);
+}
+
+static void Reshape(int width, int height)
+{
+
+ glViewport(0, 0, (GLint)width, (GLint)height);
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
+ glMatrixMode(GL_MODELVIEW);
+}
+
+static void Key(unsigned char key, int x, int y)
+{
+
+ switch (key) {
+ case 27:
+ exit(1);
+ default:
+ return;
+ }
+
+ glutPostRedisplay();
+}
+
+static void Draw(void)
+{
+ glClear(GL_COLOR_BUFFER_BIT);
+ glShadeModel(GL_FLAT);
+
+ 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();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ fprintf(stderr, "%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ GLenum type;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : 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/trivial/tri-tex-3d.c b/progs/trivial/tri-tex-3d.c
new file mode 100644
index 00000000000..6a9d1d1bf6d
--- /dev/null
+++ b/progs/trivial/tri-tex-3d.c
@@ -0,0 +1,170 @@
+/*
+ * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the name of
+ * Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
+ * ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+
+#define CI_OFFSET_1 16
+#define CI_OFFSET_2 32
+
+
+GLenum doubleBuffer;
+
+static void Init(void)
+{
+ fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+ fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
+ fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
+
+ glClearColor(0.0, 0.0, 1.0, 0.0);
+
+#define SIZE 16
+ {
+ GLubyte tex3d[SIZE][SIZE][SIZE][3];
+ GLint r, s, t;
+
+ for (s = 0; s < SIZE; s++) {
+ for (t = 0; t < SIZE; t++) {
+ for (r = 0; r < SIZE; r++) {
+#if 0
+ tex3d[r][t][s][0] = (s < SIZE/2) ? 0 : 255;
+ tex3d[r][t][s][1] = (t < SIZE/2) ? 0 : 255;
+ tex3d[r][t][s][2] = (r < SIZE/2) ? 0 : 255;
+#else
+ tex3d[r][t][s][0] = s*255/(SIZE-1);
+ tex3d[r][t][s][1] = t*255/(SIZE-1);
+ tex3d[r][t][s][2] = r*255/(SIZE-1);
+#endif
+ }
+ }
+ }
+
+ glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
+ glTexParameterf(GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, GL_REPEAT);
+ glTexParameterf(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameterf(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+ glTexImage3D(GL_TEXTURE_3D, 0, 3, SIZE, SIZE, SIZE, 0,
+ GL_RGB, GL_UNSIGNED_BYTE, tex3d);
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
+ glEnable(GL_TEXTURE_3D);
+ }
+
+}
+
+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);
+ glTexCoord3f( 0,0,.9);
+ glVertex3f( 0.9, -0.9, -30.0);
+ glTexCoord3f(.9,0,0);
+ glVertex3f( 0.9, 0.9, -30.0);
+ glTexCoord3f(0,.9,0);
+ glVertex3f(-0.9, 0.0, -30.0);
+ glEnd();
+
+ glFlush();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ fprintf(stderr, "%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ GLenum type;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : 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/trivial/tri-unfilled-clip.c b/progs/trivial/tri-unfilled-clip.c
new file mode 100644
index 00000000000..d486af23655
--- /dev/null
+++ b/progs/trivial/tri-unfilled-clip.c
@@ -0,0 +1,137 @@
+/*
+ * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the name of
+ * Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
+ * ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+
+#define CI_OFFSET_1 16
+#define CI_OFFSET_2 32
+
+
+GLenum doubleBuffer;
+
+static void Init(void)
+{
+ fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+ fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
+ fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
+
+ glClearColor(0.0, 0.0, 1.0, 0.0);
+}
+
+static void Reshape(int width, int height)
+{
+
+ glViewport(0, 0, (GLint)width, (GLint)height);
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
+ glMatrixMode(GL_MODELVIEW);
+}
+
+static void Key(unsigned char key, int x, int y)
+{
+
+ switch (key) {
+ case 27:
+ exit(1);
+ default:
+ return;
+ }
+
+ glutPostRedisplay();
+}
+
+static void Draw(void)
+{
+ glClear(GL_COLOR_BUFFER_BIT);
+ glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
+
+ glBegin(GL_TRIANGLES);
+ glColor3f(0,0,.7);
+ glVertex3f( 0.9, -0.9, -30.0);
+ glColor3f(.8,0,0);
+ glVertex3f( 0.9, 0.9, -30.0);
+ glColor3f(0,.9,0);
+ glVertex3f(-1.9, 0.0, -30.0);
+ glEnd();
+
+ glFlush();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ fprintf(stderr, "%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ GLenum type;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : 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/trivial/tri-unfilled-smooth.c b/progs/trivial/tri-unfilled-smooth.c
new file mode 100644
index 00000000000..e41903a3d50
--- /dev/null
+++ b/progs/trivial/tri-unfilled-smooth.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 <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+
+#define CI_OFFSET_1 16
+#define CI_OFFSET_2 32
+
+
+GLenum doubleBuffer;
+
+static void Init(void)
+{
+ fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+ fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
+ fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
+
+ glClearColor(0.0, 0.0, 1.0, 0.0);
+}
+
+static void Reshape(int width, int height)
+{
+
+ glViewport(0, 0, (GLint)width, (GLint)height);
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+/* glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0); */
+ glMatrixMode(GL_MODELVIEW);
+}
+
+static void Key(unsigned char key, int x, int y)
+{
+
+ switch (key) {
+ case 27:
+ exit(1);
+ default:
+ return;
+ }
+
+ glutPostRedisplay();
+}
+
+static void Draw(void)
+{
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ glEnable(GL_LINE_SMOOTH);
+
+ glBegin(GL_TRIANGLES);
+ glColor3f(0,0,.7);
+ glVertex3f( 0.6, -0.6, -0.0);
+ glColor3f(.8,0,0);
+ glVertex3f( 0.6, 0.6, -0.0);
+ glColor3f(0,.9,0);
+ glVertex3f(-0.6, 0.0, -0.0);
+ glEnd();
+
+ glPolygonMode(GL_FRONT, GL_LINE);
+/* glPolygonMode(GL_BACK, GL_LINE); */
+
+ glBegin(GL_TRIANGLES);
+ glColor3f(0,0,.7);
+ glVertex3f( 0.9, -0.9, -0.0);
+ glColor3f(.8,0,0);
+ glVertex3f( 0.9, 0.9, -0.0);
+ glColor3f(0,.9,0);
+ glVertex3f(-0.9, 0.0, -0.0);
+ glEnd();
+
+ glFlush();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ fprintf(stderr, "%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ GLenum type;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : 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/trivial/tri-unfilled-userclip.c b/progs/trivial/tri-unfilled-userclip.c
new file mode 100644
index 00000000000..dc93a8f1abf
--- /dev/null
+++ b/progs/trivial/tri-unfilled-userclip.c
@@ -0,0 +1,141 @@
+/*
+ * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the name of
+ * Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
+ * ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+
+#define CI_OFFSET_1 16
+#define CI_OFFSET_2 32
+
+
+GLenum doubleBuffer;
+
+static void Init(void)
+{
+ static GLdouble plane[4] = { -.5, 0, 1, 0 };
+
+ fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+ fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
+ fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
+
+ glClearColor(0.0, 0.0, 1.0, 0.0);
+ glClipPlane(GL_CLIP_PLANE0, plane);
+ glEnable(GL_CLIP_PLANE0);
+}
+
+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);
+ glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
+
+ glBegin(GL_TRIANGLES);
+ glColor3f(0,0,.7);
+ glVertex3f( 0.9, -0.9, 0.0);
+ glColor3f(.8,0,0);
+ glVertex3f( 0.9, 0.9, 0.0);
+ glColor3f(0,.9,0);
+ glVertex3f(-0.9, 0.0, 0.0);
+ glEnd();
+
+ glFlush();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ fprintf(stderr, "%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ GLenum type;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : 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/trivial/tri-unfilled.c b/progs/trivial/tri-unfilled.c
new file mode 100644
index 00000000000..73961bc93a6
--- /dev/null
+++ b/progs/trivial/tri-unfilled.c
@@ -0,0 +1,138 @@
+/*
+ * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the name of
+ * Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
+ * ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+
+#define CI_OFFSET_1 16
+#define CI_OFFSET_2 32
+
+
+GLenum doubleBuffer;
+
+static void Init(void)
+{
+ fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+ fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
+ fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
+
+ glClearColor(0.0, 0.0, 1.0, 0.0);
+}
+
+static void Reshape(int width, int height)
+{
+
+ glViewport(0, 0, (GLint)width, (GLint)height);
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+/* glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0); */
+ glMatrixMode(GL_MODELVIEW);
+}
+
+static void Key(unsigned char key, int x, int y)
+{
+
+ switch (key) {
+ case 27:
+ exit(1);
+ default:
+ return;
+ }
+
+ glutPostRedisplay();
+}
+
+static void Draw(void)
+{
+ glClear(GL_COLOR_BUFFER_BIT);
+ glPolygonMode(GL_FRONT, GL_LINE);
+ glPolygonMode(GL_BACK, GL_LINE);
+
+ glBegin(GL_TRIANGLES);
+ glColor3f(0,0,.7);
+ glVertex3f( 0.9, -0.9, -0.0);
+ glColor3f(.8,0,0);
+ glVertex3f( 0.9, 0.9, -0.0);
+ glColor3f(0,.9,0);
+ glVertex3f(-0.9, 0.0, -0.0);
+ glEnd();
+
+ glFlush();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ fprintf(stderr, "%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ GLenum type;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : 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/trivial/tri-userclip.c b/progs/trivial/tri-userclip.c
new file mode 100644
index 00000000000..cde9662ace9
--- /dev/null
+++ b/progs/trivial/tri-userclip.c
@@ -0,0 +1,140 @@
+/*
+ * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the name of
+ * Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
+ * ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+
+#define CI_OFFSET_1 16
+#define CI_OFFSET_2 32
+
+
+GLenum doubleBuffer;
+
+static void Init(void)
+{
+ static GLdouble plane[4] = { -.5, 0, 1, 0 };
+
+ fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+ fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
+ fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
+
+ glClearColor(0.0, 0.0, 1.0, 0.0);
+ glClipPlane(GL_CLIP_PLANE0, plane);
+ glEnable(GL_CLIP_PLANE0);
+}
+
+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,.7);
+ glVertex3f( 0.9, -0.9, 0.0);
+ glColor3f(.8,0,0);
+ glVertex3f( 0.9, 0.9, 0.0);
+ glColor3f(0,.9,0);
+ glVertex3f(-0.9, 0.0, 0.0);
+ glEnd();
+
+ glFlush();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ fprintf(stderr, "%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ GLenum type;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : 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/trivial/tri.c b/progs/trivial/tri.c
new file mode 100644
index 00000000000..58a650b559f
--- /dev/null
+++ b/progs/trivial/tri.c
@@ -0,0 +1,136 @@
+/*
+ * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the name of
+ * Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
+ * ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+
+#define CI_OFFSET_1 16
+#define CI_OFFSET_2 32
+
+
+GLenum doubleBuffer;
+
+static void Init(void)
+{
+ fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+ fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
+ fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
+
+ glClearColor(0.0, 0.0, 1.0, 0.0);
+}
+
+static void Reshape(int width, int height)
+{
+
+ glViewport(0, 0, (GLint)width, (GLint)height);
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
+ glMatrixMode(GL_MODELVIEW);
+}
+
+static void Key(unsigned char key, int x, int y)
+{
+
+ switch (key) {
+ case 27:
+ exit(1);
+ default:
+ return;
+ }
+
+ glutPostRedisplay();
+}
+
+static void Draw(void)
+{
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ glBegin(GL_TRIANGLES);
+ glColor3f(0,0,.7);
+ glVertex3f( 0.9, -0.9, -30.0);
+ glColor3f(.8,0,0);
+ glVertex3f( 0.9, 0.9, -30.0);
+ glColor3f(0,.9,0);
+ glVertex3f(-0.9, 0.0, -30.0);
+ glEnd();
+
+ glFlush();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ fprintf(stderr, "%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ GLenum type;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : 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/trivial/tristrip-clip.c b/progs/trivial/tristrip-clip.c
new file mode 100644
index 00000000000..f95c66a62aa
--- /dev/null
+++ b/progs/trivial/tristrip-clip.c
@@ -0,0 +1,138 @@
+/*
+ * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the name of
+ * Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
+ * ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+
+#define CI_OFFSET_1 16
+#define CI_OFFSET_2 32
+
+
+GLenum doubleBuffer;
+
+static void Init(void)
+{
+ fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+ fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
+ fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
+
+ glClearColor(0.0, 0.0, 1.0, 0.0);
+}
+
+static void Reshape(int width, int height)
+{
+
+ glViewport(0, 0, (GLint)width, (GLint)height);
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
+ glMatrixMode(GL_MODELVIEW);
+}
+
+static void Key(unsigned char key, int x, int y)
+{
+
+ switch (key) {
+ case 27:
+ exit(1);
+ default:
+ return;
+ }
+
+ glutPostRedisplay();
+}
+
+static void Draw(void)
+{
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ glBegin(GL_TRIANGLE_STRIP);
+ glColor3f(1,0,0);
+ glVertex3f( 0.9, -0.9, -30.0);
+ glColor3f(1,1,0);
+ glVertex3f( 0.9, 0.9, -30.0);
+ glColor3f(0,1,1);
+ glVertex3f(-0.9, -0.9, -30.0);
+ glColor3f(1,0,1);
+ glVertex3f(-1.9, 0.9, -30.0);
+ glEnd();
+
+ glFlush();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ fprintf(stderr, "%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ GLenum type;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : 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/trivial/tristrip.c b/progs/trivial/tristrip.c
new file mode 100644
index 00000000000..fa82a737112
--- /dev/null
+++ b/progs/trivial/tristrip.c
@@ -0,0 +1,138 @@
+/*
+ * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the name of
+ * Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
+ * ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+
+#define CI_OFFSET_1 16
+#define CI_OFFSET_2 32
+
+
+GLenum doubleBuffer;
+
+static void Init(void)
+{
+ fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+ fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
+ fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
+
+ glClearColor(0.0, 0.0, 1.0, 0.0);
+}
+
+static void Reshape(int width, int height)
+{
+
+ glViewport(0, 0, (GLint)width, (GLint)height);
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
+ glMatrixMode(GL_MODELVIEW);
+}
+
+static void Key(unsigned char key, int x, int y)
+{
+
+ switch (key) {
+ case 27:
+ exit(1);
+ default:
+ return;
+ }
+
+ glutPostRedisplay();
+}
+
+static void Draw(void)
+{
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ glBegin(GL_TRIANGLE_STRIP);
+ glColor3f(1,0,0);
+ glVertex3f( 0.9, -0.9, -30.0);
+ glColor3f(1,1,0);
+ glVertex3f( 0.9, 0.9, -30.0);
+ glColor3f(0,1,1);
+ glVertex3f(-0.9, -0.9, -30.0);
+ glColor3f(1,0,1);
+ glVertex3f(-0.9, 0.9, -30.0);
+ glEnd();
+
+ glFlush();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ fprintf(stderr, "%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ GLenum type;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : 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/trivial/vp-array.c b/progs/trivial/vp-array.c
new file mode 100644
index 00000000000..abe8f62bec3
--- /dev/null
+++ b/progs/trivial/vp-array.c
@@ -0,0 +1,117 @@
+/* Test glGenProgramsNV(), glIsProgramNV(), glLoadProgramNV() */
+
+#include <assert.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+GLfloat verts[][4] = {
+ { 0.9, -0.9, 0.0, 1.0 },
+ { 0.9, 0.9, 0.0, 1.0 },
+ { -0.9, 0.9, 0.0, 1.0 },
+ { -0.9, -0.9, 0.0, 1.0 },
+};
+
+GLubyte color[][4] = {
+ { 0x00, 0x00, 0xff, 0x00 },
+ { 0x00, 0xff, 0x00, 0x00 },
+ { 0xff, 0x00, 0x00, 0x00 },
+ { 0xff, 0xff, 0xff, 0x00 },
+};
+
+GLuint indices[] = { 0, 1, 2, 3 };
+
+static void Init( void )
+{
+ GLint errno;
+ GLuint prognum;
+
+ static const char *prog1 =
+ "!!ARBvp1.0\n"
+ "MOV result.color, vertex.color;\n"
+ "MOV result.position, vertex.position;\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));
+ }
+
+
+ glEnableClientState( GL_VERTEX_ARRAY );
+ glEnableClientState( GL_COLOR_ARRAY );
+ glVertexPointer( 3, GL_FLOAT, sizeof(verts[0]), verts );
+ glColorPointer( 4, GL_UNSIGNED_BYTE, 0, color );
+
+}
+
+
+
+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);
+ glDrawElements( GL_TRIANGLES, 3, GL_UNSIGNED_INT, indices );
+
+ 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 );
+ Init();
+ glutMainLoop();
+ return 0;
+}
diff --git a/progs/trivial/vp-clip.c b/progs/trivial/vp-clip.c
new file mode 100644
index 00000000000..206ba0b8cb8
--- /dev/null
+++ b/progs/trivial/vp-clip.c
@@ -0,0 +1,102 @@
+/* Test glGenProgramsNV(), glIsProgramNV(), glLoadProgramNV() */
+
+#include <assert.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+static void Init( void )
+{
+ GLint errno;
+ GLuint prognum;
+
+ static const char *prog1 =
+ "!!ARBvp1.0\n"
+ "MOV result.color, vertex.color;\n"
+ "MOV result.position, vertex.position;\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));
+ }
+}
+
+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);
+ glColor3f(0,0,1);
+ glVertex3f( 2.0, -2.0, 0.0);
+ glColor3f(0,1,0);
+ glVertex3f( 2.0, 2.0, 0.0);
+ glColor3f(1,0,0);
+ glVertex3f(-2.0, 0.0, 0.0);
+ 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 );
+ Init();
+ glutMainLoop();
+ return 0;
+}
diff --git a/progs/trivial/vp-line-clip.c b/progs/trivial/vp-line-clip.c
new file mode 100644
index 00000000000..b2aaf17ca4f
--- /dev/null
+++ b/progs/trivial/vp-line-clip.c
@@ -0,0 +1,116 @@
+/* Test glGenProgramsNV(), glIsProgramNV(), glLoadProgramNV() */
+
+#include <assert.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+static void Init( void )
+{
+ GLint errno;
+ GLuint prognum;
+
+ static const char *prog1 =
+ "!!ARBvp1.0\n"
+ "MOV result.color, vertex.color;\n"
+ "MOV result.position, vertex.position;\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));
+ }
+}
+
+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);
+
+#if 0
+ glBegin(GL_LINES);
+ glColor3f(0,0,1);
+ glVertex3f( 0.75, -0.75, 0.0);
+ glColor3f(0,1,0);
+ glVertex3f( 0.75, 0.75, 0.0);
+
+ glColor3f(0,1,0);
+ glVertex3f( 0.75, 0.75, 0.0);
+ glColor3f(1,0,0);
+ glVertex3f(-1.75, 0.0, 0.0);
+ glEnd();
+#else
+ glBegin(GL_LINE_STRIP);
+ glColor3f(0,0,1);
+ glVertex3f( 0.75, -0.75, 0.0);
+ glColor3f(0,1,0);
+ glVertex3f( 0.75, 0.75, 0.0);
+ glColor3f(1,0,0);
+ glVertex3f(-1.75, 0.0, 0.0);
+ glEnd();
+#endif
+
+
+ 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 );
+ Init();
+ glutMainLoop();
+ return 0;
+}
diff --git a/progs/trivial/vp-tri.c b/progs/trivial/vp-tri.c
new file mode 100644
index 00000000000..f8e18654c60
--- /dev/null
+++ b/progs/trivial/vp-tri.c
@@ -0,0 +1,104 @@
+/* Test glGenProgramsNV(), glIsProgramNV(), glLoadProgramNV() */
+
+#include <assert.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+static void Init( void )
+{
+ GLint errno;
+ GLuint prognum;
+
+ static const char *prog1 =
+ "!!ARBvp1.0\n"
+ "MOV result.color, vertex.color;\n"
+/* "MOV result.color, {0,0,0,1};\n" */
+ "MOV result.position, vertex.position;\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));
+ }
+}
+
+static void Display( void )
+{
+ glClearColor(0.3, 0.3, 0.3, 1);
+ glClear( GL_COLOR_BUFFER_BIT );
+
+ glEnable(GL_VERTEX_PROGRAM_NV);
+
+ glBegin(GL_TRIANGLES);
+ glColor3f(0,0,1);
+ glVertex3f( 0.9, -0.9, 0.0);
+ glColor3f(0,1,0);
+ glVertex3f( 0.9, 0.9, 0.0);
+ glColor3f(1,0,0);
+ glVertex3f(-0.9, 0.0, 0.0);
+ 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 );
+ glutCreateWindow(argv[0]);
+ glutReshapeFunc( Reshape );
+ glutKeyboardFunc( Key );
+ glutDisplayFunc( Display );
+ Init();
+ glutMainLoop();
+ return 0;
+}
diff --git a/progs/trivial/vp-unfilled.c b/progs/trivial/vp-unfilled.c
new file mode 100644
index 00000000000..ac23181fff7
--- /dev/null
+++ b/progs/trivial/vp-unfilled.c
@@ -0,0 +1,104 @@
+/* Test glGenProgramsNV(), glIsProgramNV(), glLoadProgramNV() */
+
+#include <assert.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+static void Init( void )
+{
+ GLint errno;
+ GLuint prognum;
+
+ static const char *prog1 =
+ "!!ARBvp1.0\n"
+ "MOV result.color, vertex.color;\n"
+ "MOV result.position, vertex.position;\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));
+ }
+}
+
+static void Display( void )
+{
+ glClearColor(0.3, 0.3, 0.3, 1);
+ glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
+ glPolygonMode(GL_FRONT, GL_LINE);
+ glPolygonMode(GL_BACK, GL_POINT);
+
+ glEnable(GL_VERTEX_PROGRAM_NV);
+
+ glBegin(GL_TRIANGLES);
+ glColor3f(0,0,1);
+ glVertex3f( 0.9, -0.9, 0.0);
+ glColor3f(0,1,0);
+ glVertex3f( 0.9, 0.9, 0.0);
+ glColor3f(1,0,0);
+ glVertex3f(-0.9, 0.0, 0.0);
+ 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 );
+ Init();
+ glutMainLoop();
+ return 0;
+}
diff --git a/progs/util/README b/progs/util/README
index 8c143142e41..ca89d34bd3e 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 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 [email protected]
+
+
+.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..4c5db13ec7c 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 1999/08/19 00:55:42 jtg Exp $ */
/*
* Print GL state information (for debugging)
@@ -22,8 +22,8 @@
/*
* $Log: glstate.c,v $
- * Revision 1.1.1.1 1999/08/19 00:55:42 jtg
- * Imported sources
+ * Revision 1.1 1999/08/19 00:55:42 jtg
+ * Initial revision
*
* Revision 1.4 1999/06/19 01:36:43 brianp
* more features added
diff --git a/progs/util/glstate.h b/progs/util/glstate.h
index 75f0238c591..1aa4d21d8e8 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 1999/08/19 00:55:42 jtg Exp $ */
/*
* Print GL state information (for debugging)
@@ -22,8 +22,8 @@
/*
* $Log: glstate.h,v $
- * Revision 1.1.1.1 1999/08/19 00:55:42 jtg
- * Imported sources
+ * Revision 1.1 1999/08/19 00:55:42 jtg
+ * Initial revision
*
* Revision 1.2 1999/06/19 01:36:43 brianp
* more features added
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 <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <math.h>
+#include <assert.h>
+
+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; i<x/sizeof(unsigned int); i++)
+ SwitchEndian32(&raw->rowStart[i]);
+ for(i=0; i<x/sizeof(int); i++)
+ SwitchEndian32(&raw->rowSize[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; i<raw->header.ysize; i++)
+ {
+ switch(raw->header.zsize)
+ {
+ case 1:
+ ImageSgiRawGetRow(raw, raw->chan0, i, 0);
+ for(j=0; j<raw->header.xsize; j++)
+ *(ptr++) = raw->chan0[j];
+ break;
+ case 2:
+ ImageSgiRawGetRow(raw, raw->chan0, i, 0);
+ ImageSgiRawGetRow(raw, raw->chan1, i, 1);
+ for(j=0; j<raw->header.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; j<raw->header.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; j<raw->header.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..ebb57ff3dd6 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 1999/08/19 00:55:42 jtg Exp $
# Sample makefile for compiling OpenGL/Mesa applications on Unix.
# This example assumes Linux with gcc.
@@ -6,8 +6,8 @@
# This makefile is in the public domain
# $Log: sampleMakefile,v $
-# Revision 1.1.1.1 1999/08/19 00:55:42 jtg
-# Imported sources
+# Revision 1.1 1999/08/19 00:55:42 jtg
+# Initial revision
#
# Revision 1.1 1999/02/24 05:20:45 brianp
# Initial revision
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 <assert.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+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/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