WindML driver (Stephane Raimbault)
diff --git a/progs/windml/Makefile.ugl b/progs/windml/Makefile.ugl
new file mode 100644
index 0000000..90b0b29
--- /dev/null
+++ b/progs/windml/Makefile.ugl
@@ -0,0 +1,68 @@
+# Mesa 3-D graphics library
+# Version:  3.5
+#
+# Copyright (C) 2001 Wind River Systems, Inc
+
+# The MIT License
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the "Software"),
+# to deal in the Software without restriction, including without limitation
+# the rights to use, copy, modify, merge, publish, distribute, sublicense,
+# and/or sell copies of the Software, and to permit persons to whom the
+# Software is furnished to do so, subject to the following conditions:
+# 
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+# 
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
+# DEALINGS IN THE SOFTWARE.
+
+# Makefile for UGL/Mesa demos
+
+DEMO_SOURCES = readtex.c uglaccum.c uglalldemos.c uglbounce.c uglcube.c \
+ugldrawpix.c uglflip.c uglgears.c uglicotorus.c uglline.c uglolympic.c \
+uglpoint.c uglstencil.c uglteapot.c ugltexcube.c ugltexcyl.c
+#win2d3d/winRoot.c win2d3d/winBall.c win2d3d/winPuzzle.c win2d3d/winHello.c \
+#win2d3d/winImage.c win2d3d/winGears.c
+
+DEMO_OBJECTS = $(DEMO_SOURCES:.c=.o)
+
+SOURCES = $(DEMO_SOURCES)
+
+include ../rules.windml
+
+##### TARGETS #####
+
+all: depend.$(CPU)$(TOOL) $(DEMO_OBJECTS)
+
+depend.$(CPU)$(TOOL):
+ifeq ($(WIND_HOST_TYPE),x86-win32)
+	@ $(RM) $@
+	@ $(ECHO) Creating depend.$(CPU)$(TOOL)
+ifneq ($(SOURCES),)
+	@ for %f in ($(SOURCES)) do \
+	$(CC) -MM $(CFLAGS) %f >>$@ 
+endif
+else
+Makefile
+	@ $(RM) $@
+	@ $(ECHO) "Creating depend.$(CPU)$(TOOL)"
+ifneq ($(SOURCES),)
+	@ for FILE in $(filter-out $(NODEPENDOBJS), $(SOURCES)); \
+	do \
+	$(CC) -MM $(CFLAGS) $$FILE  \
+	| $(TCL) $(BIN_DIR)/depend.tcl $(TGT_DIR) >>$@; \
+	done	
+endif
+endif
+
+.PHONY = clean
+
+clean:
+	$(RM) $(DEMO_OBJECTS)
+	$(RM) depend.$(CPU)$(TOOL)
diff --git a/progs/windml/readtex.c b/progs/windml/readtex.c
new file mode 100644
index 0000000..659c49d
--- /dev/null
+++ b/progs/windml/readtex.c
@@ -0,0 +1,365 @@
+/* readtex.c */
+
+/*
+ * Read an SGI .rgb image file and generate a mipmap texture set.
+ * Much of this code was borrowed from SGI's tk OpenGL toolkit.
+ */
+
+#include <GL/gl.h>
+#include <GL/glu.h>
+#include <stdio.h>
+#include <stdlib.h> 
+#include <string.h>
+#include "../util/readtex.h"
+
+
+#ifndef SEEK_SET
+#  define SEEK_SET 0
+#endif
+
+
+/*
+** RGB Image Structure
+*/
+
+typedef struct _TK_RGBImageRec {
+   GLint sizeX, sizeY;
+   GLint components;
+   unsigned char *data;
+} TK_RGBImageRec;
+
+
+
+/******************************************************************************/
+
+typedef struct _rawImageRec {
+    unsigned short imagic;
+    unsigned short type;
+    unsigned short dim;
+    unsigned short sizeX, sizeY, sizeZ;
+    unsigned long min, max;
+    unsigned long wasteBytes;
+    char name[80];
+    unsigned long colorMap;
+    FILE *file;
+    unsigned char *tmp, *tmpR, *tmpG, *tmpB, *tmpA;
+    unsigned long rleEnd;
+    GLuint *rowStart;
+    GLint *rowSize;
+} rawImageRec;
+
+/******************************************************************************/
+
+static void ConvertShort(unsigned short *array, long length)
+{
+   unsigned long b1, b2;
+   unsigned char *ptr;
+
+   ptr = (unsigned char *)array;
+   while (length--) {
+      b1 = *ptr++;
+      b2 = *ptr++;
+      *array++ = (unsigned short) ((b1 << 8) | (b2));
+   }
+}
+
+static void ConvertLong(GLuint *array, long length)
+{
+   unsigned long b1, b2, b3, b4;
+   unsigned char *ptr;
+
+   ptr = (unsigned char *)array;
+   while (length--) {
+      b1 = *ptr++;
+      b2 = *ptr++;
+      b3 = *ptr++;
+      b4 = *ptr++;
+      *array++ = (b1 << 24) | (b2 << 16) | (b3 << 8) | (b4);
+   }
+}
+
+static rawImageRec *RawImageOpen(const char *fileName)
+{
+   union {
+      int testWord;
+      char testByte[4];
+   } endianTest;
+   rawImageRec *raw;
+   GLenum swapFlag;
+   int x;
+
+   endianTest.testWord = 1;
+   if (endianTest.testByte[0] == 1) {
+      swapFlag = GL_TRUE;
+   } else {
+      swapFlag = GL_FALSE;
+   }
+
+   raw = (rawImageRec *)malloc(sizeof(rawImageRec));
+   if (raw == NULL) {
+      fprintf(stderr, "Out of memory!\n");
+      return NULL;
+   }
+   if ((raw->file = fopen(fileName, "rb")) == NULL) {
+      perror(fileName);
+      return NULL;
+   }
+
+   fread(raw, 1, 12, raw->file);
+
+   if (swapFlag) {
+      ConvertShort(&raw->imagic, 6);
+   }
+
+   raw->tmp = (unsigned char *)malloc(raw->sizeX*256);
+   raw->tmpR = (unsigned char *)malloc(raw->sizeX*256);
+   raw->tmpG = (unsigned char *)malloc(raw->sizeX*256);
+   raw->tmpB = (unsigned char *)malloc(raw->sizeX*256);
+   if (raw->sizeZ==4) {
+      raw->tmpA = (unsigned char *)malloc(raw->sizeX*256);
+   }
+   if (raw->tmp == NULL || raw->tmpR == NULL || raw->tmpG == NULL ||
+       raw->tmpB == NULL) {
+      fprintf(stderr, "Out of memory!\n");
+      return NULL;
+   }
+
+   if ((raw->type & 0xFF00) == 0x0100) {
+      x = raw->sizeY * raw->sizeZ * sizeof(GLuint);
+      raw->rowStart = (GLuint *)malloc(x);
+      raw->rowSize = (GLint *)malloc(x);
+      if (raw->rowStart == NULL || raw->rowSize == NULL) {
+         fprintf(stderr, "Out of memory!\n");
+         return NULL;
+      }
+      raw->rleEnd = 512 + (2 * x);
+      fseek(raw->file, 512, SEEK_SET);
+      fread(raw->rowStart, 1, x, raw->file);
+      fread(raw->rowSize, 1, x, raw->file);
+      if (swapFlag) {
+         ConvertLong(raw->rowStart, (long) (x/sizeof(GLuint)));
+         ConvertLong((GLuint *)raw->rowSize, (long) (x/sizeof(GLint)));
+      }
+   }
+   return raw;
+}
+
+static void RawImageClose(rawImageRec *raw)
+{
+
+   fclose(raw->file);
+   free(raw->tmp);
+   free(raw->tmpR);
+   free(raw->tmpG);
+   free(raw->tmpB);
+   if (raw->sizeZ>3) {
+      free(raw->tmpA);
+   }
+   free(raw);
+}
+
+static void RawImageGetRow(rawImageRec *raw, unsigned char *buf, int y, int z)
+{
+   unsigned char *iPtr, *oPtr, pixel;
+   int count, done = 0;
+
+   if ((raw->type & 0xFF00) == 0x0100) {
+      fseek(raw->file, (long) raw->rowStart[y+z*raw->sizeY], SEEK_SET);
+      fread(raw->tmp, 1, (unsigned int)raw->rowSize[y+z*raw->sizeY],
+            raw->file);
+      
+      iPtr = raw->tmp;
+      oPtr = buf;
+      while (!done) {
+         pixel = *iPtr++;
+         count = (int)(pixel & 0x7F);
+         if (!count) {
+			 done = 1;
+            return;
+         }
+         if (pixel & 0x80) {
+            while (count--) {
+               *oPtr++ = *iPtr++;
+            }
+         } else {
+            pixel = *iPtr++;
+            while (count--) {
+               *oPtr++ = pixel;
+            }
+         }
+      }
+   } else {
+      fseek(raw->file, 512+(y*raw->sizeX)+(z*raw->sizeX*raw->sizeY),
+            SEEK_SET);
+      fread(buf, 1, raw->sizeX, raw->file);
+   }
+}
+
+
+static void RawImageGetData(rawImageRec *raw, TK_RGBImageRec *final)
+{
+   unsigned char *ptr;
+   int i, j;
+
+   final->data = (unsigned char *)malloc((raw->sizeX+1)*(raw->sizeY+1)*4);
+   if (final->data == NULL) {
+      fprintf(stderr, "Out of memory!\n");
+   }
+
+   ptr = final->data;
+   for (i = 0; i < (int)(raw->sizeY); i++) {
+      RawImageGetRow(raw, raw->tmpR, i, 0);
+      RawImageGetRow(raw, raw->tmpG, i, 1);
+      RawImageGetRow(raw, raw->tmpB, i, 2);
+      if (raw->sizeZ>3) {
+         RawImageGetRow(raw, raw->tmpA, i, 3);
+      }
+      for (j = 0; j < (int)(raw->sizeX); j++) {
+         *ptr++ = *(raw->tmpR + j);
+         *ptr++ = *(raw->tmpG + j);
+         *ptr++ = *(raw->tmpB + j);
+         if (raw->sizeZ>3) {
+            *ptr++ = *(raw->tmpA + j);
+         }
+      }
+   }
+}
+
+
+static TK_RGBImageRec *tkRGBImageLoad(const char *fileName)
+{
+   rawImageRec *raw;
+   TK_RGBImageRec *final;
+
+   raw = RawImageOpen(fileName);
+   if (!raw) {
+      fprintf(stderr, "File not found\n");
+      return NULL;
+   }
+   final = (TK_RGBImageRec *)malloc(sizeof(TK_RGBImageRec));
+   if (final == NULL) {
+      fprintf(stderr, "Out of memory!\n");
+      return NULL;
+   }
+   final->sizeX = raw->sizeX;
+   final->sizeY = raw->sizeY;
+   final->components = raw->sizeZ;
+   RawImageGetData(raw, final);
+   RawImageClose(raw);
+   return final;
+}
+
+
+static void FreeImage( TK_RGBImageRec *image )
+{
+   free(image->data);
+   free(image);
+}
+
+
+/*
+ * Load an SGI .rgb file and generate a set of 2-D mipmaps from it.
+ * Input:  imageFile - name of .rgb to read
+ *         intFormat - internal texture format to use, or number of components
+ * Return:  GL_TRUE if success, GL_FALSE if error.
+ */
+GLboolean LoadRGBMipmaps( const char *imageFile, GLint intFormat )
+{
+   GLint w, h;
+   return LoadRGBMipmaps2( imageFile, GL_TEXTURE_2D, intFormat, &w, &h );
+}
+
+
+
+GLboolean LoadRGBMipmaps2( const char *imageFile, GLenum target,
+                           GLint intFormat, GLint *width, GLint *height )
+{
+   GLint error;
+   GLenum format;
+   TK_RGBImageRec *image;
+
+   image = tkRGBImageLoad( imageFile );
+   if (!image) {
+      return GL_FALSE;
+   }
+
+   if (image->components==3) {
+      format = GL_RGB;
+   }
+   else if (image->components==4) {
+      format = GL_RGBA;
+   }
+   else {
+      /* not implemented */
+      fprintf(stderr,
+              "Error in LoadRGBMipmaps %d-component images not implemented\n",
+              image->components );
+      return GL_FALSE;
+   }
+
+   error = gluBuild2DMipmaps( target,
+                              intFormat,
+                              image->sizeX, image->sizeY,
+                              format,
+                              GL_UNSIGNED_BYTE,
+                              image->data );
+
+   *width = image->sizeX;
+   *height = image->sizeY;
+
+   FreeImage(image);
+
+   return error ? GL_FALSE : GL_TRUE;
+}
+
+
+
+/*
+ * Load an SGI .rgb file and return a pointer to the image data.
+ * Input:  imageFile - name of .rgb to read
+ * Output:  width - width of image
+ *          height - height of image
+ *          format - format of image (GL_RGB or GL_RGBA)
+ * Return:  pointer to image data or NULL if error
+ */
+GLubyte *LoadRGBImage( const char *imageFile, GLint *width, GLint *height,
+                       GLenum *format )
+{
+   TK_RGBImageRec *image;
+   GLint bytes;
+   GLubyte *buffer;
+
+   image = tkRGBImageLoad( imageFile );
+   if (!image) {
+      return NULL;
+   }
+
+   if (image->components==3) {
+      *format = GL_RGB;
+   }
+   else if (image->components==4) {
+      *format = GL_RGBA;
+   }
+   else {
+      /* not implemented */
+      fprintf(stderr,
+              "Error in LoadRGBImage %d-component images not implemented\n",
+              image->components );
+      return NULL;
+   }
+
+   *width = image->sizeX;
+   *height = image->sizeY;
+
+   bytes = image->sizeX * image->sizeY * image->components;
+   buffer = (GLubyte *) malloc(bytes);
+   if (!buffer)
+      return NULL;
+
+   memcpy( (void *) buffer, (void *) image->data, bytes );
+
+   FreeImage(image);
+
+   return buffer;
+}
+
diff --git a/progs/windml/uglaccum.c b/progs/windml/uglaccum.c
new file mode 100644
index 0000000..4748618
--- /dev/null
+++ b/progs/windml/uglaccum.c
@@ -0,0 +1,240 @@
+
+/* Copyright (c) Mark J. Kilgard, 1994. */
+
+/*
+ * (c) Copyright 1993, Silicon Graphics, Inc.
+ * ALL RIGHTS RESERVED
+ * Permission to use, copy, modify, and distribute this software for
+ * any purpose and without fee is hereby granted, provided that the above
+ * copyright notice appear in all copies and that both the copyright notice
+ * and this permission notice appear in supporting documentation, and that
+ * the name of Silicon Graphics, Inc. not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission.
+ *
+ * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
+ * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
+ * FITNESS FOR A PARTICULAR PURPOSE.  IN NO EVENT SHALL SILICON
+ * GRAPHICS, INC.  BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
+ * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
+ * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
+ * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
+ * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC.  HAS BEEN
+ * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
+ * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * US Government Users Restricted Rights
+ * Use, duplication, or disclosure by the Government is subject to
+ * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
+ * (c)(1)(ii) of the Rights in Technical Data and Computer Software
+ * clause at DFARS 252.227-7013 and/or in similar or successor
+ * clauses in the FAR or the DOD or NASA FAR Supplement.
+ * Unpublished-- rights reserved under the copyright laws of the
+ * United States.  Contractor/manufacturer is Silicon Graphics,
+ * Inc., 2011 N.  Shoreline Blvd., Mountain View, CA 94039-7311.
+ *
+ * OpenGL(TM) is a trademark of Silicon Graphics, Inc.
+ */
+
+/*  Original name: accanti.c
+ *
+ *  Conversion to UGL/Mesa by Stephane Raimbault
+ */
+
+#include <stdio.h>
+#include <math.h>
+
+#include <ugl/ugl.h>
+#include <ugl/uglevent.h>
+#include <ugl/uglinput.h>
+
+#include <GL/uglmesa.h>
+#include <GL/uglglutshapes.h>
+
+#include "../book/jitter.h"
+
+UGL_LOCAL UGL_EVENT_SERVICE_ID eventServiceId;
+UGL_LOCAL UGL_EVENT_Q_ID qId;
+UGL_LOCAL UGL_MESA_CONTEXT umc;
+
+/*  Initialize lighting and other values.
+ */
+UGL_LOCAL void initGL(GLsizei w, GLsizei h)
+    {
+    GLfloat mat_ambient[] = { 1.0, 1.0, 1.0, 1.0 };
+    GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 };
+    GLfloat light_position[] = { 0.0, 0.0, 10.0, 1.0 };
+    GLfloat lm_ambient[] = { 0.2, 0.2, 0.2, 1.0 };
+
+    glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient);
+    glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
+    glMaterialf(GL_FRONT, GL_SHININESS, 50.0);
+    glLightfv(GL_LIGHT0, GL_POSITION, light_position);
+    glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lm_ambient);
+
+    glEnable(GL_LIGHTING);
+    glEnable(GL_LIGHT0);
+    glDepthFunc(GL_LESS);
+    glEnable(GL_DEPTH_TEST);
+    glShadeModel (GL_FLAT);
+
+    glClearColor(0.0, 0.0, 0.0, 0.0);
+    glClearAccum(0.0, 0.0, 0.0, 0.0);
+    
+    glMatrixMode(GL_PROJECTION);
+    glLoadIdentity();
+    if (w <= h)
+	    glOrtho (-2.25, 2.25, -2.25*h/w, 2.25*h/w, -10.0, 10.0);
+    else
+	    glOrtho (-2.25*w/h, 2.25*w/h, -2.25, 2.25, -10.0, 10.0);
+    glMatrixMode(GL_MODELVIEW);
+    }
+
+UGL_LOCAL void displayObjects(void)
+    {
+    GLfloat torus_diffuse[] = { 0.7, 0.7, 0.0, 1.0 };
+    GLfloat cube_diffuse[] = { 0.0, 0.7, 0.7, 1.0 };
+    GLfloat sphere_diffuse[] = { 0.7, 0.0, 0.7, 1.0 };
+    GLfloat octa_diffuse[] = { 0.7, 0.4, 0.4, 1.0 };
+
+    glPushMatrix ();
+    glRotatef (30.0, 1.0, 0.0, 0.0);
+
+    glPushMatrix ();
+    glTranslatef (-0.80, 0.35, 0.0);
+    glRotatef (100.0, 1.0, 0.0, 0.0);
+    glMaterialfv(GL_FRONT, GL_DIFFUSE, torus_diffuse);
+    glutSolidTorus (0.275, 0.85, 16, 16);
+    glPopMatrix ();
+
+    glPushMatrix ();
+    glTranslatef (-0.75, -0.50, 0.0);
+    glRotatef (45.0, 0.0, 0.0, 1.0);
+    glRotatef (45.0, 1.0, 0.0, 0.0);
+    glMaterialfv(GL_FRONT, GL_DIFFUSE, cube_diffuse);
+    glutSolidCube (1.5);
+    glPopMatrix ();
+
+    glPushMatrix ();
+    glTranslatef (0.75, 0.60, 0.0);
+    glRotatef (30.0, 1.0, 0.0, 0.0);
+    glMaterialfv(GL_FRONT, GL_DIFFUSE, sphere_diffuse);
+    glutSolidSphere (1.0, 16, 16);
+    glPopMatrix ();
+
+    glPushMatrix ();
+    glTranslatef (0.70, -0.90, 0.25);
+    glMaterialfv(GL_FRONT, GL_DIFFUSE, octa_diffuse);
+    glutSolidOctahedron ();
+    glPopMatrix ();
+
+    glPopMatrix ();
+    }
+
+#define ACSIZE	8
+
+UGL_LOCAL void drawGL(void)
+    {
+    GLint viewport[4];
+    int jitter;
+
+    glGetIntegerv (GL_VIEWPORT, viewport);
+
+    glClear(GL_ACCUM_BUFFER_BIT);
+    for (jitter = 0; jitter < ACSIZE; jitter++)
+	{
+	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+	glPushMatrix ();
+/*	Note that 4.5 is the distance in world space between
+ *	left and right and bottom and top.
+ *	This formula converts fractional pixel movement to
+ *	world coordinates.
+ */
+	glTranslatef (j8[jitter].x*4.5/viewport[2],
+		      j8[jitter].y*4.5/viewport[3], 0.0);
+	displayObjects ();
+	glPopMatrix ();
+	glAccum(GL_ACCUM, 1.0/ACSIZE);
+	}
+    glAccum (GL_RETURN, 1.0);
+    glFlush();
+
+    uglMesaSwapBuffers();
+    }
+
+UGL_LOCAL int getEvent(void)
+    {
+    UGL_EVENT event;
+    UGL_STATUS status;
+    int retVal = 0;
+
+    status = uglEventGet (qId, &event, sizeof (event), UGL_NO_WAIT);
+
+    while (status != UGL_STATUS_Q_EMPTY)
+        {
+	UGL_INPUT_EVENT * pInputEvent = (UGL_INPUT_EVENT *)&event;
+	
+	if (pInputEvent->modifiers & UGL_KEYBOARD_KEYDOWN)
+	    retVal = 1;
+
+	status = uglEventGet (qId, &event, sizeof (event), UGL_NO_WAIT);
+        }
+ 
+    return(retVal);
+    }
+
+void windMLAccum (void);
+
+void uglaccum (void)
+    {
+    taskSpawn("tAccum", 210, VX_FP_TASK, 100000,
+	      (FUNCPTR)windMLAccum, 0,1,2,3,4,5,6,7,8,9);
+    }
+
+void windMLAccum(void)
+    {
+    UGL_INPUT_DEVICE_ID keyboardDevId;
+    GLsizei width, height;
+    
+    uglInitialize();
+    
+    uglDriverFind (UGL_KEYBOARD_TYPE, 0, (UGL_UINT32 *)&keyboardDevId);
+    
+    uglDriverFind (UGL_EVENT_SERVICE_TYPE, 0, (UGL_UINT32 *)&eventServiceId);
+	    
+    qId = uglEventQCreate (eventServiceId, 100);
+    
+    umc = uglMesaCreateNewContextExt(GL_TRUE,
+				     16,
+				     0,
+				     8,8,8,0,
+				     NULL);
+    if (umc == NULL)
+	{
+	uglDeinitialize();
+	return;
+	}
+
+    /* Fullscreen */
+
+    uglMesaMakeCurrentContext(umc, 0, 0,
+			      UGL_MESA_FULLSCREEN_WIDTH,
+			      UGL_MESA_FULLSCREEN_HEIGHT);
+
+    uglMesaGetIntegerv(UGL_MESA_WIDTH, &width);
+    uglMesaGetIntegerv(UGL_MESA_HEIGHT, &height);
+
+    initGL(width, height);
+
+    while (!getEvent())
+	    drawGL();
+    
+    uglEventQDestroy (eventServiceId, qId);
+    
+    uglMesaDestroyContext();
+    uglDeinitialize();
+    
+    return;
+    }
diff --git a/progs/windml/uglalldemos.c b/progs/windml/uglalldemos.c
new file mode 100644
index 0000000..ebb2f27
--- /dev/null
+++ b/progs/windml/uglalldemos.c
@@ -0,0 +1,98 @@
+
+/* uglalldemos.c - WindML/Mesa example program */
+
+/* Copyright (C) 2001 by Wind River Systems, Inc */
+
+/*
+ * Mesa 3-D graphics library
+ * Version:  3.5
+ *
+ * The MIT License
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+/*
+modification history
+--------------------
+01a,17jul01,sra  written
+*/
+
+/*
+DESCRIPTION
+Show all the UGL/Mesa demos
+*/
+
+#include <vxWorks.h>
+#include <taskLib.h>
+
+void windMLPoint (void);
+void windMLLine (void);
+void windMLFlip (void);
+void windMLCube (void);
+void windMLBounce (void);
+void windMLGears (void);
+void windMLIcoTorus (void);
+void windMLOlympic (void);
+void windMLTexCube (void);
+void windMLTexCyl (void);
+void windMLTeapot (void);
+void windMLStencil (void);
+void windMLDrawPix (void);
+void windMLAccum (void);
+void windMLAllDemos (void);
+
+void uglalldemos (void)
+    {
+    taskSpawn("tAllDemos", 210, VX_FP_TASK, 200000,
+	      (FUNCPTR)windMLAllDemos, 0,1,2,3,4,5,6,7,8,9);
+    }
+
+void windMLAllDemos(void)
+    {
+
+    windMLPoint();
+
+    windMLLine();
+    
+    windMLFlip();
+
+    windMLCube();
+
+    windMLBounce();
+
+    windMLGears();
+
+    windMLIcoTorus();
+
+    windMLOlympic();
+
+    windMLTexCube();
+    
+    windMLTexCyl();
+
+    windMLTeapot();
+
+    windMLStencil();
+
+    windMLDrawPix();
+
+    windMLAccum();
+
+    return;
+    }
diff --git a/progs/windml/uglbounce.c b/progs/windml/uglbounce.c
new file mode 100644
index 0000000..bcabf44
--- /dev/null
+++ b/progs/windml/uglbounce.c
@@ -0,0 +1,268 @@
+/*
+ * Bouncing ball demo.
+ *
+ * This program is in the public domain
+ *
+ * Brian Paul
+ *
+ * Conversion to GLUT by Mark J. Kilgard
+ *
+ * Conversion to UGL/Mesa by Stephane Raimbault
+ */
+
+#include <math.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <ugl/ugl.h>
+#include <ugl/uglevent.h>
+#include <ugl/uglinput.h>
+
+#include <GL/uglmesa.h>
+
+#define COS(X)   cos( (X) * 3.14159/180.0 )
+#define SIN(X)   sin( (X) * 3.14159/180.0 )
+
+#define RED 1
+#define WHITE 2
+#define CYAN 3
+
+UGL_LOCAL UGL_EVENT_SERVICE_ID eventServiceId;
+UGL_LOCAL UGL_EVENT_Q_ID qId;
+UGL_LOCAL UGL_MESA_CONTEXT umc;
+
+UGL_LOCAL GLuint Ball;
+UGL_LOCAL GLfloat Zrot, Zstep;
+UGL_LOCAL GLfloat Xpos, Ypos;
+UGL_LOCAL GLfloat Xvel, Yvel;
+UGL_LOCAL GLfloat Xmin, Xmax;
+UGL_LOCAL GLfloat Ymin;
+/* UGL_LOCAL GLfloat Ymax = 4.0; */
+UGL_LOCAL GLfloat G;
+
+UGL_LOCAL GLuint make_ball(void)
+    {
+    GLuint list;
+    GLfloat a, b;
+    GLfloat da = 18.0, db = 18.0;
+    GLfloat radius = 1.0;
+    GLuint color;
+    GLfloat x, y, z;
+    
+    list = glGenLists(1);
+    
+    glNewList(list, GL_COMPILE);
+    
+    color = 0;
+    for (a = -90.0; a + da <= 90.0; a += da)
+	{
+	glBegin(GL_QUAD_STRIP);
+	for (b = 0.0; b <= 360.0; b += db)
+	    {
+	    if (color)
+		{
+		glIndexi(RED);
+		glColor3f(1, 0, 0);
+		}
+	    else
+		{
+		glIndexi(WHITE);
+		glColor3f(1, 1, 1);
+		}
+
+	    x = radius * COS(b) * COS(a);
+	    y = radius * SIN(b) * COS(a);
+	    z = radius * SIN(a);
+	    glVertex3f(x, y, z);
+	    
+	    x = radius * COS(b) * COS(a + da);
+	    y = radius * SIN(b) * COS(a + da);
+	    z = radius * SIN(a + da);
+	    glVertex3f(x, y, z);
+	    
+	    color = 1 - color;
+	    }
+	glEnd();
+	
+	}
+    
+    glEndList();
+    
+    return list;
+    }
+
+UGL_LOCAL void initGL(GLsizei width, GLsizei height)
+    {
+    float aspect = (float) width / (float) height;
+    glViewport(0, 0, (GLint) width, (GLint) height);
+
+    uglMesaSetColor(RED, 1.0, 0.0, 0.0);
+    uglMesaSetColor(WHITE, 1.0, 1.0, 1.0);
+    uglMesaSetColor(CYAN, 0.0, 1.0, 1.0);
+    
+    glMatrixMode(GL_PROJECTION);
+    glLoadIdentity();
+    glOrtho(-6.0 * aspect, 6.0 * aspect, -6.0, 6.0, -6.0, 6.0);
+    glMatrixMode(GL_MODELVIEW);
+
+    }
+
+UGL_LOCAL void drawGL(void)
+    {
+    GLint i;
+    static float vel0 = -100.0;
+    
+    glClear(GL_COLOR_BUFFER_BIT);
+    
+    glIndexi(CYAN);
+    glColor3f(0, 1, 1);
+    glBegin(GL_LINES);
+    for (i = -5; i <= 5; i++)
+	{
+	glVertex2i(i, -5);
+	glVertex2i(i, 5);
+	}
+    for (i = -5; i <= 5; i++)
+	{
+	glVertex2i(-5, i);
+	glVertex2i(5, i);
+	}
+    for (i = -5; i <= 5; i++)
+	{
+	glVertex2i(i, -5);
+	glVertex2f(i * 1.15, -5.9);
+	}
+    glVertex2f(-5.3, -5.35);
+    glVertex2f(5.3, -5.35);
+    glVertex2f(-5.75, -5.9);
+    glVertex2f(5.75, -5.9);
+    glEnd();
+    
+    glPushMatrix();
+    glTranslatef(Xpos, Ypos, 0.0);
+    glScalef(2.0, 2.0, 2.0);
+    glRotatef(8.0, 0.0, 0.0, 1.0);
+    glRotatef(90.0, 1.0, 0.0, 0.0);
+    glRotatef(Zrot, 0.0, 0.0, 1.0);
+    
+    glCallList(Ball);
+    
+    glPopMatrix();
+
+    glFlush();
+    
+    uglMesaSwapBuffers();
+    
+    Zrot += Zstep;
+    
+    Xpos += Xvel;
+    if (Xpos >= Xmax)
+	{
+	Xpos = Xmax;
+	Xvel = -Xvel;
+	Zstep = -Zstep;
+	}
+    if (Xpos <= Xmin)
+	{
+	Xpos = Xmin;
+	Xvel = -Xvel;
+	Zstep = -Zstep;
+	}
+    Ypos += Yvel;
+    Yvel += G;
+    if (Ypos < Ymin)
+	{
+	Ypos = Ymin;
+	if (vel0 == -100.0)
+	    vel0 = fabs(Yvel);
+	Yvel = vel0;
+	}
+    }
+
+UGL_LOCAL int getEvent(void)
+    {
+    UGL_EVENT event;
+    UGL_STATUS status;
+    int retVal = 0;
+
+    status = uglEventGet (qId, &event, sizeof (event), UGL_NO_WAIT);
+
+    while (status != UGL_STATUS_Q_EMPTY)
+        {
+	UGL_INPUT_EVENT * pInputEvent = (UGL_INPUT_EVENT *)&event;
+	
+	if (pInputEvent->modifiers & UGL_KEYBOARD_KEYDOWN)
+	    retVal = 1;
+
+	status = uglEventGet (qId, &event, sizeof (event), UGL_NO_WAIT);
+        }
+ 
+    return(retVal);
+    }
+
+void windMLBounce (void);
+
+void uglbounce (void)
+    {
+    taskSpawn("tBounce", 210, VX_FP_TASK, 100000, (FUNCPTR)windMLBounce,
+              0,1,2,3,4,5,6,7,8,9);
+    }
+
+void windMLBounce(void)
+    {
+    GLsizei width, height;
+    UGL_INPUT_DEVICE_ID keyboardDevId;
+
+    Zrot = 0.0;
+    Zstep = 6.0;
+    Xpos = 0.0;
+    Ypos = 1.0;
+    Xvel = 0.2;
+    Yvel = 0.0;
+    Xmin = -4.0;
+    Xmax = 4.0;
+    Ymin = -3.8;
+    G = -0.1;
+
+    uglInitialize();
+   
+    uglDriverFind (UGL_KEYBOARD_TYPE, 0, (UGL_UINT32 *)&keyboardDevId);
+    
+    uglDriverFind (UGL_EVENT_SERVICE_TYPE, 0, (UGL_UINT32 *)&eventServiceId);
+   
+    qId = uglEventQCreate (eventServiceId, 100);
+    
+    umc = uglMesaCreateNewContext(UGL_MESA_DOUBLE, NULL);
+    
+    if (umc == NULL)
+	{
+	uglDeinitialize();
+	return;
+	}
+
+    /* Fullscreen */
+
+    uglMesaMakeCurrentContext(umc, 0, 0, UGL_MESA_FULLSCREEN_WIDTH,
+			      UGL_MESA_FULLSCREEN_HEIGHT);
+    
+    Ball = make_ball();
+    glCullFace(GL_BACK);
+    glEnable(GL_CULL_FACE);
+    glDisable(GL_DITHER);
+    glShadeModel(GL_FLAT);
+    
+    uglMesaGetIntegerv(UGL_MESA_WIDTH, &width);
+    uglMesaGetIntegerv(UGL_MESA_HEIGHT, &height);
+    
+    initGL(width, height);
+    
+    while(!getEvent())
+	drawGL();
+
+    uglEventQDestroy (eventServiceId, qId);
+
+    uglMesaDestroyContext();
+    uglDeinitialize ();
+    
+    return;
+    }
diff --git a/progs/windml/uglcube.c b/progs/windml/uglcube.c
new file mode 100644
index 0000000..9080ba1
--- /dev/null
+++ b/progs/windml/uglcube.c
@@ -0,0 +1,253 @@
+/* uglcube.c - WindML/Mesa example program */
+
+/* Copyright (C) 2001 by Wind River Systems, Inc */
+
+/*
+ * Mesa 3-D graphics library
+ * Version:  3.5
+ *
+ * The MIT License
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+/*
+DESCRIPTION
+Draw a smooth cube.
+*/
+
+#include <stdio.h>
+#include <math.h>
+
+#include <ugl/uglevent.h>
+#include <ugl/uglinput.h>
+
+#include <GL/uglmesa.h>
+#include <GL/glu.h>
+
+UGL_LOCAL UGL_EVENT_SERVICE_ID eventServiceId;
+UGL_LOCAL UGL_EVENT_Q_ID qId;
+UGL_LOCAL UGL_MESA_CONTEXT umc;
+UGL_LOCAL GLfloat rotx;
+UGL_LOCAL GLfloat roty;
+UGL_LOCAL GLuint theCube;
+
+UGL_LOCAL void cube()
+    {
+
+    /* Front */ 
+    glBegin(GL_QUADS);
+    glColor3f(0.0f, 0.0f, 1.0f);
+    glVertex3f(-1.0f, 1.0f, 1.0f);
+    glColor3f(0.0f, 1.0f, 0.0f);
+    glVertex3f(1.0f, 1.0f, 1.0f);
+    glColor3f(1.0f, 0.0f, 0.0f);
+    glVertex3f(1.0f, -1.0f, 1.0f);
+    glColor3f(1.0f, 1.0f, 0.0f);
+    glVertex3f(-1.0f, -1.0f, 1.0f);
+    glEnd();
+    
+	    
+    /* Back */ 
+    glBegin(GL_QUADS);
+    glColor3f(0.0f, 0.0f, 1.0f);
+    glVertex3f(-1.0f, 1.0f, -1.0f);
+    glColor3f(0.0f, 1.0f, 0.0f);
+    glVertex3f(1.0f, 1.0f, -1.0f);
+    glColor3f(1.0f, 0.0f, 0.0f);
+    glVertex3f(1.0f, -1.0f, -1.0f);
+    glColor3f(1.0f, 1.0f, 0.0f);
+    glVertex3f(-1.0f, -1.0f, -1.0f);
+    glEnd();
+    
+    
+    /* Right */ 
+    glBegin(GL_QUADS);
+    glColor3f(0.0f, 1.0f, 0.0f);
+    glVertex3f(1.0f, 1.0f, 1.0f);
+    glColor3f(0.0f, 1.0f, 0.0f);
+    glVertex3f(1.0f, 1.0f, -1.0f);
+    glColor3f(1.0f, 0.0f, 0.0f);
+    glVertex3f(1.0f, -1.0f, -1.0f);
+    glColor3f(1.0f, 0.0f, 0.0f);
+    glVertex3f(1.0f, -1.0f, 1.0f);
+    glEnd();
+    
+    /* Left */ 
+    glBegin(GL_QUADS);
+    glColor3f(0.0f, 0.0f, 1.0f);
+    glVertex3f(-1.0f, 1.0f, 1.0f);
+    glColor3f(0.0f, 0.0f, 1.0f);
+    glVertex3f(-1.0f, 1.0f, -1.0f);
+    glColor3f(1.0f, 1.0f, 0.0f);
+    glVertex3f(-1.0f, -1.0f, -1.0f);
+    glColor3f(1.0f, 1.0f, 0.0f);
+    glVertex3f(-1.0f, -1.0f, 1.0f);
+    glEnd();
+    
+    /* Top */ 
+    glBegin(GL_QUADS);
+    glColor3f(0.0f, 0.0f, 1.0f);
+    glVertex3f(-1.0f, 1.0f, -1.0f);
+    glColor3f(0.0f, 1.0f, 0.0f);
+    glVertex3f(1.0f, 1.0f, -1.0f);
+    glColor3f(0.0f, 1.0f, 0.0f);
+    glVertex3f(1.0f, 1.0f, 1.0f);
+    glColor3f(0.0f, 0.0f, 1.0f);
+    glVertex3f(-1.0f, 1.0f, 1.0f);
+    glEnd();
+    
+	    
+    /* Bottom */ 
+    glBegin(GL_QUADS);
+    glColor3f(1.0f, 1.0f, 0.0f);
+    glVertex3f(-1.0f, -1.0f, -1.0f);
+    glColor3f(1.0f, 0.0f, 0.0f);
+    glVertex3f(1.0f, -1.0f, -1.0f);
+    glColor3f(1.0f, 0.0f, 0.0f);
+    glVertex3f(1.0f, -1.0f, 1.0f);
+    glColor3f(1.0f, 1.0f, 0.0f);
+    glVertex3f(-1.0f, -1.0f, 1.0f);
+    glEnd();	
+    }
+
+UGL_LOCAL void initGL
+    (
+    int Width,
+    int Height
+    ) 
+    {
+    glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
+    glDepthFunc(GL_LESS);
+    glEnable(GL_DEPTH_TEST);
+    glShadeModel(GL_SMOOTH);
+
+    theCube = glGenLists(1);
+    glNewList(theCube, GL_COMPILE);
+    cube();
+    glEndList();
+    
+    glMatrixMode(GL_PROJECTION);
+    glLoadIdentity();
+    gluPerspective(45.0f, (GLfloat) Width / (GLfloat) Height, 0.1f, 100.0f);
+    glMatrixMode(GL_MODELVIEW);
+    glLoadIdentity();
+    glTranslatef(0.0f, 0.0f, -6.0f);
+    } 
+
+
+/* The main drawing function. */ 
+
+UGL_LOCAL void drawGL() 
+    {
+
+    /* Clear The Screen And The Depth Buffer */
+
+    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+    /* Rotate the cube */
+    
+    glRotatef(rotx, 1.0f, 0.0f, 0.0f);
+    glRotatef(roty, 0.0f, 1.0f, 0.0f);
+    
+    glCallList(theCube);    
+
+    glFlush();
+
+    uglMesaSwapBuffers();
+    }
+
+
+/* The function called whenever a key is pressed. */ 
+
+UGL_LOCAL int getEvent(void)
+    {
+    UGL_EVENT event;
+    UGL_STATUS status;
+    int retVal = 0;
+    
+    status = uglEventGet (qId, &event, sizeof (event), UGL_NO_WAIT);
+
+    while (status != UGL_STATUS_Q_EMPTY)
+        {
+	UGL_INPUT_EVENT * pInputEvent = (UGL_INPUT_EVENT *)&event;
+	
+	if (pInputEvent->modifiers & UGL_KEYBOARD_KEYDOWN)
+	    retVal = 1;
+
+	status = uglEventGet (qId, &event, sizeof (event), UGL_NO_WAIT);
+        }
+ 
+    return(retVal);
+    }
+
+void windMLCube (void);
+
+void uglcube (void)
+    {
+    taskSpawn("tCube", 210, VX_FP_TASK, 100000, (FUNCPTR)windMLCube,
+              0,1,2,3,4,5,6,7,8,9);
+    }
+
+void windMLCube (void)
+    {    
+    GLsizei width, height;
+    UGL_INPUT_DEVICE_ID keyboardDevId;
+
+    rotx = 2.5f;
+    roty = 1.0f;
+    
+    uglInitialize();
+    
+    uglDriverFind (UGL_KEYBOARD_TYPE, 0, (UGL_UINT32 *)&keyboardDevId);
+    
+    if (uglDriverFind (UGL_EVENT_SERVICE_TYPE, 0,
+                       (UGL_UINT32 *)&eventServiceId) == UGL_STATUS_OK)
+        {
+        qId = uglEventQCreate (eventServiceId, 100);
+        }
+    else 
+        {
+        eventServiceId = UGL_NULL;
+        }
+
+    umc = uglMesaCreateNewContext(UGL_MESA_DOUBLE, NULL);
+
+    /* Fullscreen */
+
+    uglMesaMakeCurrentContext(umc, 0, 0, UGL_MESA_FULLSCREEN_WIDTH,
+			      UGL_MESA_FULLSCREEN_HEIGHT);
+    
+    uglMesaGetIntegerv(UGL_MESA_WIDTH, &width);
+    uglMesaGetIntegerv(UGL_MESA_HEIGHT, &height);
+
+    /* Initialize our window. */ 
+
+    initGL(width, height);
+
+    while (!getEvent())
+	drawGL();
+    
+    if (eventServiceId != UGL_NULL)
+	uglEventQDestroy (eventServiceId, qId);
+    
+    uglMesaDestroyContext();
+    uglDeinitialize();
+
+    return;
+    }
diff --git a/progs/windml/ugldrawpix.c b/progs/windml/ugldrawpix.c
new file mode 100644
index 0000000..678f423
--- /dev/null
+++ b/progs/windml/ugldrawpix.c
@@ -0,0 +1,429 @@
+/*
+ * glDrawPixels demo/test/benchmark
+ * 
+ * Brian Paul   September 25, 1997  This file is in the public domain.
+ *
+ * Conversion to UGL/Mesa by Stephane Raimbault july, 2001
+ */
+
+/*
+ * $Log: ugldrawpix.c,v $
+ * Revision 1.1  2001/08/20 16:07:11  brianp
+ * WindML driver (Stephane Raimbault)
+ *
+ * Revision 1.5  2000/12/24 22:53:54  pesco
+ * * demos/Makefile.am (INCLUDES): Added -I$(top_srcdir)/util.
+ * * demos/Makefile.X11, demos/Makefile.BeOS-R4, demos/Makefile.cygnus:
+ * Essentially the same.
+ * Program files updated to include "readtex.c", not "../util/readtex.c".
+ * * demos/reflect.c: Likewise for "showbuffer.c".
+ *
+ *
+ * * Makefile.am (EXTRA_DIST): Added top-level regular files.
+ *
+ * * include/GL/Makefile.am (INC_X11): Added glxext.h.
+ *
+ *
+ * * src/GGI/include/ggi/mesa/Makefile.am (EXTRA_HEADERS): Include
+ * Mesa GGI headers in dist even if HAVE_GGI is not given.
+ *
+ * * configure.in: Look for GLUT and demo source dirs in $srcdir.
+ *
+ * * src/swrast/Makefile.am (libMesaSwrast_la_SOURCES): Set to *.[ch].
+ * More source list updates in various Makefile.am's.
+ *
+ * * Makefile.am (dist-hook): Remove CVS directory from distribution.
+ * (DIST_SUBDIRS): List all possible subdirs here.
+ * (SUBDIRS): Only list subdirs selected for build again.
+ * The above two applied to all subdir Makefile.am's also.
+ *
+ * Revision 1.4  2000/09/08 21:45:21  brianp
+ * added dither key option
+ *
+ * Revision 1.3  1999/10/28 18:23:29  brianp
+ * minor changes to Usage() function
+ *
+ * Revision 1.2  1999/10/21 22:13:58  brianp
+ * added f key to toggle front/back drawing
+ *
+ * Revision 1.1.1.1  1999/08/19 00:55:40  jtg
+ * Imported sources
+ *
+ * Revision 3.3  1999/03/28 18:18:33  brianp
+ * minor clean-up
+ *
+ * Revision 3.2  1998/11/05 04:34:04  brianp
+ * moved image files to ../images/ directory
+ *
+ * Revision 3.1  1998/02/22 16:43:17  brianp
+ * added a few casts to silence compiler warnings
+ *
+ * Revision 3.0  1998/02/14 18:42:29  brianp
+ * initial rev
+ *
+ */
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <tickLib.h>
+
+#include <ugl/ugl.h>
+#include <ugl/uglucode.h>
+#include <ugl/uglevent.h>
+#include <ugl/uglinput.h>
+
+#include <GL/uglmesa.h>
+#include <GL/glu.h>
+
+#include "../util/readtex.h"
+
+#define IMAGE_FILE "Mesa/images/girl.rgb"
+
+UGL_LOCAL UGL_EVENT_SERVICE_ID eventServiceId;
+UGL_LOCAL UGL_EVENT_Q_ID qId;
+UGL_LOCAL volatile UGL_BOOL stopWex;
+UGL_LOCAL UGL_MESA_CONTEXT umc;
+
+UGL_LOCAL int ImgWidth, ImgHeight;
+UGL_LOCAL GLenum ImgFormat;
+UGL_LOCAL GLubyte *Image;
+
+UGL_LOCAL int Xpos, Ypos;
+UGL_LOCAL int SkipPixels, SkipRows;
+UGL_LOCAL int DrawWidth, DrawHeight;
+UGL_LOCAL float Xzoom, Yzoom;
+UGL_LOCAL GLboolean Scissor;
+UGL_LOCAL GLboolean DrawFront;
+UGL_LOCAL GLboolean Dither;
+
+UGL_LOCAL void cleanUp (void);
+
+UGL_LOCAL void reset(void)
+    {
+    Xpos = Ypos = 20;
+    DrawWidth = ImgWidth;
+    DrawHeight = ImgHeight;
+    SkipPixels = SkipRows = 0;
+    Scissor = GL_FALSE;
+    Xzoom = Yzoom = 1.0;
+    }
+
+UGL_LOCAL void initGL(GLboolean ciMode, GLsizei width, GLsizei height)
+    {
+    printf("GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
+    printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+    printf("GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
+    
+    Image = LoadRGBImage(IMAGE_FILE, &ImgWidth, &ImgHeight, &ImgFormat);
+    if (!Image)
+	{
+	printf("Couldn't read %s\n", IMAGE_FILE);
+	cleanUp();
+	exit(1);
+	}
+    
+    glScissor(width/4, height/4, width/2, height/2);
+
+    if (ciMode)
+	{
+	/* Convert RGB image to grayscale */
+	GLubyte *indexImage = malloc( ImgWidth * ImgHeight );
+	GLint i;
+	for (i=0; i<ImgWidth*ImgHeight; i++)
+	    {
+	    int gray = Image[i*3] + Image[i*3+1] + Image[i*3+2];
+	    indexImage[i] = gray / 3;
+	    }
+	free(Image);
+	Image = indexImage;
+	ImgFormat = GL_COLOR_INDEX;
+
+	for (i=0;i<255;i++)
+	    {
+	    float g = i / 255.0;
+	    uglMesaSetColor(i, g, g, g);
+	    }
+	}
+    
+    printf("Loaded %d by %d image\n", ImgWidth, ImgHeight );
+
+    glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+    glPixelStorei(GL_UNPACK_ROW_LENGTH, ImgWidth);
+
+    reset();
+    
+    glViewport( 0, 0, width, height );
+    glMatrixMode( GL_PROJECTION );
+    glLoadIdentity();
+    glOrtho( 0.0, width, 0.0, height, -1.0, 1.0 );
+    glMatrixMode( GL_MODELVIEW );
+    glLoadIdentity();   
+    }
+
+UGL_LOCAL void drawGL(void)
+    {
+    glClear(GL_COLOR_BUFFER_BIT);
+
+    /* This allows negative raster positions: */
+    glRasterPos2i(0, 0);
+    glBitmap(0, 0, 0, 0, Xpos, Ypos, NULL);
+
+    glPixelStorei(GL_UNPACK_SKIP_PIXELS, SkipPixels);
+    glPixelStorei(GL_UNPACK_SKIP_ROWS, SkipRows);
+
+    glPixelZoom( Xzoom, Yzoom );
+
+    if (Scissor)
+	    glEnable(GL_SCISSOR_TEST);
+
+    glDrawPixels(DrawWidth, DrawHeight, ImgFormat, GL_UNSIGNED_BYTE, Image);
+
+    glDisable(GL_SCISSOR_TEST);
+
+    uglMesaSwapBuffers();
+    }
+
+
+UGL_LOCAL void benchmark( void )
+    {
+    int startTick, endTick, ticksBySec;
+    int draws;
+    double seconds, pixelsPerSecond;
+
+    printf("Benchmarking (4 sec)...\n");
+
+    /* GL set-up */
+    glPixelStorei(GL_UNPACK_SKIP_PIXELS, SkipPixels);
+    glPixelStorei(GL_UNPACK_SKIP_ROWS, SkipRows);
+    glPixelZoom( Xzoom, Yzoom );
+    if (Scissor)
+	    glEnable(GL_SCISSOR_TEST);
+
+    if (DrawFront)
+	    glDrawBuffer(GL_FRONT);
+    else
+	    glDrawBuffer(GL_BACK);
+
+    /* Run timing test */
+    draws = 0;
+
+    ticksBySec = sysClkRateGet ();
+    startTick = tickGet();
+    
+    do {
+       glDrawPixels(DrawWidth, DrawHeight, ImgFormat, GL_UNSIGNED_BYTE, Image);
+       draws++;
+       endTick = tickGet ();
+    } while ((endTick - startTick)/ticksBySec < 4);   /* 4 seconds */
+
+    /* GL clean-up */
+    glDisable(GL_SCISSOR_TEST);
+
+    /* Results */
+    seconds = (endTick - startTick)/ticksBySec;
+    pixelsPerSecond = draws * DrawWidth * DrawHeight / seconds;
+    printf("Result: %d draws in %f seconds = %f pixels/sec\n",
+	   draws, seconds, pixelsPerSecond);
+    }
+
+UGL_LOCAL void echoUse(void)
+    {
+    printf("Keys:\n");
+    printf("       SPACE  Reset Parameters\n");
+    printf("     Up/Down  Move image up/down\n");
+    printf("  Left/Right  Move image left/right\n");
+    printf("           x  Decrease X-axis PixelZoom\n");
+    printf("           X  Increase X-axis PixelZoom\n");
+    printf("           y  Decrease Y-axis PixelZoom\n");
+    printf("           Y  Increase Y-axis PixelZoom\n");
+    printf("           w  Decrease glDrawPixels width*\n");
+    printf("           W  Increase glDrawPixels width*\n");
+    printf("           h  Decrease glDrawPixels height*\n");
+    printf("           H  Increase glDrawPixels height*\n");
+    printf("           p  Decrease GL_UNPACK_SKIP_PIXELS*\n");
+    printf("           P  Increase GL_UNPACK_SKIP_PIXELS*\n");
+    printf("           r  Decrease GL_UNPACK_SKIP_ROWS*\n");
+    printf("           R  Increase GL_UNPACK_SKIP_ROWS*\n");
+    printf("           s  Toggle GL_SCISSOR_TEST\n");
+    printf("           f  Toggle front/back buffer drawing\n");
+    printf("           d  Toggle dithering\n");
+    printf("           b  Benchmark test\n");
+    printf("         ESC  Exit\n");
+    printf("* Warning: no limits are imposed on these parameters so it's\n");
+    printf("  possible to cause a segfault if you go too far.\n");
+    }
+
+
+UGL_LOCAL void readKey(UGL_WCHAR key)
+    {
+    switch (key)
+	{
+	case UGL_UNI_SPACE:
+	    reset();
+	    break;
+	case 'd':
+	    Dither = !Dither;
+	    if (Dither)
+		glEnable(GL_DITHER);
+	    else
+		glDisable(GL_DITHER);
+	    break;
+	case 'w':
+	    if (DrawWidth > 0)
+		DrawWidth--;
+	    break;
+	case 'W':
+	    DrawWidth++;
+	    break;
+	case 'h':
+	    if (DrawHeight > 0)
+		DrawHeight--;
+	    break;
+	case 'H':
+	    DrawHeight++;
+	    break;
+	case 'p':
+	    if (SkipPixels > 0)
+		SkipPixels--;
+	    break;
+	case 'P':
+	    SkipPixels++;
+	    break;
+	case 'r':
+	    if (SkipRows > 0)
+		SkipRows--;
+	    break;
+	case 'R':
+	    SkipRows++;
+	    break;
+	case 's':
+	    Scissor = !Scissor;
+	    break;
+	case 'x':
+	    Xzoom -= 0.1;
+	    break;
+	case 'X':
+	    Xzoom += 0.1;
+	    break;
+	case 'y':
+	    Yzoom -= 0.1;
+	    break;
+	case 'Y':
+	    Yzoom += 0.1;
+	    break;
+	case 'b':
+	    benchmark();
+	    break;
+	case 'f':
+	    DrawFront = !DrawFront;
+	    if (DrawFront)
+		glDrawBuffer(GL_FRONT);
+	    else
+		glDrawBuffer(GL_BACK);
+	    printf("glDrawBuffer(%s)\n", DrawFront ? "GL_FRONT" : "GL_BACK");
+	    break;
+	case UGL_UNI_UP_ARROW:
+	    Ypos += 1;
+	    break;
+	case UGL_UNI_DOWN_ARROW:
+	    Ypos -= 1;
+	    break;
+	case UGL_UNI_LEFT_ARROW:
+	    Xpos -= 1;
+	    break;
+	case UGL_UNI_RIGHT_ARROW:
+	    Xpos += 1;
+	    break;
+	case UGL_UNI_ESCAPE:
+	    stopWex = UGL_TRUE;
+	    break;
+	}
+    }
+
+UGL_LOCAL void loopEvent(void)
+    {
+    UGL_EVENT event;
+    UGL_INPUT_EVENT * pInputEvent;
+ 
+    UGL_FOREVER
+	{
+	if (uglEventGet (qId, &event, sizeof (event), UGL_NO_WAIT)
+	    != UGL_STATUS_Q_EMPTY)
+            {
+	    pInputEvent = (UGL_INPUT_EVENT *)&event;
+	    
+	    if (pInputEvent->header.type == UGL_EVENT_TYPE_KEYBOARD &&
+		pInputEvent->modifiers & UGL_KEYBOARD_KEYDOWN)
+		readKey(pInputEvent->type.keyboard.key);
+	    }
+
+	drawGL();
+	if (stopWex)
+            break;
+	}
+    }
+
+UGL_LOCAL void cleanUp (void)
+    {
+    uglEventQDestroy (eventServiceId, qId);
+    
+    uglMesaDestroyContext();
+    uglDeinitialize ();
+    }
+
+void windMLDrawPix (void);
+
+void ugldrawpix (void)
+    {
+    taskSpawn ("tDrawPix", 210, VX_FP_TASK, 100000, (FUNCPTR)windMLDrawPix,
+              0,1,2,3,4,5,6,7,8,9);
+    }
+
+void windMLDrawPix (void)
+    {
+    UGL_INPUT_DEVICE_ID keyboardDevId;
+    GLuint ciMode;
+    GLsizei width, height;
+
+    Image = NULL;
+    Scissor = GL_FALSE;
+    DrawFront = GL_FALSE;
+    Dither = GL_TRUE;
+
+    uglInitialize ();
+
+    uglDriverFind (UGL_KEYBOARD_TYPE, 0,
+		   (UGL_UINT32 *)&keyboardDevId);
+
+    uglDriverFind (UGL_EVENT_SERVICE_TYPE, 0, (UGL_UINT32 *)&eventServiceId);
+
+    qId = uglEventQCreate (eventServiceId, 100);
+
+    /* Double buffering */
+    umc = uglMesaCreateNewContext (UGL_MESA_DOUBLE, NULL);
+    if (umc == NULL)
+        {
+	uglDeinitialize ();
+	return;
+	}
+    
+    uglMesaMakeCurrentContext(umc, 0, 0, UGL_MESA_FULLSCREEN_WIDTH,
+			      UGL_MESA_FULLSCREEN_HEIGHT);
+    
+    uglMesaGetIntegerv(UGL_MESA_COLOR_INDEXED, &ciMode);
+    uglMesaGetIntegerv(UGL_MESA_WIDTH, &width);
+    uglMesaGetIntegerv(UGL_MESA_HEIGHT, &height);
+    
+    initGL(ciMode, width, height);
+
+    echoUse();
+
+    stopWex = UGL_FALSE;
+    loopEvent();
+
+    cleanUp();
+        
+    return;
+    }
diff --git a/progs/windml/uglflip.c b/progs/windml/uglflip.c
new file mode 100644
index 0000000..ffc6ece
--- /dev/null
+++ b/progs/windml/uglflip.c
@@ -0,0 +1,219 @@
+
+/* uglflip.c - WindML/Mesa example program */
+
+/* Copyright (C) 2001 by Wind River Systems, Inc */
+
+/*
+ * Mesa 3-D graphics library
+ * Version:  3.5
+ *
+ * The MIT License
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Stephane Raimbault <stephane.raimbault@windriver.com> 
+ */
+
+/*
+DESCRIPTION
+Draw a triangle and flip the screen
+*/
+
+#include <stdio.h>
+#include <math.h>
+
+#include <ugl/ugl.h>
+#include <ugl/uglucode.h>
+#include <ugl/uglevent.h>
+#include <ugl/uglinput.h>
+
+#include <GL/uglmesa.h>
+#include <GL/glu.h>
+
+#define BLACK     (0)
+#define RED       (1)
+#define GREEN     (2)
+#define BLUE      (3)
+#define CI_OFFSET  4
+
+UGL_LOCAL GLuint rgb;
+UGL_LOCAL UGL_EVENT_SERVICE_ID eventServiceId;
+UGL_LOCAL UGL_EVENT_Q_ID qId;
+UGL_LOCAL volatile UGL_BOOL stopWex;
+
+UGL_LOCAL UGL_MESA_CONTEXT umc;
+
+UGL_LOCAL void initGL (void)
+    {
+    uglMesaSetColor(BLACK, 0.0, 0.0, 0.0);
+    uglMesaSetColor(RED, 1.0, 0.3, 0.3);
+    uglMesaSetColor(GREEN, 0.3, 1.0, 0.3);
+    uglMesaSetColor(BLUE, 0.3, 0.3, 1.0);
+    
+    glClearColor(0.0, 0.0, 0.0, 0.0);
+    glClearIndex(BLACK);
+
+    glMatrixMode(GL_PROJECTION);
+    glLoadIdentity();
+    glMatrixMode(GL_MODELVIEW);
+    }
+
+UGL_LOCAL void drawGL (void)
+    {
+    glClear(GL_COLOR_BUFFER_BIT);
+    
+    glBegin(GL_TRIANGLES);
+        (rgb) ? glColor3f(1.0, 0.3, 0.3) : glIndexi(RED);
+	glVertex2f(0.75, -0.50);
+	(rgb) ? glColor3f(0.3, 1.0, 0.3) : glIndexi(GREEN);
+	glVertex2f(0.0, 0.75);
+	(rgb) ? glColor3f(0.3, 0.3, 1.0) : glIndexi(BLUE);
+	glVertex2f(-0.75, -0.50);
+    glEnd();
+    
+    glBegin(GL_LINES);
+        (rgb) ? glColor3f(1.0, 0.3, 0.3) : glIndexi(RED);
+	glVertex2f(-1.0, 1.0);
+	(rgb) ? glColor3f(0.3, 0.3, 1.0) : glIndexi(BLUE);
+	glVertex2f(1.0, -1.0);
+    glEnd();
+
+    glFlush();
+
+    uglMesaSwapBuffers();
+    }    
+
+UGL_LOCAL void echoUse(void)
+    {
+    printf("tFlip keys:\n");
+    printf("             d  Toggle dithering\n");
+    printf("            up  Reduce the window\n");
+    printf("          down  Enlarge the window\n");
+    printf("       page up  Y==0 is the bottom line and increases upward\n");
+    printf("     page down  Y==0 is the bottom line and increases downward\n");
+    printf("           ESC  Exit\n");
+    }
+
+UGL_LOCAL void readKey (UGL_WCHAR key)
+    {
+    
+    switch(key)
+	{
+	case UGL_UNI_UP_ARROW:
+	    uglMesaResizeWindow(8, 8);
+	    break;
+	case UGL_UNI_DOWN_ARROW:
+	    glDrawBuffer(GL_FRONT_LEFT);
+	    glClear(GL_COLOR_BUFFER_BIT);
+	    glDrawBuffer(GL_BACK_LEFT);
+	    uglMesaResizeWindow(-8, -8);
+	    break;
+	case UGL_UNI_PAGE_UP:
+	    uglMesaPixelStore(UGL_MESA_Y_UP, GL_TRUE);
+	    break;
+	case UGL_UNI_PAGE_DOWN:
+	    uglMesaPixelStore(UGL_MESA_Y_UP, GL_FALSE);
+	    break;
+	case UGL_UNI_ESCAPE:
+	    stopWex = UGL_TRUE;
+	    break;
+	case 'd':
+	    if (glIsEnabled(GL_DITHER))
+		glDisable(GL_DITHER);
+	    else
+		glEnable(GL_DITHER);
+	    break;
+	}
+    }
+
+UGL_LOCAL void loopEvent(void)
+    {
+    UGL_EVENT event;
+    UGL_INPUT_EVENT * pInputEvent;
+ 
+    drawGL();
+
+    UGL_FOREVER
+	{
+	if (uglEventGet (qId, &event, sizeof (event), UGL_WAIT_FOREVER)
+	    != UGL_STATUS_Q_EMPTY)
+            {
+	    pInputEvent = (UGL_INPUT_EVENT *)&event;
+	    
+	    if (pInputEvent->header.type == UGL_EVENT_TYPE_KEYBOARD &&
+		pInputEvent->modifiers & UGL_KEYBOARD_KEYDOWN)
+		{
+		readKey(pInputEvent->type.keyboard.key);
+		drawGL();
+		}
+	    }
+
+	if (stopWex)
+            break;
+	}
+    }
+
+void windMLFlip (void);
+
+void uglflip (void)
+    {
+    taskSpawn("tFlip", 210, VX_FP_TASK, 100000, (FUNCPTR)windMLFlip,
+              0,1,2,3,4,5,6,7,8,9);
+    }
+
+void windMLFlip(void)
+    {
+
+    UGL_INPUT_DEVICE_ID keyboardDevId;
+
+    uglInitialize();
+
+    uglDriverFind (UGL_KEYBOARD_TYPE, 0, (UGL_UINT32 *)&keyboardDevId);
+
+    uglDriverFind (UGL_EVENT_SERVICE_TYPE, 0, (UGL_UINT32 *)&eventServiceId);
+
+    qId = uglEventQCreate (eventServiceId, 100);
+
+    umc = uglMesaCreateNewContext(UGL_MESA_DOUBLE_SW, NULL);
+
+    if (umc == NULL)
+        {
+	uglDeinitialize();
+	return;
+        }
+    uglMesaMakeCurrentContext(umc, 0, 0, UGL_MESA_FULLSCREEN_WIDTH,
+			      UGL_MESA_FULLSCREEN_HEIGHT);
+    
+    uglMesaGetIntegerv(UGL_MESA_RGB, &rgb);
+    
+    initGL();
+
+    echoUse();
+    stopWex = UGL_FALSE;	    
+    loopEvent();
+    
+    uglEventQDestroy (eventServiceId, qId);
+
+    uglMesaDestroyContext();
+    uglDeinitialize();
+
+    return;
+    }
diff --git a/progs/windml/uglgears.c b/progs/windml/uglgears.c
new file mode 100644
index 0000000..fe750a5
--- /dev/null
+++ b/progs/windml/uglgears.c
@@ -0,0 +1,422 @@
+
+/* uglgears.c - WindML/Mesa example program */
+
+/*
+ * 3-D gear wheels.  This program is in the public domain.
+ *
+ * Brian Paul
+ *
+ * Conversion to GLUT by Mark J. Kilgard
+ * Conversion to UGL/Mesa from GLUT by Stephane Raimbault
+ */
+
+/*
+DESCRIPTION
+Spinning gears demo
+*/
+
+#include <stdio.h>
+#include <math.h>
+#include <tickLib.h>
+
+#include <ugl/ugl.h>
+#include <ugl/uglucode.h>
+#include <ugl/uglevent.h>
+#include <ugl/uglinput.h>
+#include <GL/uglmesa.h>
+#include <GL/glu.h>
+
+#ifndef M_PI
+#define M_PI 3.14159265358979323846
+#endif
+
+#define COUNT_FRAMES
+
+UGL_LOCAL UGL_EVENT_SERVICE_ID eventServiceId;
+UGL_LOCAL UGL_EVENT_Q_ID qId;
+UGL_LOCAL volatile UGL_BOOL stopWex;
+UGL_LOCAL UGL_MESA_CONTEXT umc;
+
+UGL_LOCAL GLfloat view_rotx, view_roty, view_rotz;
+UGL_LOCAL GLint gear1, gear2, gear3;
+UGL_LOCAL GLfloat angle;
+
+UGL_LOCAL GLuint limit;
+UGL_LOCAL GLuint count;
+UGL_LOCAL GLuint tickStart, tickStop, tickBySec;
+
+
+/*
+* Draw a gear wheel.  You'll probably want to call this function when
+* building a display list since we do a lot of trig here.
+*
+* Input:  inner_radius - radius of hole at center
+*         outer_radius - radius at center of teeth
+*         width - width of gear
+*         teeth - number of teeth
+*         tooth_depth - depth of tooth
+*/
+
+UGL_LOCAL void gear
+    (
+    GLfloat inner_radius,
+    GLfloat outer_radius,
+    GLfloat width,
+    GLint teeth,
+    GLfloat tooth_depth
+    )
+    {
+    GLint i;
+    GLfloat r0, r1, r2;
+    GLfloat angle, da;
+    GLfloat u, v, len;
+
+    r0 = inner_radius;
+    r1 = outer_radius - tooth_depth/2.0;
+    r2 = outer_radius + tooth_depth/2.0;
+    
+    da = 2.0*M_PI / teeth / 4.0;
+    
+    glShadeModel (GL_FLAT);
+    
+    glNormal3f (0.0, 0.0, 1.0);
+    
+    /* draw front face */
+    glBegin (GL_QUAD_STRIP);
+    for (i=0;i<=teeth;i++)
+        {
+	angle = i * 2.0*M_PI / teeth;
+	glVertex3f (r0*cos (angle), r0*sin (angle), width*0.5);
+	glVertex3f (r1*cos (angle), r1*sin (angle), width*0.5);
+	glVertex3f (r0*cos (angle), r0*sin (angle), width*0.5);
+	glVertex3f (r1*cos (angle+3*da), r1*sin (angle+3*da), width*0.5);
+	}
+    glEnd ();
+
+    /* draw front sides of teeth */
+    glBegin (GL_QUADS);
+    da = 2.0*M_PI / teeth / 4.0;
+    for (i=0; i<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);
+	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 ();
+      
+}
+
+UGL_LOCAL void drawGL (void)
+    {
+#ifdef COUNT_FRAMES
+    int time;
+#endif
+    
+    angle += 2.0;
+
+    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 ();
+
+    uglMesaSwapBuffers ();
+
+#ifdef COUNT_FRAMES
+    if (count > limit)
+        {
+	tickStop = tickGet ();
+	time = (tickStop-tickStart)/tickBySec;
+	printf (" %i fps\n", count/time);
+	tickStart = tickStop;
+	count = 0;
+        }
+    else 
+	count++;
+#endif
+}
+
+
+UGL_LOCAL void initGL (GLsizei width, GLsizei height)
+    {
+    UGL_LOCAL GLfloat pos[4] = {5.0, 5.0, 10.0, 1.0 };
+    UGL_LOCAL GLfloat red[4] = {0.8, 0.1, 0.0, 1.0 };
+    UGL_LOCAL GLfloat green[4] = {0.0, 0.8, 0.2, 1.0 };
+    UGL_LOCAL GLfloat blue[4] = {0.2, 0.2, 1.0, 1.0 };
+
+    glLightfv (GL_LIGHT0, GL_POSITION, pos);
+    glEnable (GL_CULL_FACE);
+    glEnable (GL_LIGHTING);
+    glEnable (GL_LIGHT0);
+    glEnable (GL_DEPTH_TEST);
+
+    /* make the gears */
+    gear1 = glGenLists (1);
+    glNewList (gear1, GL_COMPILE);
+    glMaterialfv (GL_FRONT, GL_AMBIENT_AND_DIFFUSE, red);
+    gear (1.0, 4.0, 1.0, 20, 0.7);
+    glEndList ();
+
+    gear2 = glGenLists (1);
+    glNewList (gear2, GL_COMPILE);
+    glMaterialfv (GL_FRONT, GL_AMBIENT_AND_DIFFUSE, green);
+    gear (0.5, 2.0, 2.0, 10, 0.7);
+    glEndList ();
+
+    gear3 = glGenLists (1);
+    glNewList (gear3, GL_COMPILE);
+    glMaterialfv (GL_FRONT, GL_AMBIENT_AND_DIFFUSE, blue);
+    gear (1.3, 2.0, 0.5, 10, 0.7);
+    glEndList ();
+
+    glEnable (GL_NORMALIZE);
+
+    glViewport (0, 0, width, height);
+
+    glMatrixMode (GL_PROJECTION);
+    glLoadIdentity ();
+    if (width>height)
+        {
+	GLfloat w = (GLfloat) width / (GLfloat) height;
+	glFrustum (-w, w, -1.0, 1.0, 5.0, 60.0);
+        }
+    else
+        {
+	GLfloat h = (GLfloat) height / (GLfloat) width;
+	glFrustum (-1.0, 1.0, -h, h, 5.0, 60.0);
+        }
+
+    glMatrixMode (GL_MODELVIEW);
+    glLoadIdentity ();
+    glTranslatef (0.0, 0.0, -40.0);
+
+#ifdef COUNT_FRAMES
+    tickStart = tickGet ();
+    tickBySec = sysClkRateGet ();
+#endif
+}
+
+UGL_LOCAL void echoUse(void)
+    {
+    printf("tGears keys:\n");
+    printf("           z  Counter clockwise rotation (z-axis)\n");
+    printf("           Z  Clockwise rotation (z-axis)\n");
+    printf("          Up  Counter clockwise rotation (x-axis)\n");
+    printf("        Down  Clockwise rotation (x-axis)\n");
+    printf("        Left  Counter clockwise rotation (y-axis)\n");
+    printf("       Right  Clockwise rotation (y-axis)\n");
+    printf("         ESC  Exit\n");
+    }
+
+
+UGL_LOCAL void readKey (UGL_WCHAR key)
+    {
+    
+    switch(key)
+	{
+	case 'z':
+	    view_rotz += 5.0;
+	    break;
+	case 'Z':
+	    view_rotz -= 5.0;
+	    break;
+	case UGL_UNI_UP_ARROW:
+	    view_rotx += 5.0;
+	    break;
+	case UGL_UNI_DOWN_ARROW:
+	    view_rotx -= 5.0;
+	    break;
+	case UGL_UNI_LEFT_ARROW:
+	    view_roty += 5.0;
+	    break;
+	case UGL_UNI_RIGHT_ARROW:
+	    view_roty -= 5.0;
+	    break;  
+	case UGL_UNI_ESCAPE:
+	    stopWex = UGL_TRUE;
+	    break;
+	}
+    }
+
+UGL_LOCAL void loopEvent(void)
+    {
+    UGL_EVENT event;
+    UGL_INPUT_EVENT * pInputEvent;
+    
+    UGL_FOREVER
+	{
+	if (uglEventGet (qId, &event, sizeof (event), UGL_NO_WAIT)
+	    != UGL_STATUS_Q_EMPTY)
+            {
+	    pInputEvent = (UGL_INPUT_EVENT *)&event;
+	    
+	    if (pInputEvent->header.type == UGL_EVENT_TYPE_KEYBOARD &&
+		pInputEvent->modifiers & UGL_KEYBOARD_KEYDOWN)
+		readKey(pInputEvent->type.keyboard.key);
+	    }
+
+	drawGL();
+	if (stopWex)
+            break;
+	}
+    }
+
+void windMLGears (void);
+
+void uglgears (void)
+    {
+    taskSpawn ("tGears", 210, VX_FP_TASK, 100000, (FUNCPTR)windMLGears,
+	       0,1,2,3,4,5,6,7,8,9);
+    }
+
+void windMLGears (void)
+    {
+    GLsizei width, height;
+    UGL_INPUT_DEVICE_ID keyboardDevId;
+    
+    view_rotx=20.0;
+    view_roty=30.0;
+    view_rotz=0.0;
+    angle = 0.0;
+    limit = 100;
+    count = 1;
+
+    uglInitialize ();
+
+    uglDriverFind (UGL_KEYBOARD_TYPE, 0,
+		   (UGL_UINT32 *)&keyboardDevId);
+
+    uglDriverFind (UGL_EVENT_SERVICE_TYPE, 0, (UGL_UINT32 *)&eventServiceId);
+
+    qId = uglEventQCreate (eventServiceId, 100);
+
+    /* Double buffering */
+
+    umc = uglMesaCreateNewContext (UGL_MESA_DOUBLE, NULL);
+    if (umc == NULL)
+	{
+	uglDeinitialize ();
+	return;
+	}
+
+    /* Fullscreen */
+
+    uglMesaMakeCurrentContext (umc, 0, 0, UGL_MESA_FULLSCREEN_WIDTH,
+			       UGL_MESA_FULLSCREEN_HEIGHT);
+
+    uglMesaGetIntegerv(UGL_MESA_WIDTH, &width);
+    uglMesaGetIntegerv(UGL_MESA_HEIGHT, &height);
+    
+    initGL (width, height);
+
+    echoUse();
+
+    stopWex = UGL_FALSE;
+    loopEvent();
+        
+    uglEventQDestroy (eventServiceId, qId);
+
+    uglMesaDestroyContext();
+    uglDeinitialize ();
+
+    return;
+    }
diff --git a/progs/windml/uglicotorus.c b/progs/windml/uglicotorus.c
new file mode 100644
index 0000000..46226f1
--- /dev/null
+++ b/progs/windml/uglicotorus.c
@@ -0,0 +1,311 @@
+/* uglicotorus.c - WindML/Mesa example program */
+
+/* Copyright (C) 2001 by Wind River Systems, Inc */
+
+/*
+ * Mesa 3-D graphics library
+ * Version:  3.5
+ *
+ * The MIT License
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+/*
+modification history
+--------------------
+01a,jun01,sra
+*/
+
+#include <stdio.h>
+#include <math.h>
+
+#include <ugl/uglevent.h>
+#include <ugl/uglinput.h>
+#include <ugl/uglucode.h>
+
+#include <GL/uglmesa.h>
+#include <GL/glu.h>
+
+/* Need GLUT_SHAPES */
+
+#include <GL/uglglutshapes.h>
+
+UGL_LOCAL UGL_EVENT_SERVICE_ID eventServiceId;
+UGL_LOCAL UGL_EVENT_Q_ID qId;
+UGL_LOCAL UGL_MESA_CONTEXT umc;
+UGL_LOCAL volatile UGL_BOOL stopWex;
+
+UGL_LOCAL GLfloat angle;
+UGL_LOCAL GLboolean chaos_on;
+UGL_LOCAL GLboolean color_on;
+
+UGL_LOCAL GLuint theIco, theTorus, theSphere, theCube; 
+
+UGL_LOCAL void initGL
+    (
+    int w,
+    int h
+    )
+    {
+    glViewport(0,0,(GLsizei)w,(GLsizei)h);
+    glMatrixMode(GL_PROJECTION);
+    glLoadIdentity();
+    gluPerspective(60.0,(GLfloat)w/(GLfloat)h,1.0,60.0);
+    
+    glMatrixMode(GL_MODELVIEW);
+    glLoadIdentity();
+    gluLookAt(0.0,0.0,25.0,0.0,0.0,0.0,0.0,1.0,0.0);
+    
+    glClearColor(0.0,0.0,0.0,0.0);
+
+    glEnable(GL_DEPTH_TEST);
+    glEnable(GL_LIGHTING);
+    glEnable(GL_LIGHT0);
+
+    glEnable(GL_COLOR_MATERIAL);
+
+    theIco = glGenLists(1);
+    glNewList(theIco, GL_COMPILE);
+    glutSolidIcosahedron();
+    glEndList();
+
+    theTorus = glGenLists(1);
+    glNewList(theTorus, GL_COMPILE);
+    glutSolidTorus(0.2,1.0,10,10);
+    glEndList();
+
+    theSphere = glGenLists(1);
+    glNewList(theSphere, GL_COMPILE);
+    glutSolidSphere(2.5,20,20);
+    glEndList();
+
+    theCube = glGenLists(1);
+    glNewList(theCube, GL_COMPILE);
+    glutSolidCube(4.0);
+    glEndList();
+    
+    }
+
+UGL_LOCAL void createIcoToruses
+    (
+    int i
+    )
+    {
+    glPushMatrix();
+    glRotatef(angle,1.0,1.0,1.0);
+    glCallList(theIco);   
+
+    switch (i)
+	{
+	case 9 :
+	    glColor3f(1.0,0.0,0.0);
+	    break;
+	case 0 :
+	    glColor3f(1.0,0.1,0.7);
+	    break;
+	case 1 :
+	    glColor3f(1.0,0.0,1.0);
+	    break;
+	case 2 :
+	    glColor3f(0.0,0.0,1.0);
+	    break;
+	case 3 :
+	    glColor3f(0.0,0.5,1.0);
+	    break;
+	case 4 :
+	    glColor3f(0.0,1.0,0.7);
+	    break;
+	case 5 :
+	    glColor3f(0.0,1.0,0.0);
+	    break;
+	case 6 :
+	    glColor3f(0.5,1.0,0.0);
+	    break;
+	case 7 :
+	    glColor3f(1.0,1.0,0.0);
+	    break;
+	case 8 :
+	    glColor3f(1.0,0.5,0.0);
+	    break;
+	}
+
+    glRotatef(angle,1.0,1.0,1.0);
+    glCallList(theTorus);   
+    glRotatef(-2*angle,1.0,1.0,1.0);
+    glCallList(theTorus);
+    glPopMatrix();
+    }
+
+UGL_LOCAL void drawGL (void)
+    {
+    int i;
+
+    if (color_on)
+	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+    else
+	glClear(GL_DEPTH_BUFFER_BIT);
+    
+    glPushMatrix();
+
+    if (chaos_on)	
+	glRotatef(angle,1.0,1.0,1.0); 
+    
+    glPushMatrix();
+    glRotatef(angle,1.0,1.0,1.0);
+    glColor3f(1.0,0.5,0.0);
+    glCallList(theSphere);
+    glColor3f(1.0,0.0,0.0);
+    glCallList(theCube);
+    glPopMatrix(); 
+        
+    glRotatef(-angle,0.0,0.0,1.0);
+    glPushMatrix();
+    /* draw ten icosahedrons */
+    for (i = 0; i < 10; i++)
+	{
+	glPushMatrix();
+	glRotatef(36*i,0.0,0.0,1.0);
+	glTranslatef(10.0,0.0,0.0);
+	glRotatef(2*angle,0.0,1.0,0.0);
+	glTranslatef(0.0,0.0,2.0);
+	
+	createIcoToruses(i); 
+	glPopMatrix();
+	}
+    glPopMatrix();
+    
+    glPopMatrix();
+    
+    uglMesaSwapBuffers();
+
+    angle += 1.0;
+
+    }
+
+UGL_LOCAL void echoUse(void)
+    {
+    printf("tIcoTorus keys:\n");
+    printf("           c  Toggle color buffer clear\n");
+    printf("       SPACE  Toggle chaos mode\n");
+    printf("         ESC  Exit\n");
+    }
+
+UGL_LOCAL void readKey (UGL_WCHAR key)
+    {
+    
+    switch(key)
+	{
+	case 'c':
+	    color_on = !color_on;
+	    break;    
+	case UGL_UNI_SPACE:
+	    chaos_on = !chaos_on;
+	    break;
+	case UGL_UNI_ESCAPE:
+	    stopWex = UGL_TRUE;
+	    break;
+	}
+    }
+
+UGL_LOCAL void loopEvent(void)
+    {
+    UGL_EVENT event;
+    UGL_INPUT_EVENT * pInputEvent;
+ 
+    UGL_FOREVER
+	{
+	if (uglEventGet (qId, &event, sizeof (event), UGL_NO_WAIT)
+	    != UGL_STATUS_Q_EMPTY)
+            {
+	    pInputEvent = (UGL_INPUT_EVENT *)&event;
+	    
+	    if (pInputEvent->header.type == UGL_EVENT_TYPE_KEYBOARD &&
+		pInputEvent->modifiers & UGL_KEYBOARD_KEYDOWN)
+		readKey(pInputEvent->type.keyboard.key);
+	    }
+
+	drawGL();
+	if (stopWex)
+            break;
+	}
+    }
+
+void windMLIcoTorus (void);
+
+void uglicotorus (void)
+    {
+    taskSpawn ("tIcoTorus", 210, VX_FP_TASK, 100000, (FUNCPTR)windMLIcoTorus,
+              0,1,2,3,4,5,6,7,8,9);
+    }
+
+void windMLIcoTorus (void)
+    {
+    GLsizei width, height;
+    UGL_INPUT_DEVICE_ID keyboardDevId;
+
+    angle = 0.0;
+    chaos_on = GL_TRUE;
+    color_on = GL_TRUE;
+
+    uglInitialize ();
+
+    uglDriverFind (UGL_KEYBOARD_TYPE, 0,
+		   (UGL_UINT32 *)&keyboardDevId);
+
+    if (uglDriverFind (UGL_EVENT_SERVICE_TYPE, 0,
+                       (UGL_UINT32 *)&eventServiceId) == UGL_STATUS_OK)
+        {
+        qId = uglEventQCreate (eventServiceId, 100);
+        }
+    else 
+        {
+        eventServiceId = UGL_NULL;
+        }
+
+    /* Double buffering */
+    umc = uglMesaCreateNewContext (UGL_MESA_DOUBLE, NULL);
+
+    if (umc == NULL)
+        {
+	uglDeinitialize ();
+	return;
+	}
+    
+    uglMesaMakeCurrentContext (umc, 0, 0, UGL_MESA_FULLSCREEN_WIDTH,
+			       UGL_MESA_FULLSCREEN_HEIGHT);
+
+    uglMesaGetIntegerv(UGL_MESA_WIDTH, &width);
+    uglMesaGetIntegerv(UGL_MESA_HEIGHT, &height);
+    
+    initGL (width, height);
+
+    echoUse();
+
+    stopWex = UGL_FALSE;
+    loopEvent();
+        
+    if (eventServiceId != UGL_NULL)
+        uglEventQDestroy (eventServiceId, qId);
+
+    uglMesaDestroyContext ();
+    uglDeinitialize ();
+    
+    return;
+    }
+
diff --git a/progs/windml/uglline.c b/progs/windml/uglline.c
new file mode 100644
index 0000000..fd100ff
--- /dev/null
+++ b/progs/windml/uglline.c
@@ -0,0 +1,270 @@
+
+/* uglline.c - WindML/Mesa example program */
+
+/*
+ * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the name of
+ * Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
+ * ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+/*
+modification history
+--------------------
+01a,jun01,sra  Ported to UGL/Mesa and modifications
+*/
+
+/*
+DESCRIPTION
+Draw circular lines
+*/
+
+#include <stdio.h>
+#include <math.h>
+
+#include <ugl/ugl.h>
+#include <ugl/uglucode.h>
+#include <ugl/uglevent.h>
+#include <ugl/uglinput.h>
+
+#include <GL/uglmesa.h>
+#include <GL/glu.h>
+
+#define BLACK     (0)
+#define YELLOW    (1)
+#define GREEN     (2)
+#define BLUE      (3)
+#define CI_OFFSET  4
+
+UGL_LOCAL GLuint rgb;
+UGL_LOCAL UGL_EVENT_SERVICE_ID eventServiceId;
+UGL_LOCAL UGL_EVENT_Q_ID qId;
+UGL_LOCAL volatile UGL_BOOL stopWex;
+UGL_LOCAL UGL_MESA_CONTEXT umc;
+
+UGL_LOCAL GLboolean mode1, mode2;
+UGL_LOCAL GLint size;
+
+UGL_LOCAL GLfloat pntA[3] = {
+    -10.0, 0.0, 0.0
+};
+UGL_LOCAL GLfloat pntB[3] = {
+    -5.0, 0.0, 0.0
+};
+
+UGL_LOCAL GLint angleA;
+
+UGL_LOCAL void initGL (void)
+    {    
+    GLint i;
+
+    uglMesaSetColor(BLACK, 0.0, 0.0, 0.0);
+    uglMesaSetColor(YELLOW, 1.0, 1.0, 0.0);
+    uglMesaSetColor(GREEN, 0.0, 1.0, 0.0);
+    uglMesaSetColor(BLUE, 0.0, 0.0, 1.0);
+    
+    for (i = 0; i < 16; i++)
+	{
+	uglMesaSetColor(CI_OFFSET+i, i/15.0, i/15.0, 0.0);
+	}
+    
+    glClearColor(0.0, 0.0, 0.0, 0.0);
+    glClearIndex(BLACK);
+
+    glMatrixMode(GL_PROJECTION);
+    glLoadIdentity();
+    glOrtho(-10, 10, -10, 10, -10.0, 10.0);
+
+    glMatrixMode(GL_MODELVIEW);
+    
+    glLineStipple(1, 0xF0E0);
+    glBlendFunc(GL_SRC_ALPHA, GL_ONE);
+
+    mode1 = GL_FALSE;
+    mode2 = GL_FALSE;
+    size = 1;
+    }
+
+UGL_LOCAL void drawGL (void)
+    {
+    
+    GLint ci, i;
+
+    glClear(GL_COLOR_BUFFER_BIT);
+
+    glLineWidth(size);
+
+    if (mode1) {
+	glEnable(GL_LINE_STIPPLE);
+    } else {
+	glDisable(GL_LINE_STIPPLE);
+    }
+
+    if (mode2) {
+	ci = CI_OFFSET;
+	glEnable(GL_LINE_SMOOTH);
+	glEnable(GL_BLEND);
+    } else {
+	ci = YELLOW;
+	glDisable(GL_LINE_SMOOTH);
+	glDisable(GL_BLEND);
+    }
+
+    glPushMatrix();
+
+    glRotatef(angleA, 1, 0, 1);
+    angleA = angleA++ % 360;
+   
+    for (i = 0; i < 360; i += 5) {
+	glRotatef(5.0, 0, 0, 1);
+
+	glColor3f(1.0, 1.0, 0.0);
+	glBegin(GL_LINE_STRIP);
+	    glVertex3fv(pntA);
+	    glVertex3fv(pntB);
+	glEnd();
+
+	glPointSize(1);
+	
+	glColor3f(0.0, 1.0, 0.0);
+	glBegin(GL_POINTS);
+	glVertex3fv(pntA);
+	glVertex3fv(pntB);
+	glEnd();
+    }
+    
+    glPopMatrix();
+
+    glFlush();
+
+    uglMesaSwapBuffers();
+
+    }    
+
+UGL_LOCAL void echoUse(void)
+    {
+    printf("tLine keys:\n");
+    printf("           b  Blending/antialiasing\n");
+    printf("           n  Line stipple\n");
+    printf("     Up/Down  Pixel size\n");
+    printf("         ESC  Exit\n");
+    }
+
+UGL_LOCAL void readKey (UGL_WCHAR key)
+    {
+    switch(key)
+	{
+	case 'n':
+	    mode1 = (mode1) ? GL_FALSE: GL_TRUE;
+	    break;
+	case 'b':
+	    mode2 = (mode2) ? GL_FALSE: GL_TRUE;
+	    break;
+	case UGL_UNI_DOWN_ARROW:
+	    if(size>0)
+		size--;
+	    break;
+	case UGL_UNI_UP_ARROW:
+	    size++;
+	    break; 
+	case UGL_UNI_ESCAPE:
+	    stopWex = UGL_TRUE;
+	    break;
+	}
+    }
+
+UGL_LOCAL void loopEvent(void)
+    {
+    UGL_EVENT event;
+    UGL_INPUT_EVENT * pInputEvent;
+ 
+    UGL_FOREVER
+	{
+	if (uglEventGet (qId, &event, sizeof (event), UGL_NO_WAIT)
+	    != UGL_STATUS_Q_EMPTY)
+            {
+	    pInputEvent = (UGL_INPUT_EVENT *)&event;
+	    
+	    if (pInputEvent->header.type == UGL_EVENT_TYPE_KEYBOARD &&
+		pInputEvent->modifiers & UGL_KEYBOARD_KEYDOWN)
+		readKey(pInputEvent->type.keyboard.key);
+	    }
+
+	drawGL();
+	if (stopWex)
+            break;
+	}
+    }
+
+void windMLLine (void);
+
+void uglline (void)
+    {
+    taskSpawn("tLine", 210, VX_FP_TASK, 100000, (FUNCPTR)windMLLine,
+              0,1,2,3,4,5,6,7,8,9);
+    }
+
+
+void windMLLine(void)
+    {
+
+    UGL_INPUT_DEVICE_ID keyboardDevId;
+
+    angleA = 0;
+    
+    uglInitialize();
+
+    uglDriverFind (UGL_KEYBOARD_TYPE, 0, (UGL_UINT32 *)&keyboardDevId);
+
+    uglDriverFind (UGL_EVENT_SERVICE_TYPE, 0, (UGL_UINT32 *)&eventServiceId);
+
+    qId = uglEventQCreate (eventServiceId, 100);
+
+    /* Double buffer */
+
+    umc = uglMesaCreateNewContext(UGL_MESA_DOUBLE, NULL);
+
+    if (umc == NULL)
+        {
+	uglDeinitialize();
+	return;
+        }
+
+    /* Fullscreen */
+
+    uglMesaMakeCurrentContext(umc, 0, 0, UGL_MESA_FULLSCREEN_WIDTH,
+			      UGL_MESA_FULLSCREEN_HEIGHT);
+
+    uglMesaGetIntegerv(UGL_MESA_RGB, &rgb);
+    
+    initGL();
+
+    echoUse();
+
+    stopWex = UGL_FALSE;
+    loopEvent();
+        
+    uglEventQDestroy(eventServiceId, qId);
+
+    uglMesaDestroyContext();
+    uglDeinitialize();
+
+    return;
+    }
diff --git a/progs/windml/uglolympic.c b/progs/windml/uglolympic.c
new file mode 100644
index 0000000..de7c278
--- /dev/null
+++ b/progs/windml/uglolympic.c
@@ -0,0 +1,474 @@
+/*
+ * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the name of
+ * Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
+ * ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+/*
+ * Nov 20, 1995 use stdlib's rand()/srand() instead of random()/srand48(), etc.
+ */
+
+/*
+ * Modified by Stephane Raimbault to be able to run in VxWorks 07/18/01
+ *
+ * Modified by Li Wei(liwei@aiar.xjtu.edu.cn) to be able to run in Windows
+ * 6/13
+ *
+ * Modified by Brian Paul to compile with Windows OR Unix.  7/23/97
+ */
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+
+#include <ugl/ugl.h>
+#include <ugl/uglevent.h>
+#include <ugl/uglinput.h>
+#include <ugl/uglucode.h>
+
+#include <GL/uglmesa.h>
+#include <GL/glu.h>
+
+#ifndef RAND_MAX
+#  define RAND_MAX 32767
+#endif
+
+#define XSIZE	100
+#define YSIZE	75
+
+#define RINGS 5
+#define BLUERING 0
+#define BLACKRING 1
+#define REDRING 2
+#define YELLOWRING 3
+#define GREENRING 4
+
+#define BACKGROUND 8
+
+UGL_LOCAL UGL_EVENT_SERVICE_ID eventServiceId;
+UGL_LOCAL UGL_EVENT_Q_ID qId;
+UGL_LOCAL UGL_MESA_CONTEXT umc;
+UGL_LOCAL volatile UGL_BOOL stopWex;
+
+UGL_LOCAL int rgb;
+UGL_LOCAL unsigned char rgb_colors[RINGS][3];
+UGL_LOCAL int mapped_colors[RINGS];
+UGL_LOCAL float dests[RINGS][3];
+UGL_LOCAL float offsets[RINGS][3];
+UGL_LOCAL float angs[RINGS];
+UGL_LOCAL float rotAxis[RINGS][3];
+UGL_LOCAL int iters[RINGS];
+UGL_LOCAL GLuint theTorus;
+
+enum {
+    COLOR_BLACK = 0,
+    COLOR_RED,
+    COLOR_GREEN,
+    COLOR_YELLOW,
+    COLOR_BLUE,
+    COLOR_MAGENTA,
+    COLOR_CYAN,
+    COLOR_WHITE
+};
+
+/*
+UGL_LOCAL float RGBMap[9][3] = {
+    {0, 0, 0},
+    {1, 0, 0},
+    {0, 1, 0},
+    {1, 1, 0},
+    {0, 0, 1},
+    {1, 0, 1},
+    {0, 1, 1},
+    {1, 1, 1},
+    {0.5, 0.5, 0.5}
+};
+
+UGL_LOCAL void SetColor(int c)
+    {
+    (rgb) ? glColor3fv(RGBMap[c]): glIndexf(c);
+    }
+
+UGL_LOCAL void InitMap(void)
+    {
+    int i;
+    
+    if (rgb)
+	return;
+    
+    for (i = 0; i < 9; i++)
+	uglMesaSetColor(i, RGBMap[i][0], RGBMap[i][1], RGBMap[i][2]);
+    }
+
+UGL_LOCAL void SetFogRamp(int density, int startIndex)
+    {
+    int fogValues, colorValues;
+    int i, j, k;
+    float intensity;
+    
+    fogValues = 1 << density;
+    colorValues = 1 << startIndex;
+    for (i = 0; i < colorValues; i++)
+	{
+	for (j = 0; j < fogValues; j++)
+	    {
+	    k = i * fogValues + j;
+	    intensity = (i * fogValues + j * colorValues) / 255.0;
+	    uglMesaSetColor(k, intensity, intensity, intensity);
+	    }
+	}
+    }
+
+UGL_LOCAL void SetGreyRamp(void)
+    {
+    int i;
+    float intensity;
+
+    for (i = 0; i < 255; i++)
+	{
+	intensity = i / 255.0;
+	uglMesaSetColor(i, intensity, intensity, intensity);
+	}
+    }
+*/
+
+UGL_LOCAL void FillTorus(float rc, int numc, float rt, int numt)
+    {
+    int i, j, k;
+    double s, t;
+    double x, y, z;
+    double pi, twopi;
+
+    pi = 3.14159265358979323846;
+    twopi = 2 * pi;
+
+    for (i = 0; i < numc; i++)
+	{
+	glBegin(GL_QUAD_STRIP);
+        for (j = 0; j <= numt; j++)
+	    {
+	    for (k = 1; k >= 0; k--)
+		{
+		s = (i + k) % numc + 0.5;
+		t = j % numt;
+		
+		x = cos(t*twopi/numt) * cos(s*twopi/numc);
+		y = sin(t*twopi/numt) * cos(s*twopi/numc);
+		z = sin(s*twopi/numc);
+		glNormal3f(x, y, z);
+		
+		x = (rt + rc * cos(s*twopi/numc)) * cos(t*twopi/numt);
+		y = (rt + rc * cos(s*twopi/numc)) * sin(t*twopi/numt);
+		z = rc * sin(s*twopi/numc);
+		glVertex3f(x, y, z);
+		}
+	    }
+	glEnd();
+	}
+    }
+
+UGL_LOCAL float Clamp(int iters_left, float t)
+    {
+    if (iters_left < 3)
+	{
+	return 0.0;
+	}
+    return (iters_left-2)*t/iters_left;
+    }
+
+UGL_LOCAL void drawGL(void)
+    {
+    int i, j;
+
+    for (i = 0; i < RINGS; i++)
+	{
+	if (iters[i]) {
+	for (j = 0; j < 3; j++)
+	    {
+	    offsets[i][j] = Clamp(iters[i], offsets[i][j]);
+	    }
+	angs[i] = Clamp(iters[i], angs[i]);
+	iters[i]--;
+	}
+	}
+
+    glPushMatrix();
+
+    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+    gluLookAt(0,0,10, 0,0,0, 0,1,0);
+
+    for (i = 0; i < RINGS; i++)
+	{
+	if (rgb)
+	    {
+	    glColor3ubv(rgb_colors[i]);
+	    }
+	else
+	    {
+	    glIndexi(mapped_colors[i]);
+	    }
+	glPushMatrix();
+	glTranslatef(dests[i][0]+offsets[i][0], dests[i][1]+offsets[i][1],
+		     dests[i][2]+offsets[i][2]);
+	glRotatef(angs[i], rotAxis[i][0], rotAxis[i][1], rotAxis[i][2]);
+	glCallList(theTorus);
+	glPopMatrix();
+	}
+
+    glPopMatrix();
+
+    glFlush();
+
+    uglMesaSwapBuffers();
+    }
+
+UGL_LOCAL float MyRand(void)
+    {
+    return 10.0 * ( (float) rand() / (float) RAND_MAX - 0.5 );
+    }
+
+UGL_LOCAL void ReInit(void)
+    {
+    int i;
+    float deviation;
+
+    deviation = MyRand() / 2;
+    deviation = deviation * deviation;
+    for (i = 0; i < RINGS; i++)
+	{
+	offsets[i][0] = MyRand();
+	offsets[i][1] = MyRand();
+	offsets[i][2] = MyRand();
+	angs[i] = 260.0 * MyRand();
+	rotAxis[i][0] = MyRand();
+	rotAxis[i][1] = MyRand();
+	rotAxis[i][2] = MyRand();
+	iters[i] = (deviation * MyRand() + 60.0);
+	}
+    }
+
+UGL_LOCAL void initGL(void)
+    {
+    float base, height;
+    float aspect, x, y;
+    int i;
+
+    float top_y = 1.0;
+    float bottom_y = 0.0;
+    float top_z = 0.15;
+    float bottom_z = 0.69;
+    float spacing = 2.5;
+    static float lmodel_ambient[] = {0.0, 0.0, 0.0, 0.0};
+    static float lmodel_twoside[] = {GL_FALSE};
+    static float lmodel_local[] = {GL_FALSE};
+    static float light0_ambient[] = {0.1, 0.1, 0.1, 1.0};
+    static float light0_diffuse[] = {1.0, 1.0, 1.0, 0.0};
+    static float light0_position[] = {0.8660254, 0.5, 1, 0};
+    static float light0_specular[] = {1.0, 1.0, 1.0, 0.0};
+    static float bevel_mat_ambient[] = {0.0, 0.0, 0.0, 1.0};
+    static float bevel_mat_shininess[] = {40.0};
+    static float bevel_mat_specular[] = {1.0, 1.0, 1.0, 0.0};
+    static float bevel_mat_diffuse[] = {1.0, 0.0, 0.0, 0.0};
+
+    ReInit();
+
+    for (i = 0; i < RINGS; i++)
+	{
+	rgb_colors[i][0] = rgb_colors[i][1] = rgb_colors[i][2] = 0;
+	}
+    rgb_colors[BLUERING][2] = 255;
+    rgb_colors[REDRING][0] = 255;
+    rgb_colors[GREENRING][1] = 255;
+    rgb_colors[YELLOWRING][0] = 255;
+    rgb_colors[YELLOWRING][1] = 255;
+    mapped_colors[BLUERING] = COLOR_BLUE;
+    mapped_colors[REDRING] = COLOR_RED;
+    mapped_colors[GREENRING] = COLOR_GREEN;
+    mapped_colors[YELLOWRING] = COLOR_YELLOW;
+    mapped_colors[BLACKRING] = COLOR_BLACK;
+
+    dests[BLUERING][0] = -spacing;
+    dests[BLUERING][1] = top_y;
+    dests[BLUERING][2] = top_z;
+
+    dests[BLACKRING][0] = 0.0;
+    dests[BLACKRING][1] = top_y;
+    dests[BLACKRING][2] = top_z;
+
+    dests[REDRING][0] = spacing;
+    dests[REDRING][1] = top_y;
+    dests[REDRING][2] = top_z;
+
+    dests[YELLOWRING][0] = -spacing / 2.0;
+    dests[YELLOWRING][1] = bottom_y;
+    dests[YELLOWRING][2] = bottom_z;
+
+    dests[GREENRING][0] = spacing / 2.0;
+    dests[GREENRING][1] = bottom_y;
+    dests[GREENRING][2] = bottom_z;
+
+    base = 2.0;
+    height = 2.0;
+    theTorus = glGenLists(1);
+    glNewList(theTorus, GL_COMPILE);
+    FillTorus(0.1, 8, 1.0, 25);
+    glEndList();
+
+    x = (float)XSIZE;
+    y = (float)YSIZE;
+    aspect = x / y;
+    glEnable(GL_CULL_FACE);
+    glCullFace(GL_BACK);
+    glEnable(GL_DEPTH_TEST);
+    glClearDepth(1.0);
+
+    if (rgb)
+	{
+	glClearColor(0.5, 0.5, 0.5, 0.0);
+	glLightfv(GL_LIGHT0, GL_AMBIENT, light0_ambient);
+	glLightfv(GL_LIGHT0, GL_DIFFUSE, light0_diffuse);
+	glLightfv(GL_LIGHT0, GL_SPECULAR, light0_specular);
+	glLightfv(GL_LIGHT0, GL_POSITION, light0_position);
+	glEnable(GL_LIGHT0);
+
+	glLightModelfv(GL_LIGHT_MODEL_LOCAL_VIEWER, lmodel_local);
+	glLightModelfv(GL_LIGHT_MODEL_TWO_SIDE, lmodel_twoside);
+	glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient);
+	glEnable(GL_LIGHTING);
+
+	glMaterialfv(GL_FRONT, GL_AMBIENT, bevel_mat_ambient);
+	glMaterialfv(GL_FRONT, GL_SHININESS, bevel_mat_shininess);
+	glMaterialfv(GL_FRONT, GL_SPECULAR, bevel_mat_specular);
+	glMaterialfv(GL_FRONT, GL_DIFFUSE, bevel_mat_diffuse);
+
+	glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
+	glEnable(GL_COLOR_MATERIAL);
+	glShadeModel(GL_SMOOTH);
+	}
+    else
+	{
+	glClearIndex(BACKGROUND);
+	glShadeModel(GL_FLAT);
+	}
+
+    glMatrixMode(GL_PROJECTION);
+    gluPerspective(45, 1.33, 0.1, 100.0);
+    glMatrixMode(GL_MODELVIEW);
+    }
+
+UGL_LOCAL void echoUse(void)
+    {
+    printf("tOlympic keys:\n");
+    printf("       SPACE  Reinitialize\n");
+    printf("         ESC  Exit\n");
+    }
+
+UGL_LOCAL void readKey (UGL_WCHAR key)
+    {
+    switch(key)
+	{
+	case UGL_UNI_SPACE:
+	    ReInit();
+	    break;
+	case UGL_UNI_ESCAPE:
+	    stopWex = 1;
+	    break;
+	}
+    }
+
+UGL_LOCAL void loopEvent(void)
+    {
+    UGL_EVENT event;
+    UGL_INPUT_EVENT * pInputEvent;
+ 
+    UGL_FOREVER
+	{
+	if (uglEventGet (qId, &event, sizeof (event), UGL_NO_WAIT)
+	    != UGL_STATUS_Q_EMPTY)
+            {
+	    pInputEvent = (UGL_INPUT_EVENT *)&event;
+	    
+	    if (pInputEvent->header.type == UGL_EVENT_TYPE_KEYBOARD &&
+		pInputEvent->modifiers & UGL_KEYBOARD_KEYDOWN)
+		readKey(pInputEvent->type.keyboard.key);
+	    }
+
+	drawGL();
+	if (stopWex)
+            break;
+	}
+    }
+
+void windMLOlympic (void);
+
+void uglolympic (void)
+    {
+    taskSpawn("tOlympic", 210, VX_FP_TASK, 100000, (FUNCPTR)windMLOlympic,
+              0,1,2,3,4,5,6,7,8,9);
+    }
+
+void windMLOlympic(void)
+    {
+    UGL_INPUT_DEVICE_ID keyboardDevId;
+    
+    uglInitialize();
+    
+    uglDriverFind (UGL_KEYBOARD_TYPE, 0, (UGL_UINT32 *)&keyboardDevId);
+    
+    if (uglDriverFind (UGL_EVENT_SERVICE_TYPE, 0,
+                       (UGL_UINT32 *)&eventServiceId) == UGL_STATUS_OK)
+        {
+        qId = uglEventQCreate (eventServiceId, 100);
+        }
+    else 
+        {
+        eventServiceId = UGL_NULL;
+        }
+    
+    umc = uglMesaCreateNewContext(UGL_MESA_DOUBLE, NULL);
+    if (umc == NULL)
+        {
+	uglDeinitialize();
+	return;
+        }
+
+    uglMesaMakeCurrentContext(umc, 0, 0, UGL_MESA_FULLSCREEN_WIDTH,
+			      UGL_MESA_FULLSCREEN_HEIGHT);
+
+    uglMesaGetIntegerv(UGL_MESA_RGB, &rgb);
+    
+    initGL();
+
+    echoUse();
+
+    stopWex = 0;
+    loopEvent();
+    
+    if (eventServiceId != UGL_NULL)
+	uglEventQDestroy (eventServiceId, qId);
+    
+    uglMesaDestroyContext();
+    uglDeinitialize();
+    
+    return;
+    }
diff --git a/progs/windml/uglpoint.c b/progs/windml/uglpoint.c
new file mode 100644
index 0000000..e184eaa
--- /dev/null
+++ b/progs/windml/uglpoint.c
@@ -0,0 +1,266 @@
+
+/* uglpoint.c - WindML/Mesa example program */
+
+/* Copyright (C) 2001 by Wind River Systems, Inc */
+
+/*
+ * Mesa 3-D graphics library
+ * Version:  3.5
+ *
+ * The MIT License
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Stephane Raimbault <stephane.raimbault@windriver.com> 
+ */
+
+/*
+DESCRIPTION
+Draw a single point.
+*/
+
+#include <stdio.h>
+#include <math.h>
+
+#include <ugl/ugl.h>
+#include <ugl/uglevent.h>
+#include <ugl/uglinput.h>
+
+#include <GL/uglmesa.h>
+
+#define DOUBLE_BUFFER GL_TRUE
+
+enum {
+    BLACK = 0,
+    RED,
+    GREEN,
+    BLUE,
+    WHITE
+};
+
+UGL_LOCAL GLuint rgb;
+UGL_LOCAL UGL_EVENT_SERVICE_ID eventServiceId;
+UGL_LOCAL UGL_EVENT_Q_ID qId;
+UGL_LOCAL UGL_MESA_CONTEXT umc;
+UGL_LOCAL GLint angleT;
+
+UGL_LOCAL void initGL (void)
+    {
+    /* By passed in RGB mode */
+    uglMesaSetColor(BLACK, 0.0, 0.0, 0.0);
+    uglMesaSetColor(RED, 1.0, 0.0, 0.0);
+    uglMesaSetColor(GREEN, 0.0, 1.0, 0.0);
+    uglMesaSetColor(BLUE, 0.0, 0.0, 1.0);
+    uglMesaSetColor(WHITE, 1.0, 1.0, 1.0);
+    
+    glOrtho(0.0, 1.0, 0.0, 1.0, -20.0, 20.0);
+    
+    glClearColor(0.0, 0.0, 0.0, 0.0);
+    glClearIndex(BLACK);
+    }
+
+UGL_LOCAL void drawGL (void)
+    {
+    GLint i;
+    GLfloat x, y;
+
+    /* Avoid blinking in single buffer */
+    
+    if (DOUBLE_BUFFER)
+	glClear(GL_COLOR_BUFFER_BIT);    
+
+    /* Random points */
+
+    glBegin(GL_POINTS);
+    (rgb) ? glColor3f(1.0, 0.0, 0.0): glIndexi(RED);
+
+    for (i=0; i<150; i++)
+	{
+	x = rand() / (RAND_MAX+1.0);
+        y = rand() / (RAND_MAX+1.0);
+	glVertex2f(x, y);
+	}
+
+    (rgb) ? glColor3f(0.0, 1.0, 0.0): glIndexi(GREEN);
+
+    for (i=0; i<150; i++)
+	{
+	x = (rand() / (RAND_MAX+1.0));
+        y = (rand() / (RAND_MAX+1.0));
+	glVertex2f(x, y);
+	}
+
+    (rgb) ? glColor3f(0.0, 0.0, 1.0): glIndexi(BLUE);
+    glVertex2f(0.5,0.5);
+    
+    for (i=0; i<150; i++)
+	{
+	x = rand() / (RAND_MAX+1.0);
+        y = rand() / (RAND_MAX+1.0);
+	glVertex2f(x, y);
+	}
+
+    glEnd();
+
+    /* Smooth triangle */
+
+    glPushMatrix();
+    glTranslatef(0.5, 0.5, 0);    
+    glRotatef(angleT, 1.0, -1.0, 0.0);
+    angleT = angleT++ % 360;
+    glBegin(GL_TRIANGLES);
+            (rgb) ? glColor3f(1.0, 0.0, 0.0): glIndexi(RED);  
+	    glVertex2f(0.75, 0.25);
+	    (rgb) ? glColor3f(0.0, 1.0, 0.0): glIndexi(GREEN);  
+	    glVertex2f(0.75, 0.75);
+	    (rgb) ? glColor3f(0.0, 0.0, 1.0): glIndexi(BLUE);  
+	    glVertex2f(0.25, 0.75);
+    glEnd();
+    glPopMatrix();
+
+    /* Flush and swap */
+
+    glFlush();
+    
+    if(DOUBLE_BUFFER)
+	uglMesaSwapBuffers();
+    }
+
+/************************************************************************
+*
+* getEvent
+*
+* RETURNS: true or false
+*
+* NOMANUAL
+*
+*/
+
+UGL_LOCAL int getEvent(void)
+    {
+    UGL_EVENT event;
+    UGL_STATUS status;
+    int retVal = 0;
+
+    status = uglEventGet (qId, &event, sizeof (event), UGL_NO_WAIT);
+
+    while (status != UGL_STATUS_Q_EMPTY)
+        {
+	UGL_INPUT_EVENT * pInputEvent = (UGL_INPUT_EVENT *)&event;
+	
+	if (pInputEvent->modifiers & UGL_KEYBOARD_KEYDOWN)
+	    retVal = 1;
+
+	status = uglEventGet (qId, &event, sizeof (event), UGL_NO_WAIT);
+        }
+ 
+    return(retVal);
+    }
+
+void windMLPoint (void);
+
+void uglpoint (void)
+    {
+    taskSpawn("tPoint", 210, VX_FP_TASK, 100000,
+	      (FUNCPTR)windMLPoint, 0,1,2,3,4,5,6,7,8,9);
+    }
+
+void windMLPoint(void)
+    {
+    GLubyte pPixels[4];
+    GLsizei width, height;
+    UGL_INPUT_DEVICE_ID keyboardDevId;
+    
+    angleT = 0;
+
+    uglInitialize();
+    
+    uglDriverFind (UGL_KEYBOARD_TYPE, 0, (UGL_UINT32 *)&keyboardDevId);
+    
+    if (uglDriverFind (UGL_EVENT_SERVICE_TYPE, 0,
+                       (UGL_UINT32 *)&eventServiceId) == UGL_STATUS_OK)
+        {
+        qId = uglEventQCreate (eventServiceId, 100);
+        }
+    else 
+        {
+        eventServiceId = UGL_NULL;
+        }
+    
+    if (DOUBLE_BUFFER)
+	umc = uglMesaCreateNewContext(UGL_MESA_DOUBLE, NULL);
+    else
+	umc = uglMesaCreateNewContext(UGL_MESA_SINGLE, NULL);
+
+    if (umc == NULL)
+        {
+	uglDeinitialize();
+	return;
+        }
+
+    /* Fullscreen */
+
+    uglMesaMakeCurrentContext(umc, 0, 0, UGL_MESA_FULLSCREEN_WIDTH,
+			      UGL_MESA_FULLSCREEN_HEIGHT);
+    
+    /* RGB or CI ? */
+
+    uglMesaGetIntegerv(UGL_MESA_RGB, &rgb);
+    
+    initGL();
+
+    while (!getEvent())
+	drawGL();
+    
+    uglMesaGetIntegerv(UGL_MESA_WIDTH, &width);
+    uglMesaGetIntegerv(UGL_MESA_HEIGHT, &height);
+    
+    printf ("glReadPixel return ");
+    if (rgb)
+	{
+	glReadPixels(width/2, height/2,
+		     1, 1, GL_RGB,
+		     GL_UNSIGNED_BYTE, pPixels);  
+	glFlush();
+	printf ("R:%i G:%i B:%i (RGB)", pPixels[0], pPixels[1], pPixels[2]);
+	}
+    else
+	{
+	glReadPixels(width/2, height/2,
+		     1, 1, GL_COLOR_INDEX,
+		     GL_UNSIGNED_BYTE, pPixels);  
+	glFlush();
+	if (pPixels[0] == BLUE)
+	    printf ("BLUE (CI)");
+	else
+	    printf ("%i (CI))", pPixels[0]);
+	}
+
+    printf(" for %ix%i\n", width/2, height/2);
+    
+    if (eventServiceId != UGL_NULL)
+	uglEventQDestroy (eventServiceId, qId);
+    
+    uglMesaDestroyContext();
+    uglDeinitialize();
+    
+    return;
+    }
diff --git a/progs/windml/uglstencil.c b/progs/windml/uglstencil.c
new file mode 100644
index 0000000..94e9f50
--- /dev/null
+++ b/progs/windml/uglstencil.c
@@ -0,0 +1,233 @@
+
+/* Copyright (c) Mark J. Kilgard, 1994. */
+
+/*
+ * (c) Copyright 1993, Silicon Graphics, Inc.
+ * ALL RIGHTS RESERVED
+ * Permission to use, copy, modify, and distribute this software for
+ * any purpose and without fee is hereby granted, provided that the above
+ * copyright notice appear in all copies and that both the copyright notice
+ * and this permission notice appear in supporting documentation, and that
+ * the name of Silicon Graphics, Inc. not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission.
+ *
+ * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
+ * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
+ * FITNESS FOR A PARTICULAR PURPOSE.  IN NO EVENT SHALL SILICON
+ * GRAPHICS, INC.  BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
+ * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
+ * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
+ * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
+ * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC.  HAS BEEN
+ * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
+ * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * US Government Users Restricted Rights
+ * Use, duplication, or disclosure by the Government is subject to
+ * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
+ * (c)(1)(ii) of the Rights in Technical Data and Computer Software
+ * clause at DFARS 252.227-7013 and/or in similar or successor
+ * clauses in the FAR or the DOD or NASA FAR Supplement.
+ * Unpublished-- rights reserved under the copyright laws of the
+ * United States.  Contractor/manufacturer is Silicon Graphics,
+ * Inc., 2011 N.  Shoreline Blvd., Mountain View, CA 94039-7311.
+ *
+ * OpenGL(TM) is a trademark of Silicon Graphics, Inc.
+ */
+/*  stencil.c
+ *  This program draws two rotated tori in a window.
+ *  A diamond in the center of the window masks out part
+ *  of the scene.  Within this mask, a different model
+ *  (a sphere) is drawn in a different color.
+ */
+
+/*
+ * Conversion to UGL/Mesa by Stephane Raimbault, 2001
+ */
+
+#include <stdio.h>
+#include <math.h>
+
+#include <ugl/ugl.h>
+#include <ugl/uglevent.h>
+#include <ugl/uglinput.h>
+
+#include <GL/uglmesa.h>
+#include <GL/glu.h>
+#include <GL/uglglutshapes.h>
+
+#define YELLOWMAT   1
+#define BLUEMAT 2
+
+UGL_LOCAL UGL_EVENT_SERVICE_ID eventServiceId;
+UGL_LOCAL UGL_EVENT_Q_ID qId;
+UGL_LOCAL UGL_MESA_CONTEXT umc;
+
+UGL_LOCAL void initGL (GLsizei w, GLsizei h)
+    {
+    GLfloat yellow_diffuse[] = { 0.7, 0.7, 0.0, 1.0 };
+    GLfloat yellow_specular[] = { 1.0, 1.0, 1.0, 1.0 };
+
+    GLfloat blue_diffuse[] = { 0.1, 0.1, 0.7, 1.0 };
+    GLfloat blue_specular[] = { 0.1, 1.0, 1.0, 1.0 };
+
+    GLfloat position_one[] = { 1.0, 1.0, 1.0, 0.0 };
+
+    glNewList(YELLOWMAT, GL_COMPILE);
+    glMaterialfv(GL_FRONT, GL_DIFFUSE, yellow_diffuse);
+    glMaterialfv(GL_FRONT, GL_SPECULAR, yellow_specular);
+    glMaterialf(GL_FRONT, GL_SHININESS, 64.0);
+    glEndList();
+
+    glNewList(BLUEMAT, GL_COMPILE);
+    glMaterialfv(GL_FRONT, GL_DIFFUSE, blue_diffuse);
+    glMaterialfv(GL_FRONT, GL_SPECULAR, blue_specular);
+    glMaterialf(GL_FRONT, GL_SHININESS, 45.0);
+    glEndList();
+
+    glLightfv(GL_LIGHT0, GL_POSITION, position_one);
+
+    glEnable(GL_LIGHT0);
+    glEnable(GL_LIGHTING);
+    glDepthFunc(GL_LESS);
+    glEnable(GL_DEPTH_TEST);
+
+    glClearStencil(0x0);
+    glEnable(GL_STENCIL_TEST);
+
+    glClear(GL_STENCIL_BUFFER_BIT);
+
+/* create a diamond shaped stencil area */
+    glMatrixMode(GL_PROJECTION);
+    glLoadIdentity();
+    glOrtho(-3.0, 3.0, -3.0, 3.0, -1.0, 1.0);
+    glMatrixMode(GL_MODELVIEW);
+    glLoadIdentity();
+
+    glStencilFunc (GL_ALWAYS, 0x1, 0x1);
+    glStencilOp (GL_REPLACE, GL_REPLACE, GL_REPLACE);
+    glBegin(GL_QUADS);
+	glVertex3f (-1.0, 0.0, 0.0);
+	glVertex3f (0.0, 1.0, 0.0);
+	glVertex3f (1.0, 0.0, 0.0);
+	glVertex3f (0.0, -1.0, 0.0);
+    glEnd();
+
+    glMatrixMode(GL_PROJECTION);
+    glLoadIdentity();
+    gluPerspective(45.0, (GLfloat) w/(GLfloat) h, 3.0, 7.0);
+    glMatrixMode(GL_MODELVIEW);
+    glLoadIdentity();
+    glTranslatef(0.0, 0.0, -5.0);
+    }
+
+/*  Draw a sphere in a diamond-shaped section in the
+ *  middle of a window with 2 tori.
+ */
+UGL_LOCAL void drawGL(void)
+    {
+    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+    glStencilOp (GL_KEEP, GL_KEEP, GL_KEEP);
+
+/* draw blue sphere where the stencil is 1 */
+    glStencilFunc (GL_EQUAL, 0x1, 0x1);
+    glCallList (BLUEMAT);
+    glutSolidSphere (0.5, 15, 15);
+ 
+/* draw the tori where the stencil is not 1 */
+    glStencilFunc (GL_NOTEQUAL, 0x1, 0x1);
+    glPushMatrix();
+       glRotatef (45.0, 0.0, 0.0, 1.0);
+       glRotatef (45.0, 0.0, 1.0, 0.0);
+       glCallList (YELLOWMAT);
+       glutSolidTorus (0.275, 0.85, 15, 15);
+       glPushMatrix();
+          glRotatef (90.0, 1.0, 0.0, 0.0);
+	  glutSolidTorus (0.275, 0.85, 15, 15);
+       glPopMatrix();
+    glPopMatrix();
+
+    glFlush();
+
+    uglMesaSwapBuffers();
+    }
+
+UGL_LOCAL int getEvent(void)
+    {
+    UGL_EVENT event;
+    UGL_STATUS status;
+    int retVal = 0;
+
+    status = uglEventGet (qId, &event, sizeof (event), UGL_NO_WAIT);
+
+    while (status != UGL_STATUS_Q_EMPTY)
+        {
+	UGL_INPUT_EVENT * pInputEvent = (UGL_INPUT_EVENT *)&event;
+	
+	if (pInputEvent->modifiers & UGL_KEYBOARD_KEYDOWN)
+	    retVal = 1;
+
+	status = uglEventGet (qId, &event, sizeof (event), UGL_NO_WAIT);
+        }
+ 
+    return(retVal);
+    }
+
+void windMLStencil (void);
+
+void uglstencil (void)
+    {
+    taskSpawn("tStencil", 210, VX_FP_TASK, 100000,
+	      (FUNCPTR)windMLStencil, 0,1,2,3,4,5,6,7,8,9);
+    }
+
+void windMLStencil(void)
+    {
+    UGL_INPUT_DEVICE_ID keyboardDevId;
+    GLsizei width, height;
+    
+    uglInitialize();
+    
+    uglDriverFind (UGL_KEYBOARD_TYPE, 0, (UGL_UINT32 *)&keyboardDevId);
+    
+    uglDriverFind (UGL_EVENT_SERVICE_TYPE, 0, (UGL_UINT32 *)&eventServiceId);
+	    
+    qId = uglEventQCreate (eventServiceId, 100);
+    
+    umc = uglMesaCreateNewContextExt(GL_FALSE,
+				     16,
+				     8,
+				     0,0,0,0,
+				     NULL);
+    if (umc == NULL)
+	{
+	uglDeinitialize();
+	return;
+	}
+
+    /* Fullscreen */
+
+    uglMesaMakeCurrentContext(umc, 0, 0, UGL_MESA_FULLSCREEN_WIDTH,
+			      UGL_MESA_FULLSCREEN_HEIGHT);
+    
+    uglMesaGetIntegerv(UGL_MESA_WIDTH, &width);
+    uglMesaGetIntegerv(UGL_MESA_HEIGHT, &height);
+    
+    initGL(width, height);
+
+    drawGL();
+	    
+    while (!getEvent());
+	    
+    uglEventQDestroy (eventServiceId, qId);
+    
+    uglMesaDestroyContext();
+    uglDeinitialize();
+    
+    return;
+    }
+
diff --git a/progs/windml/uglteapot.c b/progs/windml/uglteapot.c
new file mode 100644
index 0000000..26c766d
--- /dev/null
+++ b/progs/windml/uglteapot.c
@@ -0,0 +1,290 @@
+/*
+ * Mesa 3-D graphics library
+ * Version:  3.5
+ *
+ * The MIT License
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+/*
+ * Linux Magazine July 2001
+ * Conversion to UGL/Mesa from GLUT by Stephane Raimbault, 2001
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <math.h>
+
+#include <ugl/ugl.h>
+#include <ugl/uglevent.h>
+#include <ugl/uglinput.h>
+#include <ugl/uglucode.h>
+
+#include <GL/uglmesa.h>
+#include <GL/glu.h>
+
+/* Need GLUT_SHAPES */
+
+#include <GL/uglglutshapes.h>
+
+#ifndef PI
+#define PI 3.14159265
+#endif
+
+UGL_LOCAL UGL_EVENT_SERVICE_ID eventServiceId;
+UGL_LOCAL UGL_EVENT_Q_ID qId;
+UGL_LOCAL UGL_MESA_CONTEXT umc;
+UGL_LOCAL volatile UGL_BOOL stopWex;
+
+UGL_LOCAL GLint angle;
+UGL_LOCAL GLfloat Sin[360], Cos[360];
+UGL_LOCAL GLfloat L0pos[]={0.0, 2.0, -1.0};
+UGL_LOCAL GLfloat L0dif[]={0.3, 0.3, 0.8};
+UGL_LOCAL GLfloat L1pos[]={2.0, 2.0, 2.0};
+UGL_LOCAL GLfloat L1dif[]={0.5, 0.5, 0.5};
+UGL_LOCAL GLfloat Mspec[3];
+UGL_LOCAL GLfloat Mshiny;
+UGL_LOCAL GLuint theTeapot;
+
+UGL_LOCAL void calcTableCosSin()
+{
+	int i;
+	for(i=0;i<360;i++) {
+		Cos[i] = cos(((float)i)/180.0*PI);
+		Sin[i] = sin(((float)i)/180.0*PI);
+	}
+}
+
+UGL_LOCAL void initGL(void)
+    {
+    glClearColor(0.0, 0.0, 0.0, 0.0);
+    glColor3f(1.0, 0.0, 0.0);
+    glEnable(GL_DEPTH_TEST);
+    
+    glShadeModel(GL_SMOOTH);
+    glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE);
+    glEnable(GL_LIGHTING);
+    glEnable(GL_LIGHT0);
+    glEnable(GL_LIGHT1);
+    glLightfv(GL_LIGHT0, GL_DIFFUSE, L0dif);
+    glLightfv(GL_LIGHT0, GL_SPECULAR, L0dif);
+    glLightfv(GL_LIGHT1, GL_DIFFUSE, L1dif);
+    glLightfv(GL_LIGHT1, GL_SPECULAR, L1dif);
+    
+    glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, Mspec);
+    glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, Mshiny);
+    
+    glMatrixMode(GL_PROJECTION);
+    glLoadIdentity();
+    gluPerspective(45.0, 1.0, 0.1, 10.0);
+    glMatrixMode(GL_MODELVIEW);
+
+    theTeapot = glGenLists(1);
+    glNewList(theTeapot, GL_COMPILE);
+    glutSolidTeapot(1.0);
+    glEndList();
+
+    }
+
+UGL_LOCAL void drawGL()
+    {
+    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+    
+    glLoadIdentity();
+    
+    gluLookAt(4.5*Cos[angle], 2.0,4.5*Sin[angle],0.0,0.0,0.0,0.0,
+	      1.0,0.0);
+    glLightfv(GL_LIGHT0, GL_POSITION, L0pos);
+    glLightfv(GL_LIGHT1, GL_POSITION, L1pos);
+
+    glCallList(theTeapot);
+
+    glFlush();
+    
+    uglMesaSwapBuffers();
+    }
+
+UGL_LOCAL void echoUse(void)
+    {
+    printf("tTeapot keys:\n");
+    printf("        Left  Counter clockwise rotation (y-axis)\n");
+    printf("       Right  Clockwise rotation (y-axis)\n");
+    printf("           j  Enable/disable Light0\n");
+    printf("           k  Enable/disable Light1\n");
+    printf("           m  Add specular\n");
+    printf("           l  Remove specular\n");
+    printf("           o  Add shininess\n");
+    printf("           p  Remove shininess\n");
+    printf("         ESC  Exit\n");
+    }
+
+
+UGL_LOCAL void readKey (UGL_WCHAR key)
+    {
+    switch(key)
+	{
+	case UGL_UNI_RIGHT_ARROW:
+	    angle +=2;
+	    if (angle>= 360)
+		angle-=360;
+	    break;
+	case UGL_UNI_LEFT_ARROW:
+	    angle -=2;
+	    if (angle<0)
+		angle+=360;
+	    break;
+	case 'j':
+	    glIsEnabled(GL_LIGHT0) ?
+		glDisable(GL_LIGHT0) : glEnable(GL_LIGHT0);
+	    break;
+	case 'k':
+	    glIsEnabled(GL_LIGHT1) ?
+		glDisable(GL_LIGHT1) : glEnable(GL_LIGHT1);
+	    break;
+	case 'm':
+	    Mspec[0]+=0.1;
+	    if(Mspec[0]>1)
+		Mspec[0]=1;
+	    Mspec[1]+=0.1;
+	    if(Mspec[1]>1)
+		Mspec[1]=1;
+	    Mspec[2]+=0.1;
+	    if(Mspec[2]>1)
+		Mspec[2]=1;
+	    glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, Mspec);
+	    break;
+	case 'l':
+	    Mspec[0]-=0.1;
+	    if(Mspec[0]>1)
+		Mspec[0]=1;
+	    Mspec[1]-=0.1;
+	    if(Mspec[1]>1)
+		Mspec[1]=1;
+	    Mspec[2]-=0.1;
+	    if(Mspec[2]>1)
+		Mspec[2]=1;
+	    glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, Mspec);
+	    break;
+	case 'o':
+	    Mshiny -= 1;
+	    if (Mshiny<0)
+		Mshiny=0;
+	    glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, Mshiny);
+	    break;
+	case 'p':
+	    Mshiny += 1;
+	    if (Mshiny>128)
+		Mshiny=128;
+	    glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, Mshiny);
+	    break;
+	case UGL_UNI_ESCAPE:
+	    stopWex = UGL_TRUE;
+	    break;
+	}
+    }
+
+UGL_LOCAL void loopEvent(void)
+    {
+    UGL_EVENT event;
+    UGL_INPUT_EVENT * pInputEvent;
+ 
+    UGL_FOREVER
+	{
+	if (uglEventGet (qId, &event, sizeof (event), UGL_NO_WAIT)
+	    != UGL_STATUS_Q_EMPTY)
+            {
+	    pInputEvent = (UGL_INPUT_EVENT *)&event;
+	    
+	    if (pInputEvent->header.type == UGL_EVENT_TYPE_KEYBOARD &&
+		pInputEvent->modifiers & UGL_KEYBOARD_KEYDOWN)
+		readKey(pInputEvent->type.keyboard.key);
+	    }
+
+	drawGL();
+	if (stopWex)
+            break;
+	}
+    }
+
+void windMLTeapot (void);
+
+void uglteapot (void)
+    {
+    taskSpawn ("tTeapot", 210, VX_FP_TASK, 100000, (FUNCPTR)windMLTeapot,
+              0,1,2,3,4,5,6,7,8,9);
+    }
+
+void windMLTeapot (void)
+    {
+    UGL_INPUT_DEVICE_ID keyboardDevId;
+    GLsizei displayWidth, displayHeight;
+    GLsizei x, y, w, h;
+    
+    angle = 45;
+    Mspec[0] = 0.5;
+    Mspec[1] = 0.5;
+    Mspec[2] = 0.5;
+    Mshiny = 50;
+    
+    uglInitialize ();
+
+    uglDriverFind (UGL_KEYBOARD_TYPE, 0,
+		   (UGL_UINT32 *)&keyboardDevId);
+
+    uglDriverFind (UGL_EVENT_SERVICE_TYPE, 0, (UGL_UINT32 *)&eventServiceId);
+
+    qId = uglEventQCreate (eventServiceId, 100);
+
+    /* Double buffering */
+    umc = uglMesaCreateNewContext (UGL_MESA_DOUBLE, NULL);
+    if (umc == NULL)
+        {
+	uglDeinitialize ();
+	return;
+	}
+
+    uglMesaMakeCurrentContext (umc, 0, 0, 1, 1);
+
+    uglMesaGetIntegerv(UGL_MESA_DISPLAY_WIDTH, &displayWidth);
+    uglMesaGetIntegerv(UGL_MESA_DISPLAY_HEIGHT, &displayHeight);
+    
+    h = (displayHeight*2)/3;
+    w = h;
+    x = (displayWidth-w)/2;
+    y = (displayHeight-h)/2;
+    
+    uglMesaMoveToWindow(x, y);
+    uglMesaResizeToWindow(w, h);
+    
+    calcTableCosSin();
+    
+    initGL ();
+    
+    echoUse();
+
+    stopWex = UGL_FALSE;
+    loopEvent();
+    
+    uglEventQDestroy (eventServiceId, qId);
+    
+    uglMesaDestroyContext();
+    uglDeinitialize ();
+
+    return;
+    }
diff --git a/progs/windml/ugltexcube.c b/progs/windml/ugltexcube.c
new file mode 100644
index 0000000..1ce6666
--- /dev/null
+++ b/progs/windml/ugltexcube.c
@@ -0,0 +1,460 @@
+
+/* ugltexcube.c - WindML/Mesa example program */
+
+/* Copyright (C) 2001 by Wind River Systems, Inc */
+
+/*
+ * Mesa 3-D graphics library
+ * Version:  3.5
+ *
+ * The MIT License
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Stephane Raimbault <stephane.raimbault@windriver.com> 
+ */
+
+/*
+DESCRIPTION
+Draw a textured cube
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+#include <ugl/ugl.h>
+#include <ugl/uglevent.h>
+#include <ugl/uglinput.h>
+#include <GL/uglmesa.h>
+#include <GL/glu.h>
+
+#define IMAGE_FILE "Mesa/windmldemos/wrs_logo.bmp"
+
+UGL_LOCAL UGL_EVENT_SERVICE_ID eventServiceId;
+UGL_LOCAL UGL_EVENT_Q_ID qId;
+UGL_LOCAL UGL_MESA_CONTEXT umc;
+
+UGL_LOCAL GLfloat xrot, yrot, zrot;
+UGL_LOCAL GLuint texture[1];
+UGL_LOCAL GLuint theTexCube;
+
+typedef struct {
+    unsigned long sizeX;
+    unsigned long sizeY;
+    char *data;
+    } TEX_IMAGE;
+
+UGL_LOCAL void cleanUp (void);
+
+UGL_LOCAL GLboolean imageLoad(char *filename, TEX_IMAGE * texImage)
+    {
+    FILE * file = NULL;
+    unsigned long size;
+    unsigned long i;
+    unsigned short int planes;
+    unsigned short int bpp;
+    char temp;		
+    
+    if ((file = fopen(filename, "rb")) == NULL)
+	{
+	printf("File Not Found : %s\n", filename);
+	return GL_FALSE;
+	}
+    
+    fseek(file, 18, SEEK_CUR);
+    
+    if ((i = fread(&texImage->sizeX, 4, 1, file)) != 1)
+	{
+	printf("Error reading width from %s.\n", filename);
+	return GL_FALSE;
+	}
+    
+    printf("Width of %s: %lu\n", filename, texImage->sizeX);
+		    
+    if ((i = fread(&texImage->sizeY, 4, 1, file)) != 1)
+	{
+	printf("Error reading height from %s.\n", filename);
+	return GL_FALSE;
+	}
+
+    printf("Height of %s: %lu\n", filename, texImage->sizeY);
+    size = texImage->sizeX * texImage->sizeY * 3;
+    
+    if ((fread(&planes, 2, 1, file)) != 1)
+	{
+	printf("Error reading planes from %s.\n", filename);
+	return GL_FALSE;
+	}
+    
+    if (planes != 1)
+	{
+	printf("Planes from %s is not 1: %u\n", filename, planes);
+	return GL_FALSE;
+	}
+	
+    if ((i = fread(&bpp, 2, 1, file)) != 1)
+	{
+	printf("Error reading bpp from %s.\n", filename);
+	return GL_FALSE;
+	}
+    
+    if (bpp != 24)
+	{
+	printf("Bpp from %s is not 24: %u\n", filename, bpp);
+	return GL_FALSE;
+	}
+	
+    fseek(file, 24, SEEK_CUR);
+    
+    texImage->data = (char *) malloc(size);
+
+    if (texImage->data == NULL)
+	{
+	printf("Error allocating memory for color-corrected texImage data");
+	return GL_FALSE;
+	}
+    
+    if ((i = fread(texImage->data, size, 1, file)) != 1)
+	{
+	printf("Error reading texImage data from %s.\n", filename);
+	free(texImage->data);
+	return GL_FALSE;
+	}
+    
+    /* bgr -> rgb */
+    
+    for (i=0; i<size; i+=3)
+	{
+	temp = texImage->data[i];
+	texImage->data[i] = texImage->data[i + 2];
+	texImage->data[i + 2] = temp;
+	}
+
+    fclose(file);
+    
+    return GL_TRUE;
+    }
+
+
+UGL_LOCAL void loadGLTexture()
+    {
+    TEX_IMAGE * texImage=NULL;
+
+    texImage = (TEX_IMAGE *) malloc(sizeof(TEX_IMAGE));
+
+    if (texImage == NULL)
+	{
+	printf("Error allocating space for image");
+	cleanUp();
+	exit(1);
+	}
+	
+    if (!imageLoad(IMAGE_FILE, texImage))
+	{
+	printf("Error allocating space for image data");
+	free(texImage);
+	cleanUp();
+	exit(1);
+	}
+	
+    /* Create Texture */
+    glGenTextures(1, &texture[0]);
+    glBindTexture(GL_TEXTURE_2D, texture[0]);
+    glTexImage2D(GL_TEXTURE_2D, 0, 3,
+		 texImage->sizeX, texImage->sizeY,
+		 0, GL_RGB, GL_UNSIGNED_BYTE, texImage->data);
+
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+
+    free(texImage->data);
+    free(texImage);
+    }
+
+UGL_LOCAL void initGL(int width, int height)
+    {
+
+    /* Load the texture(s) */
+    loadGLTexture();
+
+    /* Enable texture mapping */
+    glEnable(GL_TEXTURE_2D);
+
+    /* Clear the background color to black */
+    glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
+
+    glEnable(GL_CULL_FACE);
+    
+    /* Enables smooth color shading */
+    glShadeModel(GL_SMOOTH);
+
+/* glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); */	 
+/* glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST); */
+ 
+    theTexCube = glGenLists(1);
+    glNewList(theTexCube, GL_COMPILE);
+
+    /* Choose the texture to use */
+    glBindTexture(GL_TEXTURE_2D, texture[0]);
+
+    /* Begin drawing a cube */
+    glBegin(GL_QUADS);
+        
+    /* Front face (note that the texture's corners have to match the
+       quad's corners) */
+
+    /* Bottom left of the texture and quad */
+    glTexCoord2f(0.0f, 0.0f);
+    glVertex3f(-1.0f, -1.0f, 1.0f);
+
+    /* Bottom Right Of The Texture and Quad */
+    glTexCoord2f(1.0f, 0.0f);
+    glVertex3f(1.0f, -1.0f, 1.0f);
+
+    /* Top Right Of The Texture and Quad */
+    glTexCoord2f(1.0f, 1.0f);
+    glVertex3f(1.0f, 1.0f, 1.0f);
+    /* Top Left Of The Texture and Quad	*/
+    glTexCoord2f(0.0f, 1.0f);
+    glVertex3f(-1.0f, 1.0f, 1.0f);
+    
+    /* Back Face */
+
+    /* Bottom Right Of The Texture and Quad */
+    glTexCoord2f(1.0f, 0.0f);
+    glVertex3f(-1.0f, -1.0f, -1.0f);
+
+    /* Top Right Of The Texture and Quad */
+    glTexCoord2f(1.0f, 1.0f);
+    glVertex3f(-1.0f, 1.0f, -1.0f);
+
+    /* Top Left Of The Texture and Quad */
+    glTexCoord2f(0.0f, 1.0f);
+    glVertex3f(1.0f, 1.0f, -1.0f);
+
+    /* Bottom Left Of The Texture and Quad */
+    glTexCoord2f(0.0f, 0.0f);
+    glVertex3f(1.0f, -1.0f, -1.0f);
+
+    
+    /* Top Face */
+
+    /* Top Left Of The Texture and Quad */
+    glTexCoord2f(0.0f, 1.0f);
+    glVertex3f(-1.0f, 1.0f, -1.0f);
+
+    /* Bottom Left Of The Texture and Quad */
+    glTexCoord2f(0.0f, 0.0f);
+    glVertex3f(-1.0f, 1.0f, 1.0f);
+
+    /* Bottom Right Of The Texture and Quad */
+    glTexCoord2f(1.0f, 0.0f);
+    glVertex3f(1.0f, 1.0f, 1.0f);
+
+    /* Top Right Of The Texture and Quad */
+    glTexCoord2f(1.0f, 1.0f);
+    glVertex3f(1.0f, 1.0f, -1.0f);
+    
+    /* Bottom Face */
+
+    /* Top Right Of The Texture and Quad */
+    glTexCoord2f(1.0f, 1.0f);
+    glVertex3f(-1.0f, -1.0f, -1.0f);
+
+    /* Top Left Of The Texture and Quad */
+    glTexCoord2f(0.0f, 1.0f);
+    glVertex3f(1.0f, -1.0f, -1.0f);
+
+    /* Bottom Left Of The Texture and Quad */
+    glTexCoord2f(0.0f, 0.0f);
+    glVertex3f(1.0f, -1.0f, 1.0f);
+
+    /* Bottom Right Of The Texture and Quad */
+    glTexCoord2f(1.0f, 0.0f);
+    glVertex3f(-1.0f, -1.0f, 1.0f);
+	
+	
+    /* Right face */
+    /* Bottom Right Of The Texture and Quad */
+    glTexCoord2f(1.0f, 0.0f);
+    glVertex3f(1.0f, -1.0f, -1.0f);
+
+    /* Top Right Of The Texture and Quad */
+    glTexCoord2f(1.0f, 1.0f);
+    glVertex3f(1.0f, 1.0f, -1.0f);
+
+    /* Top Left Of The Texture and Quad */
+    glTexCoord2f(0.0f, 1.0f);
+    glVertex3f(1.0f, 1.0f, 1.0f);
+
+    /* Bottom Left Of The Texture and Quad */
+    glTexCoord2f(0.0f, 0.0f);
+    glVertex3f(1.0f, -1.0f, 1.0f);
+    
+	
+    /* Left Face */
+    /* Bottom Left Of The Texture and Quad */
+    glTexCoord2f(0.0f, 0.0f);
+    glVertex3f(-1.0f, -1.0f, -1.0f);
+
+    /* Bottom Right Of The Texture and Quad */
+    glTexCoord2f(1.0f, 0.0f);
+    glVertex3f(-1.0f, -1.0f, 1.0f);
+
+    /* Top Right Of The Texture and Quad */
+    glTexCoord2f(1.0f, 1.0f);
+    glVertex3f(-1.0f, 1.0f, 1.0f);
+
+    /* Top Left Of The Texture and Quad */
+    glTexCoord2f(0.0f, 1.0f);
+    glVertex3f(-1.0f, 1.0f, -1.0f);
+						   
+    glEnd();		/* done with the polygon */
+    glEndList();
+    
+    glMatrixMode(GL_PROJECTION);
+    /* Reset the projection matrix */
+    glLoadIdentity();
+    /* Calculate the aspect ratio of the window */
+    gluPerspective(45.0f, (GLfloat) width / (GLfloat) height, 0.1f, 100.0f);
+
+    glMatrixMode(GL_MODELVIEW);
+    glLoadIdentity();
+    }
+
+UGL_LOCAL void drawGL() 
+    {
+    glClear(GL_COLOR_BUFFER_BIT);
+
+    /* Reset The View */
+    glPushMatrix();
+    
+    /* Move 8 units into the screen */
+    glTranslatef(0.0f, 0.0f, -8.0f);
+
+    /* Rotate on the X axis */
+    glRotatef(xrot, 1.0f, 0.0f, 0.0f);
+    
+    /* Rotate on the Y axis */
+    glRotatef(yrot, 0.0f, 1.0f, 0.0f);
+
+    /* Rotate On The Z Axis */
+    glRotatef(zrot, 0.0f, 0.0f, 1.0f);
+
+    glCallList(theTexCube);
+    
+    glFlush();
+        
+    uglMesaSwapBuffers();
+
+    glPopMatrix();
+
+    xrot += 1.6f;
+    yrot += 1.6f;
+    zrot += 1.6f;
+} 
+
+UGL_LOCAL int getEvent(void)
+    {
+    UGL_EVENT event;
+    UGL_STATUS status;
+    int retVal = 0;
+
+    status = uglEventGet (qId, &event, sizeof (event), UGL_NO_WAIT);
+
+    while (status != UGL_STATUS_Q_EMPTY)
+        {
+	UGL_INPUT_EVENT * pInputEvent = (UGL_INPUT_EVENT *)&event;
+	
+	if (pInputEvent->modifiers & UGL_KEYBOARD_KEYDOWN)
+	    retVal = 1;
+
+	status = uglEventGet (qId, &event, sizeof (event), UGL_NO_WAIT);
+        }
+ 
+    return(retVal);
+    }
+
+UGL_LOCAL void cleanUp (void)
+    {
+    if (eventServiceId != UGL_NULL)
+	uglEventQDestroy (eventServiceId, qId);
+
+    uglMesaDestroyContext();
+    uglDeinitialize();
+    }
+
+void windMLTexCube (void);
+
+void ugltexcube (void)
+    {
+    taskSpawn("tTexCube", 210, VX_FP_TASK, 100000, (FUNCPTR)windMLTexCube,
+	      0,1,2,3,4,5,6,7,8,9);
+    }
+
+
+void windMLTexCube(void)
+    {
+    GLuint width, height;
+    UGL_INPUT_DEVICE_ID keyboardDevId;
+    
+    uglInitialize();
+
+    uglDriverFind (UGL_KEYBOARD_TYPE, 0, (UGL_UINT32 *)&keyboardDevId);
+
+    if (uglDriverFind (UGL_EVENT_SERVICE_TYPE, 0,
+                       (UGL_UINT32 *)&eventServiceId) == UGL_STATUS_OK)
+        {
+        qId = uglEventQCreate (eventServiceId, 100);
+        }
+    else 
+        {
+        eventServiceId = UGL_NULL;
+        }
+
+    umc = uglMesaCreateNewContext(UGL_MESA_DOUBLE, NULL);
+
+    if (umc == NULL)
+        {
+	uglDeinitialize();
+	return;
+        }
+
+    uglMesaMakeCurrentContext(umc, 0, 0,
+			      UGL_MESA_FULLSCREEN_WIDTH,
+			      UGL_MESA_FULLSCREEN_HEIGHT);
+			      
+
+    uglMesaGetIntegerv(UGL_MESA_WIDTH, &width);
+    uglMesaGetIntegerv(UGL_MESA_HEIGHT, &height);
+
+    initGL(width, height);
+
+    while(!getEvent())
+	drawGL();
+        
+    cleanUp();
+
+    return;
+    }
+
+
diff --git a/progs/windml/ugltexcyl.c b/progs/windml/ugltexcyl.c
new file mode 100644
index 0000000..d83c20b
--- /dev/null
+++ b/progs/windml/ugltexcyl.c
@@ -0,0 +1,399 @@
+/*
+ * Textured cylinder demo: lighting, texturing, reflection mapping.
+ *
+ * Brian Paul  May 1997  This program is in the public domain.
+ *
+ * Conversion to UGL/Mesa by Stephane Raimbault
+ */
+
+/*
+ * $Log: ugltexcyl.c,v $
+ * Revision 1.1  2001/08/20 16:07:11  brianp
+ * WindML driver (Stephane Raimbault)
+ *
+ * Revision 1.5  2001/03/27 17:35:26  brianp
+ * set initial window pos
+ *
+ * Revision 1.4  2000/12/24 22:53:54  pesco
+ * * demos/Makefile.am (INCLUDES): Added -I$(top_srcdir)/util.
+ * * demos/Makefile.X11, demos/Makefile.BeOS-R4, demos/Makefile.cygnus:
+ * Essentially the same.
+ * Program files updated to include "readtex.c", not "../util/readtex.c".
+ * * demos/reflect.c: Likewise for "showbuffer.c".
+ *
+ *
+ * * Makefile.am (EXTRA_DIST): Added top-level regular files.
+ *
+ * * include/GL/Makefile.am (INC_X11): Added glxext.h.
+ *
+ *
+ * * src/GGI/include/ggi/mesa/Makefile.am (EXTRA_HEADERS): Include
+ * Mesa GGI headers in dist even if HAVE_GGI is not given.
+ *
+ * * configure.in: Look for GLUT and demo source dirs in $srcdir.
+ *
+ * * src/swrast/Makefile.am (libMesaSwrast_la_SOURCES): Set to *.[ch].
+ * More source list updates in various Makefile.am's.
+ *
+ * * Makefile.am (dist-hook): Remove CVS directory from distribution.
+ * (DIST_SUBDIRS): List all possible subdirs here.
+ * (SUBDIRS): Only list subdirs selected for build again.
+ * The above two applied to all subdir Makefile.am's also.
+ *
+ * Revision 1.3  2000/09/29 23:09:39  brianp
+ * added fps output
+ *
+ * Revision 1.2  1999/10/21 16:39:06  brianp
+ * added -info command line option
+ *
+ * Revision 1.1.1.1  1999/08/19 00:55:40  jtg
+ * Imported sources
+ *
+ * Revision 3.3  1999/03/28 18:24:37  brianp
+ * minor clean-up
+ *
+ * Revision 3.2  1998/11/05 04:34:04  brianp
+ * moved image files to ../images/ directory
+ *
+ * Revision 3.1  1998/06/23 03:16:51  brianp
+ * added Point/Linear sampling menu items
+ *
+ * Revision 3.0  1998/02/14 18:42:29  brianp
+ * initial rev
+ *
+ */
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <tickLib.h>
+
+#include <ugl/ugl.h>
+#include <ugl/uglucode.h>
+#include <ugl/uglevent.h>
+#include <ugl/uglinput.h>
+
+#include <GL/uglmesa.h>
+#include <GL/glu.h>
+
+#include "../util/readtex.h"
+
+#define TEXTURE_FILE "Mesa/images/reflect.rgb"
+
+#define LIT 1
+#define TEXTURED 2
+#define REFLECT 3
+#define ANIMATE 10
+#define POINT_FILTER 20
+#define LINEAR_FILTER 21
+#define QUIT 100
+#define COUNT_FRAMES
+
+UGL_LOCAL UGL_EVENT_SERVICE_ID eventServiceId;
+UGL_LOCAL UGL_EVENT_Q_ID qId;
+UGL_LOCAL volatile UGL_BOOL stopWex;
+UGL_LOCAL UGL_MESA_CONTEXT umc;
+
+UGL_LOCAL GLuint CylinderObj;
+UGL_LOCAL GLboolean Animate;
+UGL_LOCAL GLboolean linearFilter;
+
+UGL_LOCAL GLfloat Xrot, Yrot, Zrot;
+UGL_LOCAL GLfloat DXrot, DYrot;
+
+UGL_LOCAL GLuint limit;
+UGL_LOCAL GLuint count;
+UGL_LOCAL GLuint tickStart, tickStop, tickBySec;
+
+UGL_LOCAL void cleanUp (void);
+
+UGL_LOCAL void drawGL(void)
+    {
+#ifdef COUNT_FRAMES
+    int time;
+#endif
+
+    glClear( GL_COLOR_BUFFER_BIT );
+    
+    glPushMatrix();
+    glRotatef(Xrot, 1.0, 0.0, 0.0);
+    glRotatef(Yrot, 0.0, 1.0, 0.0);
+    glRotatef(Zrot, 0.0, 0.0, 1.0);
+    glScalef(5.0, 5.0, 5.0);
+    glCallList(CylinderObj);
+    
+    glPopMatrix();
+    
+    uglMesaSwapBuffers();
+    
+    if (Animate)
+	{
+	Xrot += DXrot;
+	Yrot += DYrot;
+	}
+
+#ifdef COUNT_FRAMES
+    if (count > limit)
+        {
+	tickStop = tickGet ();
+	time = (tickStop-tickStart)/tickBySec;
+	printf (" %i fps\n", count/time);
+	tickStart = tickStop;
+	count = 0;
+        }
+    else 
+	count++;
+#endif
+
+    }
+
+UGL_LOCAL void echoUse(void)
+    {
+    printf("Keys:\n");
+    printf("     Up/Down  Rotate on Y\n");
+    printf("  Left/Right  Rotate on X\n");
+    printf("           a  Toggle animation\n");
+    printf("           f  Toggle point/linear filtered\n");
+    printf("           l  Lit\n");
+    printf("           t  Textured\n");
+    printf("           r  Reflect\n"); 
+    printf("         ESC  Exit\n");
+    }
+
+UGL_LOCAL void readKey(UGL_WCHAR key)
+    {
+    float step = 3.0;
+    switch (key)
+	{
+	case 'a':
+	    Animate = !Animate;
+	    break;
+	case 'f':
+	    if(linearFilter)
+		{
+		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
+				GL_NEAREST);
+		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
+				GL_NEAREST);
+		}
+	    else
+		{
+		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
+				GL_LINEAR);
+		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
+				GL_LINEAR);
+		}
+	    linearFilter = !linearFilter;
+	    break;
+	case 'l':
+	    glEnable(GL_LIGHTING);
+	    glDisable(GL_TEXTURE_2D);
+	    glDisable(GL_TEXTURE_GEN_S);
+	    glDisable(GL_TEXTURE_GEN_T);
+	    break;
+	case 't':
+	    glDisable(GL_LIGHTING);
+	    glEnable(GL_TEXTURE_2D);
+	    glDisable(GL_TEXTURE_GEN_S);
+	    glDisable(GL_TEXTURE_GEN_T);
+	    break;
+	case 'r':
+	    glDisable(GL_LIGHTING);
+	    glEnable(GL_TEXTURE_2D);
+	    glEnable(GL_TEXTURE_GEN_S);
+	    glEnable(GL_TEXTURE_GEN_T);
+	    break;
+	case UGL_UNI_UP_ARROW:
+	    Xrot += step;
+	    break;
+	case UGL_UNI_DOWN_ARROW:
+	    Xrot -= step;
+	    break;
+	case UGL_UNI_LEFT_ARROW:
+	    Yrot += step;
+	    break;
+	case UGL_UNI_RIGHT_ARROW:
+	    Yrot -= step;
+	    break;
+	case UGL_UNI_ESCAPE:
+	    stopWex = UGL_TRUE;
+	    break;
+	}
+    }
+
+UGL_LOCAL void loopEvent(void)
+    {
+    UGL_EVENT event;
+    UGL_INPUT_EVENT * pInputEvent;
+ 
+    UGL_FOREVER
+	{
+	if (uglEventGet (qId, &event, sizeof (event), UGL_NO_WAIT)
+	    != UGL_STATUS_Q_EMPTY)
+            {
+	    pInputEvent = (UGL_INPUT_EVENT *)&event;
+	    
+	    if (pInputEvent->header.type == UGL_EVENT_TYPE_KEYBOARD &&
+		pInputEvent->modifiers & UGL_KEYBOARD_KEYDOWN)
+		readKey(pInputEvent->type.keyboard.key);
+	    }
+	
+	drawGL();
+	if (stopWex)
+            break;
+	}
+    }
+
+UGL_LOCAL void initGL(void)
+    {
+    GLUquadricObj *q = gluNewQuadric();
+    CylinderObj = glGenLists(1);
+    glNewList(CylinderObj, GL_COMPILE);
+
+    glTranslatef(0.0, 0.0, -1.0);
+
+    /* cylinder */
+    gluQuadricNormals(q, GL_SMOOTH);
+    gluQuadricTexture(q, GL_TRUE);
+    gluCylinder(q, 0.6, 0.6, 2.0, 24, 1);
+
+    /* end cap */
+    glTranslatef(0.0, 0.0, 2.0);
+    gluDisk(q, 0.0, 0.6, 24, 1);
+
+    /* other end cap */
+    glTranslatef(0.0, 0.0, -2.0);
+    gluQuadricOrientation(q, GLU_INSIDE);
+    gluDisk(q, 0.0, 0.6, 24, 1);
+
+    glEndList();
+    gluDeleteQuadric(q);
+
+    /* lighting */
+    glEnable(GL_LIGHTING);
+    {
+    GLfloat gray[4] = {0.2, 0.2, 0.2, 1.0};
+    GLfloat white[4] = {1.0, 1.0, 1.0, 1.0};
+    GLfloat teal[4] = { 0.0, 1.0, 0.8, 1.0 };
+    glMaterialfv(GL_FRONT, GL_DIFFUSE, teal);
+    glLightfv(GL_LIGHT0, GL_AMBIENT, gray);
+    glLightfv(GL_LIGHT0, GL_DIFFUSE, white);
+    glEnable(GL_LIGHT0);
+    }
+
+    /* fitering = nearest, initially */
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+
+    glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
+    glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);
+
+    glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
+    glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
+
+    if (!LoadRGBMipmaps(TEXTURE_FILE, GL_RGB))
+	{
+	printf("Error: couldn't load texture image\n");
+	cleanUp();
+	exit(1);
+	}
+    
+    glEnable(GL_CULL_FACE);  /* don't need Z testing for convex objects */
+
+    glEnable(GL_LIGHTING);
+
+    glMatrixMode( GL_PROJECTION );
+    glLoadIdentity();
+    glFrustum( -1.0, 1.0, -1.0, 1.0, 10.0, 100.0 );
+    glMatrixMode( GL_MODELVIEW );
+    glLoadIdentity();
+    glTranslatef( 0.0, 0.0, -70.0 );
+    
+    printf("GL_RENDERER   = %s\n", (char *) glGetString(GL_RENDERER));
+    printf("GL_VERSION    = %s\n", (char *) glGetString(GL_VERSION));
+    printf("GL_VENDOR     = %s\n", (char *) glGetString(GL_VENDOR));
+    printf("GL_EXTENSIONS = %s\n", (char *) glGetString(GL_EXTENSIONS));
+
+#ifdef COUNT_FRAMES
+    tickStart = tickGet ();
+    tickBySec = sysClkRateGet ();
+#endif
+
+    }
+
+UGL_LOCAL void cleanUp (void)
+    {
+    uglEventQDestroy (eventServiceId, qId);
+    
+    uglMesaDestroyContext();
+    uglDeinitialize ();
+    }
+
+void windMLTexCyl (void);
+
+void ugltexcyl (void)
+    {
+    taskSpawn ("tTexCyl", 210, VX_FP_TASK, 100000, (FUNCPTR)windMLTexCyl,
+              0,1,2,3,4,5,6,7,8,9);
+    }
+
+void windMLTexCyl (void)
+    {
+    UGL_INPUT_DEVICE_ID keyboardDevId;
+    GLsizei displayWidth, displayHeight;
+    GLsizei x, y, w, h;
+
+    CylinderObj = 0;
+    Animate = GL_TRUE;
+    linearFilter = GL_FALSE;
+    Xrot = 0.0;
+    Yrot = 0.0;
+    Zrot = 0.0;
+    DXrot = 1.0;
+    DYrot = 2.5;
+    limit = 100;
+    count = 1;
+    
+    uglInitialize ();
+
+    uglDriverFind (UGL_KEYBOARD_TYPE, 0,
+		   (UGL_UINT32 *)&keyboardDevId);
+
+    uglDriverFind (UGL_EVENT_SERVICE_TYPE, 0, (UGL_UINT32 *)&eventServiceId);
+
+    qId = uglEventQCreate (eventServiceId, 100);
+    
+    /* Double buffering */
+    umc = uglMesaCreateNewContext (UGL_MESA_DOUBLE, NULL);
+    if (umc == NULL)
+        {
+	uglDeinitialize ();
+	return;
+	}
+
+    uglMesaMakeCurrentContext (umc, 0, 0, 1, 1);
+
+    uglMesaGetIntegerv(UGL_MESA_DISPLAY_WIDTH, &displayWidth);
+    uglMesaGetIntegerv(UGL_MESA_DISPLAY_HEIGHT, &displayHeight);
+    
+    h = (displayHeight*3)/4;
+    w = h;
+    x = (displayWidth-w)/2;
+    y = (displayHeight-h)/2;
+    
+    uglMesaMoveToWindow(x, y);
+    uglMesaResizeToWindow(w, h);
+
+    initGL ();
+    
+    echoUse();
+
+    stopWex = UGL_FALSE;
+    loopEvent();
+
+    cleanUp();
+    
+    return;
+    }
+
diff --git a/progs/windml/wrs_logo.bmp b/progs/windml/wrs_logo.bmp
new file mode 100644
index 0000000..9a9f042
--- /dev/null
+++ b/progs/windml/wrs_logo.bmp
Binary files differ