
  $ FileName "b.exe"
 'uses RTL64
  $ title "Crates"
  % ExplicitMain
  uses OpenglSceneFrame
  uses glo2\particles


  'SHARED
  '======

  indexbase 1
  float ang1
  sys cube pent
  cloud cloud1
  smoke smoke1
  

  sub initialize(sys hWnd)
  ========================
  '
  GDIplus 1
  '
  'PREPARE TEXTURES
  '
  glGenTextures 2, texn
  '
  static sys res=256
  string imgs[3]
  MinTexture texn[1],0xffffffff,0x80ffffff,0x00ffffff
  MinTexture texn[2],0xffffffff,0x80ffffff,0x00000000
  LoadPixImage "../images/crate.jpg",res,imgs[3]
  MakeTexture *imgs[3],res,res,texn[3]
  '
  cube=CompileList : CubeForm    : glEndList
  pent=CompileList : Sides 5,1,1 : glEndList
  '
  SetTimer hWnd,1,10,null
  end sub

  sub Release(sys hwnd)
  '====================
  DeleteAllGlCompiled
  DeleteTextures  3
  Gdiplus         0
  killTimer hwnd, 1
  end sub

  sub RenderCrate(float x,y,z,sc,sys tex)
  =======================================
  'glColor4f .99,.99,.99,.99
  glEnable GL_TEXTURE_2D
  glBindTexture GL_TEXTURE_2D,tex
  glPushMatrix
  gltranslatef x,y,z
  glrotatef    45.0,0,1,0
  glscalef sc,sc,sc
  glCallList Cube
  'glCallList Pent
  glPopMatrix
  glDisable GL_TEXTURE_2D
  end sub


  sub scene(sys hWnd)
  '==================

  static single ra,ri,angi1=.5
  '
  ActiveFrame
  glClearColor 0.5, 0.5, 0.7, 0
  Fog          0.5, 0.5, 0.7, 0.030
  StandardLighting  li
  StandardMaterial  ma
  '
  '
  'CRATES
  'glColor4f .99,.99,.99,.99
  sys n=texn[3]
  RenderCrate  11.5,-0.9,-24.0,0.5,n
  RenderCrate   6.5,-0.9,-16.0,0.5,n
  RenderCrate   2.5,-0.9,-8.0, 0.5,n
  RenderCrate   0.5,-0.9,-4.0, 0.5,n
  RenderCrate  -0.5,-0.9,-2.0, 0.5,n
  glDisable GL_LIGHTING
  '
  'CLOUD
  glEnable GL_TEXTURE_2D
  glPushMatrix
  gltranslatef -10.0, -10.0, -22.0
  glscalef      20.0,12.0,1.0
  cloud1.basetex=1
  cloud1.render 40 'max 50
  glPopMatrix
  glDisable GL_TEXTURE_2D
  '
  'SMOKE
  glEnable GL_TEXTURE_2D
  glBindTexture GL_TEXTURE_2D,texn[2]
  glPushMatrix
  gltranslatef  0.0, -0.6, -3.5
  glScalef      1.5,2.0,1.0
  smoke1.r<=    .55,.40,.70
  smoke1.render 20 'max 50
  glPopMatrix
  glDisable GL_TEXTURE_2D
  '
  '
  ang1+=angi1
  if ang1>360 then ang1-=360
  sleep 10
  end sub

  MainWindow width,height,WS_OVERLAPPEDWINDOW
