
  $ FileName "t.exe"
  'uses RTL32
  'uses RTL64
  % ExplicitMain
  string title="Tiles and shapes"
  uses OpenglSceneFrame
  uses MinMidi
  uses glo2\shapes
  uses glo2\textures
  uses glo2\materials
  uses glo2\particles

  indexbase 1
  sys   GdiplusToken
  float ang1
  float ma[16]
  float li[16]
  sys   cube,sphere,helix,tors
  Cloud cloud1
  Smoke smoke1
  plant fern

  sub MinTextureA(sys n,f,h,b)
  ===========================
  static long v[16]
  v<=
  b,b,b,b,
  b,f,h,b,
  b,h,h,b,
  b,b,b,b
  MakeTexture @v, 4, 4, n
  End sub


  sub initialize(sys hWnd)
  ========================
  '
  GDIplus 1
  '
  sys res=256
  BuildTextures 16,res
  sys p
  p=fern.new res,32000 'pixel map
  MakeTexture p,res,res,texn[12]
  fern.free

  cube=CompileList   : CubeForm      : glEndList
  sphere=CompileList : Spheric 1,1,6 : glEndList
  '
  StandardLighting li
  StandardMaterial ma
  '
  end sub

  sub Release(sys hwnd)
  '====================
  DeleteAllGlCompiled
  glDeleteTextures 16, texn
  Gdiplus 0
  end sub

  sub RenderPlane(int tex, float u,v)
  ===================================
  glBindTexture GL_TEXTURE_2D,tex
  glBegin GL_QUADS
  glTexCoord2f 0.0,0.0 : glVertex3f -1.0,0,-1.0
  glTexCoord2f u  ,0.0 : glVertex3f  1.0,0,-1.0
  glTexCoord2f u  ,v   : glVertex3f  1.0,0, 1.0
  glTexCoord2f 0.0,v   : glVertex3f -1.0,0, 1.0    
  glend
  end sub


  sub scene(sys hWnd)
  ===================
  '
  SnapShots hWnd 'Ctrl-P take snapshot
  NewFrame
  glClearColor 0.5, 0.5, 0.7, 0.0
  Fog          0.5, 0.5, 0.7, 0.05 'rgb and density
  '
  glPolygonMode GL_FRONT_AND_BACK, GL_FILL
  glEnable GL_NORMALIZE
  '
  sys t1=texn[10]
  sys t2=texn[11]
  '
  'MYSTERIOUS RED PLANET
  glPushMatrix
  glTranslatef -20.,10.,-60.0
  Material Red
  glScalef      6.,6.,6.
  glEnable GL_LIGHTING
  glCallList sphere
  'glDisable GL_LIGHTING
  Material White
  glPopMatrix
  '
  'TILES
  glPushMatrix
  glEnable GL_TEXTURE_2D
  glTranslatef -8.0,-1.99,-5.0
  glScalef     .25,1.,.25
  glPushMatrix
  sys i,j
  for j=1 to 16
    for i=1 to 16
      RenderPlane  t1,1.,1.
      glTranslatef 4.,0.,0.
    next
    glTranslatef -62.,0.,-2.
  next
  glPopMatrix
  glDisable GL_TEXTURE_2D
  glPopMatrix
  '
  'GREEN PLANE
  glPushMatrix
  glEnable GL_TEXTURE_2D
  glTranslatef 0.0,-2.0,-29.0
  glScalef     16.,1.,16.
  RenderPlane  t2,8.,8.
  glDisable GL_TEXTURE_2D
  glPopMatrix
  '
  'SOFT SHADOWS
  glEnable GL_TEXTURE_2D
  glPushMatrix
  glTranslatef -1.2,-1.98,-5.8 'for plinth
  glScalef     2.,1.,1.5
  RenderPlane  texn[4],1.,1.
  glPopMatrix
  '
  glPushMatrix
  glTranslatef -2.5,-1.98,-5.5 'for torus
  glScalef     1.,1.,1.
  RenderPlane  texn[3],1.,1.
  glPopMatrix
  '
  glPushMatrix
  glTranslatef 2.5,-1.98,-5.5 'for sphere
  glScalef     .7,.7,.7
  RenderPlane  texn[3],1.,1.
  glPopMatrix
  glDisable GL_TEXTURE_2D
  '
  'SPHERE
  glPushMatrix
  glTranslatef 2.5,-1.5,-6.0
  glScalef      .5,.5,.5
  glCallList sphere
   glPopMatrix
  '
  'OVOID
  glPushMatrix
  glTranslatef -1.,1.2,-6.0
  glScalef      .75,.25,.5
  glCallList sphere
  glPopMatrix
  '
  glPushMatrix
  glTranslatef -2.5,-1.0,-6.0
  glScalef      .5,.5,.5
  glrotatef 65.0,0,1,0
  glrotatef 90.0,1,0,0
  if not tors
    tors=CompileList : torus 1.,.25 : glEndList
  end if
  glCallList tors
  glPopMatrix
  '
  glPushMatrix
  gltranslatef  5.25, -1.85, -30.
  glScalef      .5,.5,.5
  glCallList tors
  glPopMatrix
  '
  'HELIX
  glPushMatrix
  glTranslatef -1.0,-1.0,-6.0
  glScalef      .35,.35,.35
  glrotatef -ang1,0,1,0
  if not helix
    helix=CompileList : toroid 1.,.25,.8,.16,5.,6. : glEndList
  end if
  glCallList helix
  glPopMatrix
  '
  glEnable GL_TEXTURE_2D
  '
  
  'PLINTH
  glPushMatrix
  glTranslatef -1.0,-1.5,-6.0
  glrotatef   30.0,0,1,0
  glScalef    .5,.5,.5
  glBindTexture GL_TEXTURE_2D,t1
  glCallList cube
  glPopMatrix

  glDisable GL_TEXTURE_2D
  glDisable GL_LIGHTING
  '
  'CLOUD
  glEnable GL_TEXTURE_2D
  glPushMatrix
  gltranslatef -10.0, -10.0, -48.0
  glscalef      20.0,12.0,1.0
  cloud1.render 30 'max 50
  glPopMatrix
  glDisable GL_TEXTURE_2D
  '
  'SMOKE
  glEnable GL_TEXTURE_2D
  glBindTexture GL_TEXTURE_2D,texn[2]
  glPushMatrix
  gltranslatef  5, -2., -30.
  glScalef      2.,1.5,1.0
  smoke1.r<=    .85,.75,.65
  smoke1.render 20 'max 50
  'cloud1.render  15
  glPopMatrix
  glDisable GL_TEXTURE_2D
  '
  'PLANT
  glBindTexture GL_TEXTURE_2D,texn(12)
  glEnable GL_TEXTURE_2D
  '
  glPushMatrix
  glTranslatef 1.,-1.,-3.0
  glScalef    .9,.9,1.
  glColor4f   .0,.1,.0,1.
  quadtex     1,1,0
  glPopMatrix
  '
  glPushMatrix
  glTranslatef .7,-1.,-2.99
  glscalef     .9,.9,1.
  glColor4f    .0,.2,.0,1.
  glRotatef    10.,0,0,1
  quadtex      1.,1.,0
  glPopMatrix
  '
  glPushMatrix
  glTranslatef .5,-1.,-2.98
  glscalef     .9,.9,1.
  glColor4f    .0,.3,.0,1.
  'quadtex      1.,1.,0
  glPopMatrix
  '
  glDisable GL_TEXTURE_2D
  '
  sleep 20
  end sub

  MainWindow width,height,WS_OVERLAPPEDWINDOW
