GLUT_ALPHA;
      else if (strcmp(argv[i],"+stencil")==0)
         BufferMask |= GL_STENCIL_BUFFER_BIT;
      else if (strcmp(argv[i],"+accum")==0)
         BufferMask |= GL_ACCUM_BUFFER_BIT;
      else if (strcmp(argv[i],"-width")==0) {
         Width = atoi(argv[i+1]);
         i++;
      }
      else if (strcmp(argv[i],"-height")==0) {
         Height = atoi(argv[i+1]);
         i++;
      }
      else if (strcmp(argv[i],"+swap")==0) {
         SwapFlag = GL_TRUE;
      }
      else if (strcmp(argv[i],"-swap")==0) {
         SwapFlag = GL_FALSE;
      }
      else
         printf("Unknown option: %s\n", argv[i]);
   }

   if (ColorMode & GLUT_ALPHA)
      printf("Mode:  RGB + Alpha\n");
   else if (ColorMode==GLUT_RGB)
      printf("Mode:  RGB\n");
   else
      printf("Mode:  Color Index\n");
   printf("SwapBuffers: %s\n", SwapFlag ? "yes" : "no" );
   printf("Size: %d x %d\n", Width, Height);
   printf("Buffers: ");
   if (BufferMask & GL_COLOR_BUFFER_BIT)  printf("color ");
   if (BufferMask & GL_DEPTH_BUFFER_BIT)  printf("depth ");
   if (BufferMask & GL_STENCIL_BUFFER_BIT)  printf("stencil ");
   if (BufferMask & GL_ACCUM_BUFFER_BIT)  printf("accum ");
   printf("\n");
}


static void Help( const char *program )
{
   printf("%s options:\n", program);
   printf("  +rgb       RGB mode\n");
   printf("  +ci        color index mode\n");
   printf("  -color     don't clear color buffer\n");
   printf("  +alpha     clear alpha buffer\n");
   printf("  +depth     clear depth buffer\n");
   printf("  +stencil   clear stencil buffer\n");
   printf("  +accum     clear accum buffer\n");
   printf("  +swap      also do SwapBuffers\n");
   printf("  -swap      don't do SwapBuffers\n");
}


int main( int argc, char *argv[] )
{
   printf("For options:  %s -help\n", argv[0]);

   Init( argc, argv );

   glutInit( &argc, argv );
   glutInitWindowSize( (int) Width, (int) Height );
   glutInitWindowPosition( 0, 0 );

   glutInitDisplayMode( ColorMode | GLUT_DOUBLE | GLUT_DEPTH | GLUT_STENCIL | GLUT_ACCUM );

   glutCreateWindow( argv[0] );

   if (argc==2 && strcmp(argv[1],"-help")==0) {
      Help(argv[0]);
      return 0;
   }

   glutReshapeFunc( Reshape );
   glutKeyboardFunc( Key );
   glutDisplayFunc( Display );
   glutIdleFunc( Idle );

   glutMainLoop();
   return 0;
}
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             # Makefile for GLUT-based demo programs for VMS
# contributed by Jouk Jansen  joukj@crys.chem.uva.nl


.first
	define gl [-.include.gl]

.include [-]mms-config.

##### MACROS #####

INCDIR = [-.include]
CFLAGS = /include=$(INCDIR)/prefix=all

.ifdef SHARE
GL_LIBS = $(XLIBS)
.else
GL_LIBS = [-.lib]libGLUT/l,libMesaGLU/l,libMesaGL/l,$(XLIBS)
.endif

LIB_DEP = [-.lib]$(GL_LIB) [-.lib]$(GLU_LIB) [-.lib]$(GLUT_LIB)

PROGS = bounce.exe;,clearspd.exe;,drawpix.exe;,gamma.exe;,gears.exe;,\
	glinfo.exe;,glutfx.exe;,isosurf.exe;,morph3d.exe;,osdemo.exe;,\
	paltex.exe;,pointblast.exe;,reflect.exe;,spectex.exe;,stex3d.exe;,\
	tessdemo.exe;,texcyl.exe;,texobj.exe;,trispd.exe;,winpos.exe;


##### RULES #####
.obj.exe :
	link $(MMS$TARGET_NAME),$(GL_LIBS)

##### TARGETS #####
default :
	$(MMS)$(MMSQUALIFIERS) $(PROGS)

clean :
	delete *.obj;*

realclean :
	delete $(PROGS)
	delete *.obj;*

bounce.exe; : bounce.obj $(LIB_DEP)
clearspd.exe; : clearspd.obj $(LIB_DEP)
drawpix.exe; : drawpix.obj $(LIB_DEP)
gamma.exe; : gamma.obj $(LIB_DEP)
gears.exe; : gears.obj $(LIB_DEP)
glinfo.exe; : glinfo.obj $(LIB_DEP)
glutfx.exe; : glutfx.obj $(LIB_DEP)
isosurf.exe; : isosurf.obj $(LIB_DEP)
morph3d.exe; : morph3d.obj $(LIB_DEP)
osdemo.exe; : osdemo.obj $(LIB_DEP)
paltex.exe; : paltex.obj $(LIB_DEP)
pointblast.exe; : pointblast.obj $(LIB_DEP)
reflect.exe; : reflect.obj $(LIB_DEP)
spectex.exe; : spectex.obj $(LIB_DEP)
stex3d.exe; : stex3d.obj $(LIB_DEP)
tessdemo.exe; : tessdemo.obj $(LIB_DEP)
texcyl.exe; : texcyl.obj $(LIB_DEP)
texobj.exe; : texobj.obj $(LIB_DEP)
trispd.exe; : trispd.obj $(LIB_DEP)
winpos.exe; : winpos.obj $(LIB_DEP)
                                                                                                                                                                                                                                                                                                                                                                                                                                    on Functions

@@deftypefun GList* g_list_alloc (void)
@@end deftypefun

@@deftypefun void g_list_free (GList *@@var{list})
@@end deftypefun

@@deftypefun void g_list_free_1 (GList *@@var{list})
@@end deftypefun

@@deftypefun GList* g_list_append (GList *@@var{list}, gpointer @@var{data})
@@end deftypefun

@@deftypefun GList* g_list_prepend (GList *@@var{list}, gpointer @@var{data})
@@end deftypefun

@@deftypefun GList* g_list_insert (GList *@@var{list}, gpointer @@var{data}, gint @@var{position})
@@end deftypefun

@@deftypefun GList* g_list_insert_sorted (GList *@@var{list}, gpointer @@var{data}, GCompareFunc @@var{func})
@@end deftypefun

@@deftypefun GList* g_list_concat (GList *@@var{list1}, GList *@@var{list2})
@@end deftypefun

@@deftypefun GList* g_list_remove (GList *@@var{list}, gpointer @@var{data})
@@end deftypefun

@@deftypefun GList* g_list_remove_link (GList *@@var{list}, GList *@@var{link})
@@end deftypefun

@@deftypefun GList* g_list_reverse (GList *@@var{list})
@@end deftypefun

@@deftypefun GList* g_list_nth (GList *@@var{list}, gint @@var{n})
@@end deftypefun

@@deftypefun GList* g_list_find (GList *@@var{list}, gpointer @@var{data})
@@end deftypefun

@@deftypefun GList* g_list_last (GList *@@var{list})
@@end deftypefun

@@deftypefun GList* g_list_first (GList *@@var{list})
@@end deftypefun

@@deftypefun gint g_list_length (GList *@@var{list})
@@end deftypefun

@@deftypefun void g_list_foreach (GList *@@var{list}, GFunc @@var{func}, gpointer @@var{user_data})
@@end deftypefun

@@node Signly linked lists, List allocators, Doubly linked lists, Top
@@comment node-name, next, previous, up
@@chapter Signly linked lists

@@subsection Functions
@@deftypefun GSList* g_slist_alloc (void)
@@end deftypefun

@@deftypefun void g_slist_free (GSList *@@var{list})
@@end deftypefun

@@deftypefun void g_slist_free_1 (GSList *@@var{list})
@@end deftypefun

@@deftypefun GSList* g_slist_append (GSList *@@var{list}, gpointer @@var{data})
@@end deftypefun

@@deftypefun GSList* g_slist_prepend (GSList *@@var{list}, gpointer @@var{data})
@@end deftypefun

@@deftypefun GSList* g_slist_insert (GSList *@@var{list}, gpointer @@var{data}, gint @@var{position})
@@end deftypefun

@@deftypefun GSList* g_slist_insert_sorted (GSList *@@var{list}, gpointer @@var{data}, GCompareFunc @@var{func})
@@end deftypefun

@@deftypefun GSList* g_slist_concat (GSList *@@var{list1}, GSList *@@var{list2})
@@end deftypefun

@@deftypefun GSList* g_slist_remove (GSList *@@var{list}, gpointer @@var{data})
@@end deftypefun

@@deftypefun GSList* g_slist_remove_link (GSList *@@var{list}, GSList *@@var{link})
@@end deftypefun

@@deftypefun GSList* g_slist_reverse (GSList *@@var{list})
@@end deftypefun

@@deftypefun GSList* g_slist_nth (GSList *@@var{list}, gint @@var{n})
@@end deftypefun

@@deftypefun GSList* g_slist_find (GSList *@@var{list}, gpointer @@var{data})
@@end deftypefun

@@deftypefun GSList* g_slist_last (GSList *@@var{list})
@@end deftypefun

@@deftypefun gint g_slist_length (GSList *@@var{list})
@@end deftypefun

@@deftypefun void g_slist_foreach (GSList *@@var{list}, GFunc @@var{func}, gpointer @@var{user_data})
@@end deftypefun

@@node List allocators, Hash tables, Signly linked lists, Top
@@comment node-name, next, previous, up
@@chapter List allocators

@@subsection Functions

@@deftypefun GListAllocator* g_list_allocator_new (void)
@@end deftypefun

@@deftypefun void g_list_allocator_free (GListAllocator *@@var{allocator})
@@end deftypefun

@@deftypefun GListAllocator* g_slist_set_allocator (GListAllocator *@@var{allocator})
@@end deftypefun

@@deftypefun GListAllocator* g_list_set_allocator (GListAllocator *@@var{allocator})
@@end deftypefun

@@node Hash tables, Caches, List allocators, Top
@@comment node-name, next, previous, up
@@chapter Hash tables

@@subsection Functions

@@deftypefun GHashTable* g_hash_table_new (GHashFunc @@var{hash_func}, GCompareFunc @@var{key_compare_func})
@@end deftypefun

@@deftypefun void g_hash_table_destroy (GHashTable *@@var{hash_table})
@@end deftypefun

@@deftypefun void g_hash_table_insert (GHashTable *@@var{hash_table}, gpointer @@var{key}, gpointer @@var{value})
@@end deftypefun

@@deftypefun void g_hash_table_remove (GHashTable *@@var{hash_table}, gpointer @@var{key})
@@end deftypefun

@@deftypefun gpointer g_hash_table_lookup (GHashTable *@@var{hash_table}, gpointer @@var{key})
@@end deftypefun

@@deftypefun void g_hash_table_freeze (GHashTable *@@var{hash_table})
@@end deftypefun

@@deftypefun void g_hash_table_thaw (GHashTable *@@var{hash_table})
@@end deftypefun

@@deftypefun void g_hash_table_foreach (GHashTable *@@var{hash_table}, GHFunc @@var{func}, gpointer @@var{user_data})
@@end deftypefun

@@node Caches, Trees, Hash tables, Top
@@comment node-name, next, previous, up
@@chapter Cache handling

@@subsection Functions

@@deftypefun GCache* g_cache_new (GCacheNewFunc @@var{value_new_func}, GCacheDestroyFunc @@var{value_destroy_func}, GCacheDupFunc @@var{key_dup_func}, GCacheDestroyFunc @@var{key_destroy_func}, GHashFunc @@var{hash_key_func}, GHashFunc @@var{hash_value_func}, GCompareFunc @@var{key_compare_func})
@@end deftypefun

@@deftypefun void g_cache_destroy (GCache *@@var{cache})
@@end deftypefun

@@deftypefun gpointer g_cache_insert (GCache *@@var{cache}, gpointer @@var{key})
@@end deftypefun

@@deftypefun void g_cache_remove (GCache *@@var{cache}, gpointer @@var{key})
@@end deftypefun

@@deftypefun void g_cache_key_foreach (GCache *@@var{cache}, GHFunc @@var{func}, gpointer @@var{user_data})
@@end deftypefun

@@deftypefun void g_cache_value_foreach (GCache *@@var{cache}, GHFunc @@var{func}, gpointer @@var{user_data})
@@end deftypefun

@@node Trees, Memory, Caches, Top
@@comment node-name, next, previous, up
@@chapter Tree handling

@@subsection Functions

@@deftypefun GTree* g_tree_new (GCompareFunc @@var{key_compare_func})
@@end deftypefun

@@deftypefun void g_tree_destroy (GTree *@@var{tree})
@@end deftypefun

@@deftypefun void g_tree_remove (GTree *@@var{tree}, gpointer @@var{key}, gpointer @@var{value})
@@end deftypefun

@@deftypefun gpointer g_tree_lookup (GTree *@@var{tree}, gpointer @@var{key})
@@end deftypefun

@@deftypefun void g_tree_traverse (GTree *@@var{tree}, GTraverseFunc @@var{traverse_func}, GTraverseType @@var{traverse_type}, gpointer @@var{data}
@@end deftypefun

@@deftypefun gpointer g_tree_search (GTree *@@var{tree}, GSearchFunc @@var{search_func}, gpointer @@var{data})
@@end deftypefun

@@deftypefun gint g_tree_height (GTree *@@var{tree})
@@end deftypefun

@@deftypefun gint g_tree_nnodes (GTree *@@var{tree})
@@end deftypefun

@@node Memory, Timers, Trees, Top
@@comment node-name, next, previous, up
@@chapter Memory handling

@@subsection Functions

@@deftypefun gpointer g_malloc (gulong @@var{size})
@@end deftypefun

@@deftypefun gpointer g_malloc0 (gulong @@var{size})
@@end deftypefun

@@deftypefun gpointer g_realloc (gpointer @@var{mem}, gulong @@var{size})
@@end deftypefun

@@deftypefun void g_mem_profile (void)
@@end deftypefun

@@deftypefun void g_mem_check (gpointer @@var{mem})
@@end deftypefun

@@deftypefun GMemChunk* g_mem_chunk_new (gchar *@@var{name}, gint @@var{atom_/* $Id: drawpix.c,v 3.3 1999/03/28 18:18:33 brianp Exp $ */

/*
 * glDrawPixels demo/test/benchmark
 * 
 * Brian Paul   September 25, 1997  This file is in the public domain.
 */

/*
 * $Log: drawpix.c,v $
 * 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 <GL/glut.h>

#include "../util/readtex.c"  /* a hack, I know */

#define IMAGE_FILE "../images/girl.rgb"

static int ImgWidth, ImgHeight;
static GLenum ImgFormat;
static GLubyte *Image = NULL;

static int Xpos, Ypos;
static int SkipPixels, SkipRows;
static int DrawWidth, DrawHeight;
static int Scissor = 0;
static float Xzoom, Yzoom;



static void Reset( void )
{
   Xpos = Ypos = 20;
   DrawWidth = ImgWidth;
   DrawHeight = ImgHeight;
   SkipPixels = SkipRows = 0;
   Scissor = 0;
   Xzoom = Yzoom = 1.0;
}


static void Display( void )
{
   glClear( GL_COLOR_BUFFER_BIT );

#if 0
   glRasterPos2i(Xpos, Ypos);
#else
   /* This allows negative raster positions: */
   glRasterPos2i(0, 0);
   glBitmap(0, 0, 0, 0, Xpos, Ypos, NULL);
#endif

   glPixelStorei(GL_UNPACK_SKIP_PIXELS, SkipPixels);
   glPixelStorei(GL_UNPACK_SKIP_ROWS, SkipRows);

   glPixelZoom( Xzoom, Yzoom );

   if (Scissor)
      glEnable(GL_SCISSOR_TEST);

   glDrawPixels(DrawWidth, DrawHeight, ImgFormat, GL_UNSIGNED_BYTE, Image);

   glDisable(GL_SCISSOR_TEST);

   glutSwapBuffers();
}


static void Benchmark( void )
{
   int startTime, endTime;
   int draws = 500;
   double seconds, pixelsPerSecond;

   printf("Benchmarking...\n");
   /* GL set-up */
   glPixelStorei(GL_UNPACK_SKIP_PIXELS, SkipPixels);
   glPixelStorei(GL_UNPACK_SKIP_ROWS, SkipRows);
   glPixelZoom( Xzoom, Yzoom );
   if (Scissor)
      glEnable(GL_SCISSOR_TEST);

   /* Run timing test */
   draws = 0;
   startTime = glutGet(GLUT_ELAPSED_TIME);
   do {
      glDrawPixels(DrawWidth, DrawHeight, ImgFormat, GL_UNSIGNED_BYTE, Image);
      draws++;
      endTime = glutGet(GLUT_ELAPSED_TIME);
   } while (endTime - startTime < 4000);   /* 4 seconds */

   /* GL clean-up */
   glDisable(GL_SCISSOR_TEST);

   /* Results */
   seconds = (double) (endTime - startTime) / 1000.0;
   pixelsPerSecond = draws * DrawWidth * DrawHeight / seconds;
   printf("Result:  %d draws in %f seconds = %f pixels/sec\n",
          draws, seconds, pixelsPerSecond);
}


static void Reshape( int width, int height )
{
   glViewport( 0, 0, width, height );
   glMatrixMode( GL_PROJECTION );
   glLoadIdentity();
   glOrtho( 0.0, width, 0.0, height, -1.0, 1.0 );
   glMatrixMode( GL_MODELVIEW );
   glLoadIdentity();

   glScissor(width/4, height/4, width/2, height/2);
}


static void Key( unsigned char key, int x, int y )
{
   (void) x;
   (void) y;
   switch (key) {
      case ' ':
         Reset();
         break;
      case 'w':
  