home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / alt / sources / 2608 / draw_starfield_xgl.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-11-23  |  1.7 KB  |  100 lines

  1. #ifndef lint
  2. static    char    sccsid[] = "@(#)draw_starfield_xgl.c 1.1 92/05/28 SMI" ;
  3.     /* from draw_starfield_xgl.c 1.1 90/07/23 SMI */
  4. #endif
  5.  
  6. /*
  7.  * Copyright (c) 1986 by Sun Microsystems, Inc.
  8.  */
  9.  
  10. /*
  11.  * this file draws all the stars
  12.  */
  13.  
  14.  
  15. #include <stdio.h>
  16. #include <math.h>
  17. #include "graphics.h"
  18. #include "dstar.h"
  19.  
  20. static    Pt3d    starfield[] = {
  21. #include "starfield.h"
  22.         } ;
  23.  
  24. #define    NSTAR    (sizeof(starfield)/sizeof(Pt3d))
  25.  
  26. static    Xgl_pt_flag_f3d    starpts[NSTAR][2] ;
  27.  
  28. extern    int    debug_level ;
  29.  
  30. static    int    initialized = 0 ;
  31.  
  32.  
  33. starfield_init()
  34. {
  35.     int    i ;
  36.  
  37.     for(i=0; i<NSTAR; ++i)
  38.     {
  39.       starpts[i][0].x = starfield[i].x ;
  40.       starpts[i][0].y = starfield[i].y ;
  41.       starpts[i][0].z = starfield[i].z ;
  42.       starpts[i][1] = starpts[i][0] ;
  43.       starpts[i][0].flag = 0 ;
  44.       starpts[i][1].flag = 1 ;
  45.     }
  46.     initialized = 1 ;
  47. }
  48.  
  49. draw_starfield()
  50. {
  51.     int    i ;
  52.     int    nwhite, nother ;
  53.     int    color ;
  54. register Pt3d    *ptr ;
  55. register int    fit ;
  56.     Xgl_pt_list    pts ;
  57.  
  58.     if( !initialized )
  59.       starfield_init() ;
  60.  
  61.     pts.pt_type = XGL_PT_FLAG_F3D ;
  62.     pts.bbox = NULL ;
  63.     pts.num_pts = NSTAR*2 ;
  64.     pts.pts.flag_f3d = &starpts[0][0] ;
  65.     xgl_multipolyline(Main_gfx, NULL, 1, &pts) ;
  66. }
  67.  
  68.  
  69.  
  70.  
  71. #ifdef    COMMENT
  72. draw_starfield()
  73. {
  74.     int    i ;
  75.     int    nstars ;
  76.     int    nwhite, nother ;
  77.     int    color ;
  78. register Pt3d    *ptr ;
  79. register int    fit ;
  80.     Xgl_pt_list    pts ;
  81.  
  82.  
  83.     nstars = sizeof(starfield) / sizeof(Pt3d) ;
  84.     nwhite = nstars/2 ;
  85.     nother = nstars/8 ;
  86.     color = 4 ;
  87.     ptr = &starfield[0] ;
  88.  
  89.     xgl_object_set(Main_gfx,
  90.         XGL_CTX_MARKER_DESCRIPTION, xgl_marker_dot,
  91.         XGL_CTX_MARKER_COLOR, ¤t_xgl_color, 0) ;
  92.  
  93.     pts.pt_type = XGL_PT_F3D ;
  94.     pts.bbox = NULL ;
  95.     pts.num_pts = nstars ;
  96.     pts.pts.f3d = starfield ;
  97.     xgl_multimarker(Main_gfx, &pts) ;
  98. }
  99. #endif    COMMENT
  100.