home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / exampleCode / stereo / GL_5.2 / backg.c next >
Encoding:
C/C++ Source or Header  |  1994-08-02  |  2.2 KB  |  112 lines

  1. /*
  2.  * Copyright (C) 1991, 1992, 1993, 1994, Silicon Graphics, Inc.
  3.  * All Rights Reserved.
  4.  *
  5.  * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  6.  * the contents of this file may not be disclosed to third parties, copied or
  7.  * duplicated in any form, in whole or in part, without the prior written
  8.  * permission of Silicon Graphics, Inc.
  9.  *
  10.  * RESTRICTED RIGHTS LEGEND:
  11.  * Use, duplication or disclosure by the Government is subject to restrictions
  12.  * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  13.  * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  14.  * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  15.  * rights reserved under the Copyright Laws of the United States.
  16.  */
  17. /*
  18.  *    texback - 
  19.  *        make a two colored textured background.
  20.  *
  21.  *                Paul Haeberli - 1984
  22.  *
  23.  *      Modified by Thant Tessman, then Gavin Bell to do stereo, 1990
  24.  */
  25. #include <stdio.h>
  26. #include <string.h>
  27.  
  28. #include "stereo.h"
  29.  
  30.  
  31. #define SEP 0
  32.  
  33. /*
  34.  * Local function prototypes
  35.  */
  36. void background();
  37. void draw_pattern();
  38.  
  39. main(argc,argv)
  40. int argc;
  41. char **argv;
  42. {
  43.     int dev;
  44.     short val;
  45.  
  46.     prefposition(0, getgdesc(GD_XPMAX), 0, getgdesc(GD_YPMAX));
  47.  
  48.     {    /* Open window with name of executable */
  49.         char *t;
  50.         winopen((t=strrchr(argv[0], '/')) != NULL ? t+1 : argv[0]);
  51.     }
  52.  
  53.     stereo_on(STR_RECT);    /* From libstereo.a */
  54.  
  55.     qdevice(ESCKEY);    /* Need to turn off stereo on quit */
  56.     qdevice(WINQUIT);    /* Need to turn off stereo on quit */
  57.     qdevice(LEFTMOUSE);   /* Eat up mouse events */
  58.     qdevice(MIDDLEMOUSE);   /* Eat up mouse events */
  59.  
  60.     background();
  61.     while (dev = qread(&val)) 
  62.     {
  63.         switch(dev)
  64.         {
  65.         case REDRAW:
  66.             background();
  67.             break;
  68.         case ESCKEY:
  69.         case WINQUIT:
  70.             stereo_off();    /* From libstereo.a */
  71.             exit(0);
  72.         }
  73.     }
  74. }
  75.  
  76. void
  77. background()
  78. {
  79.     color(9);
  80.     clear();
  81.  
  82.     color(10);
  83.     draw_pattern();
  84. }
  85.  
  86. void
  87. draw_pattern()
  88. {
  89.     int i, j;
  90.  
  91.     color(BLACK);
  92.     rectfi(0, YMAXSTEREO, XMAXSCREEN, YOFFSET);
  93.  
  94.     for (i=0; i<=XMAXSCREEN; i+=40)
  95.     {
  96.         move2i(i-SEP, 0);
  97.         draw2i(i-SEP, YMAXSTEREO);
  98.  
  99.         move2i(i+SEP, 0+YOFFSET);
  100.         draw2i(i+SEP, YMAXSTEREO+YOFFSET);
  101.     }
  102.  
  103.     for (j=0; j<=YMAXSTEREO; j+=20)
  104.     {
  105.         move2i(0, j);
  106.         draw2i(XMAXSCREEN, j);
  107.  
  108.         move2i(0, j+YOFFSET);
  109.         draw2i(XMAXSCREEN, j+YOFFSET);
  110.     }
  111. }
  112.