  $ filename "t.exe"
 'uses rtl64
  uses glTransA

  'ARRAY OF MODEL VIEW MATRICES
  '
  %mmax 0x1000
  float matf[mmax*16] 'matrix array
  float vz[mmax]      'float array for z (translation)
  sys   midx[mmax]    'index for ascending-order of z


  sub scene(sys hWnd)
  ===================
  '
  static ShapeObject boa
  if not boa.vb
    float m=-1,l=1,o=0
    boa.init
    boa.PutMatrix float {l,o,o,o, o,l,o,o, o,o,l,0, o,o,o,l },16
    boa.PutVertex float {
    'VERTEX NORMAL TEXCOR
    m,m,o,  o,o,l, o,o, 
    l,m,o,  o,o,l, l,o, 
    l,l,o,  o,o,l, l,l, 
    m,l,o,  o,o,l, o,l
    },32 'SQUARE PANEL
    'boa.PutIndex int {0,1,2, 2,3,0},6,GL_TRIANGLES
    boa.PutIndex int {0,1,3,2},4,GL_TRIANGLE_STRIP
    boa.Transfer 
  end if

  '% BackGroundColor 0 , 0 , 0.2 , 0
  PrepareSceneFrame
  StandardLighting     li
  TranslucentMaterial  mt,0.5
  '
  CreateTexture       imgn, "../../images/glass.jpg"

  int a,b
  a=0x00300000
  b=0xffaaffff
  '
  CreateSynthTexture imgn1, int {
  a,a,a,
  a,b,a,
  a,a,a
  }, bytesof

  CreateSynthTexture imgn2, int {
  a,a,a,a,a,
  a,b,a,b,a,
  a,a,b,a,a,
  a,b,a,b,a,
  a,a,a,a,a
  }, bytesof

  

  'ShaderProgram shaderMin.ph
  'ShaderProgram shaderMin.t0, 1, imgn 'FOR COLOR
  ShaderProgram shaderMaj.ph
  ShaderTexture shaderMaj.t0, 0, imgn 'FOR COLOR
  float tint =  {1,1,1,.7}
  float a=.15,d=.65,s=.2,sh=16
  float light     = {a,a,0,1, d,d,d,1, s,s,s,1, 100} 'ambient,diffuse,(specular),(shiny)
  float direction = {0,0,1,0} 'for parallel lighting 
  glUniform4fv(ShaderMaj.v0, 1, tint )
  glUniform4fv(ShaderMaj.v1, 4, light)
  glUniform4fv(ShaderMaj.v2, 1, direction)
  '
  '
  'GENERATE ARRAY OF TRANSFORMS
  float ang2,ang3
  sys   i,j,k,m
  sys   n=8
  float ang=360/n
  float d=tan(rad(90-ang/2))
  '
  j=0 : k=0
  for m=0 to 1 'with inner circle
  for i=0 to <n
    ang2=i*ang
    ang3=ang1+ang2
    ' 
    loadidentity
    translatef   0,0,-7
    if m then  scalef .5,.5,.5
    rotatef      20,  1,0,0
    if m then  translatef 1,0,0
    rotatef      ang3,0,1,0
    translatef   0,0,d
    savematrix   matf(j)
    '
    vz[k]=matf[j+14] 'COLLECT Z DISPLACEMENT
    j+=16 : k+=1
  next
  next
  '
  'ARRANGE PANELS INTO ASCENDING Z ORDER
  sortindex vz, midx, k
  '
  'RENDER PANELS IN Z ORDER (FARTHEST FIRST)
  float Projection[16]
  SetProjectionMatrix projection, 45, aspect, 1, 1e6
  glUniformMatrix4fv(ShaderMaj.m0, 1, GL_FALSE, projection)
  sys nn=n*m
  for i=0 to <nn
    j=midx[i]*16 'SELECT MATRIX VIA INDEX (ASCENDING ORDER)
    loadmatrix  matf[j]
    translormf  v[12],v[112],4      'TRANSLATION ONLY (FOR SIGNBOARDING)
   'transformf  v[12],v[112],4      'FULL TRANSFORM
   'transnormf  v[24],v[124],1      'FOR NORMALS
    ColorQuad
    glUniformMatrix4fv(ShaderMaj.m1, 1, GL_FALSE, matf[j]) 'modelView
    boa.render
  next
  '
  ShaderProgram -1
  texture   -1
  '
  end sub



  MainWindow width,height,WS_OVERLAPPEDWINDOW
