  '
  '-- experimental openGL example for generating stars, 16.5.2013
  '-- by frankolinox, version 1.0
  '
  #compact
  $ FileName  "t.exe"
  'uses rtl32
  'uses rtl64
  $ title     "Lines & Stars.."
  %ExplicitMain
  uses OpenglSceneFrame

  type theStars
  =============
  float  x,y,z    'position
  float  r,g,b,a  'color
  float  vx,vy,vz 'velocity
  float  l        'length
  end type
  
  %maxStars=1000

  dim stars(%MaxStars) as theStars
  
  function Randi(int z) as int
  ============================
  static int seed=0x12345678
  seed=seed*0x8088405+1
  mul z      'unsigned multiply
  return edx 'top 32 bits of 64 bit product
  end function 

  sub generateStars( sys index )
  ==============================
  stars(index).x  = randi(100)-50
  stars(index).y  = randi(100)-50
  stars(index).z  = randi(10)-110
  stars(index).r  = randi(255)*.004
  stars(index).g  = randi(255)*.004
  stars(index).b  = randi(255)*.004
  stars(index).a  = 1.0
  stars(index).vz = randi(255)*.002+.1
  stars(index).l  = randi(255)*.04+1
  end sub
  
    sub Staros
  '===========
  sys vv
  glLineWidth 3.0
  glPointSize 3.0
  for vv = 1 to %maxStars
    thestars s at (@stars(vv))                 
    glBegin GL_LINES
    glColor4f s.r,s.g,s.b,0.0 : glVertex3f s.x,s.y,s.z 
    glColor4f s.r,s.g,s.b,s.a : glVertex3f s.x,s.y,s.z+s.l
    glEnd    
    glBegin GL_POINTS
    glColor4f s.r,s.g,s.b,s.a : glVertex3f s.x,s.y,s.z+s.l
    glEnd    
    if s.z >= 0
      generateStars(vv)
    else
      s.z += s.vz
    end if
  next 
  end sub

  sub initialize(sys hWnd)
  '=======================
  end sub
  '

  sub scene(sys hWnd)
  '==================
  '
  sys a
  static single s1,s2,s3,s4,ang1,angi1=.1,ra,ri,i
  ActiveFrame
  glHint GL_POINT_SMOOTH_HINT, GL_NICEST
  glEnable GL_POINT_SMOOTH
  glClearColor 0.1, 0.0, 0.1, 0
  glRotatef ang1,0,0,1.
  staros() ' stars generatings
  ang1+=angi1
  if ang1>360 then ang1-=360
  sleep 10
  '
  end sub

  sub Release(sys hwnd)
  '====================
  end sub

  MainWindow width,height,WS_OVERLAPPEDWINDOW
