
  $ title     "glo2 Transforms and shaders"
  % ExplicitMain
  indexbase 0

  uses OpenglBase
  'uses OpenglSceneFrame
  uses glTransShaders
  uses glTransTextures

  'types
  '====
  '
  'type vert float x,y,z
  'type tex  float u,v
  'type rgba byte  r,g,b,a
  '
  %mmax 0x100
  float projection[16] 'projection matrix (perspective)
  float modelView[16]  'modelview matrix (viewer)
  float tm[16]         'temp matrix
  float matf[mmax*16]  'matrix array
  float vz[mmax]       'float array for z (translation)
  sys   midx[mmax]     'index for ascending-order of z

  float ang1,ang2,ang3

  shaderProg  ShaderMin
  shaderProg  ShaderPostPro
  shaderProg  ShaderMaj

  uses glTransShapes

  sub initialize(sys hWnd)
  '=======================
  SetupExtFunctions
  GDIplus 1
  GenTextures 32
  MakeShaders
  CreateSqPanel
  end sub

  sub Release(sys hwnd)
  '====================
  SqPanel.Release
  ReleaseShaders
  DeleteTextures 32
  GDIplus 0
  end sub

  %% BackGroundColor 0.5, 0.5, 0.7, 0.0

  declare main()

  sub scene(sys hwnd)
  ===================
  gwnd=hwnd
  BeginPick
  ActiveFrame
  glClearColor BackGroundColor 
  main
  EndPick
  end sub

  sub PickLabel(int c) 'override
  ====================
  static float nc[4] 'no color coding
  if pick then
    float r,g,b,d=1/255
    int a
    a=c and 0xff : r=a*d : c=c>>8
    a=c and 0xff : g=a*d : c=c>>8
    a=c and 0xff : b=a*d
    ShaderVector4 ShaderMaj.v3, 1, float {r,g,b,1} 'sets flat color for label
  else
    ShaderVector4 ShaderMaj.v3, 1, nc 'no flat color
  end if
  end sub


  def PickerBackGround
  ====================
  float tm[16]
  if pick then
    picklabel 0xff00000
    loadidentity
    savematrix tm
    ShaderMatrix4 ShaderMaj.m1, 1, GL_FALSE, tm 'modelView
    translatef 0,0,-1000
    scalef 10000,10000,10000
    savematrix tm
    SqPanel.clearmatrix
    SqPanel.putmatrix tm,16
    SqPanel.render 'using panel as background
  end if
  end def


