C:\Documents and Settings\Ville\Desktop\engine research\shaders

demo shaders
  http://www.bonzaisoftware.com/npr.html
  http://developer.3dlabs.com/downloads/glslexamples/index.htm

Material
  VertexShader
  FragmentShader
  
VertexShader
  ShaderSource ""
  UniformVariables
    DefineVariable "Wobblyness"
    ShaderVariable VarName="Wobblyness" ValueRef="App.Time"
    
ShadersSupported = (glCreateShaderObjectARB<>nil)
  platform_GetGlExtensionProc(name pchar) : pointer;

TShaderBase
  GlHandle
  Source string

ladda upp  
  glCreateShaderObjectARB(fragment)
  glShaderSource(handle, pchar)
  glCompile
  
  glAttachObject attach till program
  ha ett program för allt? nix, kan bara finnas en main per program, behövs en per material.
  samma shader kan bli attached till flera program
    program hålls av material?
  
  program
    createprogram
    attachobject vshader
    attachobject fshader
    link
    use
    
  variabler
    getUniformLocation(proghandle,name)
    uniform(location,value)
    
städa upp
  måste deattach shaders innan de kan raderas

pseudo-kod
  UseMaterial
    if material.HasShaders and ShadersSupported
      material.EnableShader

  DisableMaterial
    material.disableShader
    
  material.EnableShader()
    if (not created) or changed or vshader.changed or fshader.changed
      cleanup()
      recreate()
    if Self.LastVariableUpdate<>Clock.Time
      uppdatera uniform vars
      Self.LastVariableUpdate=clock.time
    glUseProgram(self.proghandle)
  material.cleanup()

alt.
Shader
  public
    VertexShaderSource
    FragmentShaderSource
  private
    proghandle,vshaderhandle,fshaderhandle
    UseShader
      if changed
        reinit()
      glUseProgram(self.Proghandle)
    ReInit()
      cleanup()
      
undvik onödigt byte av shaders
  inbyggd DefaultMaterial med det som är default
    instans ägs av vad? renderer unit?
  slopa DisableMaterial?
  EnableMaterial(Old,New)
    if Old=New then
      Exit;
    NilOld := Old=nil;
    if NilOld or (Old.Texture<>New.Texture)
      ...
    if NilOld or (Old.Shader<>New.Shader)
      ...
    CurrentMaterial = new
  render_begin
  render_end
    EnableMaterial(CurrentMaterial,DefaultMaterial)

felsökning
  GLCheck(value) inline
    ifndef minimal
    if value=error showmessage
    
procs
  wglGetProcAddress
  http://jedi-sdl.cvs.sourceforge.net/jedi-sdl/JEDI-SDLv1.0/OpenGL/Pas/