  #compact
  $ title     "Shaders and Index Buffer Objects"
  $ FileName  "t.exe"
 'uses RTL64
  %ExplicitMain
  uses OpenglSceneFrame
  uses glo2/ShaderSupport
  uses glo2/shaders

  'types
  '====
  '
  type vert float x,y,z
  type tex  float u,v
  type rgba byte  r,g,b,a
  '
  '

  'globals
  '=====
  '
  'indexbase 1
  int    ShaderSky
  int    TexSky
  int    SkyUL[4]

  sub initialize(sys hWnd)
  '=======================
  '
  finit
  int a
  SetupExtFunctions
  '
  GDIplus 1
  '
  'glClientActiveTexture(GL_TEXTURE0)
  '
  LoadCubicTextures (
  "..\..\images\SkyBox\left.jpg",
  "..\..\images\SkyBox\right.jpg",
  "..\..\images\SkyBox\bottom.jpg",
  "..\..\images\SkyBox\top.jpg",
  "..\..\images\SkyBox\front.jpg",
  "..\..\images\SkyBox\back.jpg",
  TexSky
  )
  '
  shaders()
  '1  'MINIMAL
  '2  'PER PIXEL
  '3  'PHONG
  '4  'MULTIPLE LIGHTS 
  '5  'MULTIPLE LIGHTS AND TEXTURING
  '6  'SWAP COLORS
  '7  'COMBINED MULTIPLE LIGHTS AND TEXTURING AND REFLECTION
  '8  'SKY BOX
  '9  'CUBIC REFLECTION 1
  '10 'CUBIC REFLECTION 2
  '11 'CUBIC REFLECTION 3
  '12 '3.3 LIGHT MATERIAL AND CUBIC REFLECTION ALPHA SHADER
  '
  CreateShaderProg ps[8]
  ShaderSky=ps[8].ph
  SkyUL[1] = glGetUniformLocation(ps[8].ph, "CubeMap")
  BuildSkyBox()
  '
  end sub


  sub Release(sys hwnd)
  '====================
  DeleteAllGlCompiled
  Gdiplus 0
  glDeleteTextures 1,TexSky
  ReleaseShaderProg ps[8]
  end sub


  sub scene(sys hWnd)
  '==================
  '
  static float ang1,angi1=.5
  '
  ActiveFrame
  if ShaderError then exit sub
  '
  'SKY BOX RENDER
  '==============
  '
  glPushMatrix
  glLoadIdentity
  glRotatef 30,-1,0,0 'tilt
  glRotatef Ang1*.4,0,1,0
  glScalef 1000,1000,1000
  DrawSkyBox(TexSky,ShaderSky)
  glPopMatrix
  '
  'UPDATE ROTATION ANGLES
  '----------------------
  ang1+=0.1
  'if ang1>360 then ang1-=360
  '
  end sub

  MainWindow width,height,WS_OVERLAPPEDWINDOW
