Browse Source

* Auto-generate webgl.pas webaudio.pas from .idl files

michael 7 years ago
parent
commit
0d764b00cc
3 changed files with 1668 additions and 658 deletions
  1. 1 0
      packages/rtl/types.pas
  2. 1006 0
      packages/rtl/webaudio.pas
  3. 661 658
      packages/rtl/webgl.pas

+ 1 - 0
packages/rtl/types.pas

@@ -21,6 +21,7 @@ type
 
   TBooleanDynArray = array of Boolean;
   TIntegerDynArray = array of Integer;
+  TNativeIntDynArray = array of NativeInt;
   TStringDynArray = array of String;
   TDoubleDynArray = array of Double;
   TJSValueDynArray = array of JSValue;

+ 1006 - 0
packages/rtl/webaudio.pas

@@ -0,0 +1,1006 @@
+Unit webaudio;
+
+{$MODE ObjFPC}
+{$H+}
+{$modeswitch externalclass}
+
+interface
+
+uses SysUtils, JS,web,types;
+
+{
+  Automatically generated file by TWebIDLToPas on 2018-06-23 10:52:00
+  
+  Used command-line options : 
+  -i
+  webaudio.idl
+  -v
+  v2
+  -t
+  EventTarget=TJSEventTarget,DOMHighResTimeStamp=TJSDOMHighResTimeStamp,HTMLMediaElement=TJSElement,MediaStream=JSValue,MediaStreamTrack=JSValue,EventHandler=TJSEVentHandler,Promise=TJSPromise,Event=TJSEvent,Worklet=TJSOBject,WorkletGlobalScope=TJSObject,VoidFunction=TProcedure,MessagePort=TJSMessagePort
+  -x
+  web,types
+  -d
+  -p
+  
+  Command-line options translate to: 
+  
+  Options : [coDictionaryAsClass,coaddOptionsToheader]
+  Keyword prefix : 
+  Keyword suffix : _
+  Class prefix : TJS
+  Class suffix : 
+  Field prefix : F
+  WEBIDLversion : v2
+  Type aliases:
+  EventTarget=TJSEventTarget
+  DOMHighResTimeStamp=TJSDOMHighResTimeStamp
+  HTMLMediaElement=TJSElement
+  MediaStream=JSValue
+  MediaStreamTrack=JSValue
+  EventHandler=TJSEVentHandler
+  Promise=TJSPromise
+  Event=TJSEvent
+  Worklet=TJSOBject
+  WorkletGlobalScope=TJSObject
+  VoidFunction=TProcedure
+  MessagePort=TJSMessagePort
+}
+Type
+  // Forward class definitions
+  TJSBaseAudioContext = Class;
+  TJSAudioContext = Class;
+  TJSOfflineAudioContext = Class;
+  TJSOfflineAudioCompletionEvent = Class;
+  TJSAudioBuffer = Class;
+  TJSAudioNode = Class;
+  TJSAudioParam = Class;
+  TJSAudioScheduledSourceNode = Class;
+  TJSAnalyserNode = Class;
+  TJSAudioBufferSourceNode = Class;
+  TJSAudioDestinationNode = Class;
+  TJSAudioListener = Class;
+  TJSAudioProcessingEvent = Class;
+  TJSBiquadFilterNode = Class;
+  TJSChannelMergerNode = Class;
+  TJSChannelSplitterNode = Class;
+  TJSConstantSourceNode = Class;
+  TJSConvolverNode = Class;
+  TJSDelayNode = Class;
+  TJSDynamicsCompressorNode = Class;
+  TJSGainNode = Class;
+  TJSIIRFilterNode = Class;
+  TJSMediaElementAudioSourceNode = Class;
+  TJSMediaStreamAudioDestinationNode = Class;
+  TJSMediaStreamAudioSourceNode = Class;
+  TJSMediaStreamTrackAudioSourceNode = Class;
+  TJSOscillatorNode = Class;
+  TJSPannerNode = Class;
+  TJSPeriodicWave = Class;
+  TJSScriptProcessorNode = Class;
+  TJSStereoPannerNode = Class;
+  TJSWaveShaperNode = Class;
+  TJSAudioWorklet = Class;
+  TJSAudioWorkletGlobalScope = Class;
+  TJSAudioParamMap = Class;
+  TJSAudioWorkletNode = Class;
+  TJSAudioWorkletProcessor = Class;
+  TJSAudioContextOptions = Class;
+  TJSAudioTimestamp = Class;
+  TJSOfflineAudioContextOptions = Class;
+  TJSOfflineAudioCompletionEventInit = Class;
+  TJSAudioBufferOptions = Class;
+  TJSAudioNodeOptions = Class;
+  TJSAnalyserOptions = Class;
+  TJSAudioBufferSourceOptions = Class;
+  TJSAudioProcessingEventInit = Class;
+  TJSBiquadFilterOptions = Class;
+  TJSChannelMergerOptions = Class;
+  TJSChannelSplitterOptions = Class;
+  TJSConstantSourceOptions = Class;
+  TJSConvolverOptions = Class;
+  TJSDelayOptions = Class;
+  TJSDynamicsCompressorOptions = Class;
+  TJSGainOptions = Class;
+  TJSIIRFilterOptions = Class;
+  TJSMediaElementAudioSourceOptions = Class;
+  TJSMediaStreamAudioSourceOptions = Class;
+  TJSMediaStreamTrackAudioSourceOptions = Class;
+  TJSOscillatorOptions = Class;
+  TJSPannerOptions = Class;
+  TJSPeriodicWaveConstraints = Class;
+  TJSPeriodicWaveOptions = Class;
+  TJSStereoPannerOptions = Class;
+  TJSWaveShaperOptions = Class;
+  TJSAudioWorkletNodeOptions = Class;
+  TJSAudioParamDescriptor = Class;
+  AudioContextState = String;
+  AudioContextLatencyCategory = String;
+  ChannelCountMode = String;
+  ChannelInterpretation = String;
+  AutomationRate = String;
+  BiquadFilterType = String;
+  OscillatorType = String;
+  PanningModelType = String;
+  DistanceModelType = String;
+  OverSampleType = String;
+  DecodeErrorCallback = Procedure (error : TJSError);
+  DecodeSuccessCallback = Procedure (decodedData : TJSAudioBuffer);
+  
+  { --------------------------------------------------------------------
+    TJSAudioContextOptions
+    --------------------------------------------------------------------}
+  
+  TJSAudioContextOptions = class(TJSObject)
+    latencyHint : JSValue;
+    sampleRate : Double;
+  end;
+  
+  { --------------------------------------------------------------------
+    TJSAudioTimestamp
+    --------------------------------------------------------------------}
+  
+  TJSAudioTimestamp = class(TJSObject)
+    contextTime : Double;
+    performanceTime : TJSDOMHighResTimeStamp;
+  end;
+  
+  { --------------------------------------------------------------------
+    TJSOfflineAudioContextOptions
+    --------------------------------------------------------------------}
+  
+  TJSOfflineAudioContextOptions = class(TJSObject)
+    numberOfChannels : NativeInt;
+    length_ : NativeInt;external name 'length';
+    sampleRate : Double;
+  end;
+  
+  { --------------------------------------------------------------------
+    TJSOfflineAudioCompletionEventInit
+    --------------------------------------------------------------------}
+  
+  TJSOfflineAudioCompletionEventInit = class(TJSObject)
+    renderedBuffer : TJSAudioBuffer;
+  end;
+  
+  { --------------------------------------------------------------------
+    TJSAudioBufferOptions
+    --------------------------------------------------------------------}
+  
+  TJSAudioBufferOptions = class(TJSObject)
+    numberOfChannels : NativeInt;
+    length_ : NativeInt;external name 'length';
+    sampleRate : Double;
+  end;
+  
+  { --------------------------------------------------------------------
+    TJSAudioNodeOptions
+    --------------------------------------------------------------------}
+  
+  TJSAudioNodeOptions = class(TJSObject)
+    channelCount : NativeInt;
+    _channelCountMode : ChannelCountMode;external name 'channelCountMode';
+    _channelInterpretation : ChannelInterpretation;external name 'channelInterpretation';
+  end;
+  
+  { --------------------------------------------------------------------
+    TJSAnalyserOptions
+    --------------------------------------------------------------------}
+  
+  TJSAnalyserOptions = class(TJSObject)
+    fftSize : NativeInt;
+    maxDecibels : Double;
+    minDecibels : Double;
+    smoothingTimeConstant : Double;
+  end;
+  
+  { --------------------------------------------------------------------
+    TJSAudioBufferSourceOptions
+    --------------------------------------------------------------------}
+  
+  TJSAudioBufferSourceOptions = class(TJSObject)
+    buffer : TJSAudioBuffer;
+    detune : Double;
+    loop : boolean;
+    loopEnd : Double;
+    loopStart : Double;
+    playbackRate : Double;
+  end;
+  
+  { --------------------------------------------------------------------
+    TJSAudioProcessingEventInit
+    --------------------------------------------------------------------}
+  
+  TJSAudioProcessingEventInit = class(TJSObject)
+    playbackTime : Double;
+    inputBuffer : TJSAudioBuffer;
+    outputBuffer : TJSAudioBuffer;
+  end;
+  
+  { --------------------------------------------------------------------
+    TJSBiquadFilterOptions
+    --------------------------------------------------------------------}
+  
+  TJSBiquadFilterOptions = class(TJSObject)
+    type_ : BiquadFilterType;external name 'type';
+    Q : Double;
+    detune : Double;
+    frequency : Double;
+    gain : Double;
+  end;
+  
+  { --------------------------------------------------------------------
+    TJSChannelMergerOptions
+    --------------------------------------------------------------------}
+  
+  TJSChannelMergerOptions = class(TJSObject)
+    numberOfInputs : NativeInt;
+  end;
+  
+  { --------------------------------------------------------------------
+    TJSChannelSplitterOptions
+    --------------------------------------------------------------------}
+  
+  TJSChannelSplitterOptions = class(TJSObject)
+    numberOfOutputs : NativeInt;
+  end;
+  
+  { --------------------------------------------------------------------
+    TJSConstantSourceOptions
+    --------------------------------------------------------------------}
+  
+  TJSConstantSourceOptions = class(TJSObject)
+    offset : Double;
+  end;
+  
+  { --------------------------------------------------------------------
+    TJSConvolverOptions
+    --------------------------------------------------------------------}
+  
+  TJSConvolverOptions = class(TJSObject)
+    buffer : TJSAudioBuffer;
+    disableNormalization : boolean;
+  end;
+  
+  { --------------------------------------------------------------------
+    TJSDelayOptions
+    --------------------------------------------------------------------}
+  
+  TJSDelayOptions = class(TJSObject)
+    maxDelayTime : Double;
+    delayTime : Double;
+  end;
+  
+  { --------------------------------------------------------------------
+    TJSDynamicsCompressorOptions
+    --------------------------------------------------------------------}
+  
+  TJSDynamicsCompressorOptions = class(TJSObject)
+    attack : Double;
+    knee : Double;
+    ratio : Double;
+    release : Double;
+    threshold : Double;
+  end;
+  
+  { --------------------------------------------------------------------
+    TJSGainOptions
+    --------------------------------------------------------------------}
+  
+  TJSGainOptions = class(TJSObject)
+    gain : Double;
+  end;
+  
+  { --------------------------------------------------------------------
+    TJSIIRFilterOptions
+    --------------------------------------------------------------------}
+  
+  TJSIIRFilterOptions = class(TJSObject)
+    feedforward : TDoubleDynArray;
+    feedback : TDoubleDynArray;
+  end;
+  
+  { --------------------------------------------------------------------
+    TJSMediaElementAudioSourceOptions
+    --------------------------------------------------------------------}
+  
+  TJSMediaElementAudioSourceOptions = class(TJSObject)
+    mediaElement : TJSElement;
+  end;
+  
+  { --------------------------------------------------------------------
+    TJSMediaStreamAudioSourceOptions
+    --------------------------------------------------------------------}
+  
+  TJSMediaStreamAudioSourceOptions = class(TJSObject)
+    mediaStream : JSValue;
+  end;
+  
+  { --------------------------------------------------------------------
+    TJSMediaStreamTrackAudioSourceOptions
+    --------------------------------------------------------------------}
+  
+  TJSMediaStreamTrackAudioSourceOptions = class(TJSObject)
+    mediaStreamTrack : JSValue;
+  end;
+  
+  { --------------------------------------------------------------------
+    TJSOscillatorOptions
+    --------------------------------------------------------------------}
+  
+  TJSOscillatorOptions = class(TJSObject)
+    type_ : OscillatorType;external name 'type';
+    frequency : Double;
+    detune : Double;
+    periodicWave : TJSPeriodicWave;
+  end;
+  
+  { --------------------------------------------------------------------
+    TJSPannerOptions
+    --------------------------------------------------------------------}
+  
+  TJSPannerOptions = class(TJSObject)
+    panningModel : PanningModelType;
+    distanceModel : DistanceModelType;
+    positionX : Double;
+    positionY : Double;
+    positionZ : Double;
+    orientationX : Double;
+    orientationY : Double;
+    orientationZ : Double;
+    refDistance : Double;
+    maxDistance : Double;
+    rolloffFactor : Double;
+    coneInnerAngle : Double;
+    coneOuterAngle : Double;
+    coneOuterGain : Double;
+  end;
+  
+  { --------------------------------------------------------------------
+    TJSPeriodicWaveConstraints
+    --------------------------------------------------------------------}
+  
+  TJSPeriodicWaveConstraints = class(TJSObject)
+    disableNormalization : boolean;
+  end;
+  
+  { --------------------------------------------------------------------
+    TJSPeriodicWaveOptions
+    --------------------------------------------------------------------}
+  
+  TJSPeriodicWaveOptions = class(TJSObject)
+    real : TDoubleDynArray;
+    imag : TDoubleDynArray;
+  end;
+  
+  { --------------------------------------------------------------------
+    TJSStereoPannerOptions
+    --------------------------------------------------------------------}
+  
+  TJSStereoPannerOptions = class(TJSObject)
+    pan : Double;
+  end;
+  
+  { --------------------------------------------------------------------
+    TJSWaveShaperOptions
+    --------------------------------------------------------------------}
+  
+  TJSWaveShaperOptions = class(TJSObject)
+    curve : TDoubleDynArray;
+    oversample : OverSampleType;
+  end;
+  
+  { --------------------------------------------------------------------
+    TJSAudioWorkletNodeOptions
+    --------------------------------------------------------------------}
+  
+  TJSAudioWorkletNodeOptions = class(TJSObject)
+    numberOfInputs : NativeInt;
+    numberOfOutputs : NativeInt;
+    outputChannelCount : TNativeIntDynArray;
+    parameterData : TJSObject;
+    processorOptions : TJSObject;
+  end;
+  
+  { --------------------------------------------------------------------
+    TJSAudioParamDescriptor
+    --------------------------------------------------------------------}
+  
+  TJSAudioParamDescriptor = class(TJSObject)
+    name : String;
+    defaultValue : Double;
+    minValue : Double;
+    maxValue : Double;
+    _automationRate : AutomationRate;external name 'automationRate';
+  end;
+  
+  { --------------------------------------------------------------------
+    TJSBaseAudioContext
+    --------------------------------------------------------------------}
+  
+  TDoubleDynArray = Array of Double;
+  
+  TJSBaseAudioContext = class external name 'BaseAudioContext'  (TJSEventTarget)
+  Private
+    Fdestination : TJSAudioDestinationNode; external name 'destination'; 
+    FsampleRate : Double; external name 'sampleRate'; 
+    FcurrentTime : Double; external name 'currentTime'; 
+    Flistener : TJSAudioListener; external name 'listener'; 
+    Fstate : AudioContextState; external name 'state'; 
+    FaudioWorklet : TJSAudioWorklet; external name 'audioWorklet'; 
+  Public
+    
+      onstatechange : TJSEVentHandler;
+    function createAnalyser: TJSAnalyserNode;
+    function createBiquadFilter: TJSBiquadFilterNode;
+    function createBuffer(numberOfChannels : NativeInt; length_ : NativeInt; sampleRate : Double): TJSAudioBuffer;
+    function createBufferSource: TJSAudioBufferSourceNode;
+    function createChannelMerger(numberOfInputs : NativeInt): TJSChannelMergerNode; overload;
+    function createChannelMerger: TJSChannelMergerNode; overload;
+    function createChannelSplitter(numberOfOutputs : NativeInt): TJSChannelSplitterNode; overload;
+    function createChannelSplitter: TJSChannelSplitterNode; overload;
+    function createConstantSource: TJSConstantSourceNode;
+    function createConvolver: TJSConvolverNode;
+    function createDelay(maxDelayTime : Double): TJSDelayNode; overload;
+    function createDelay: TJSDelayNode; overload;
+    function createDynamicsCompressor: TJSDynamicsCompressorNode;
+    function createGain: TJSGainNode;
+    function createIIRFilter(feedforward : TDoubleDynArray; feedback : TDoubleDynArray): TJSIIRFilterNode;
+    function createOscillator: TJSOscillatorNode;
+    function createPanner: TJSPannerNode;
+    function createPeriodicWave(real : TDoubleDynArray; imag : TDoubleDynArray; constraints : TJSPeriodicWaveConstraints): TJSPeriodicWave; overload;
+    function createPeriodicWave(real : TDoubleDynArray; imag : TDoubleDynArray): TJSPeriodicWave; overload;
+    function createScriptProcessor(bufferSize : NativeInt; numberOfInputChannels : NativeInt; numberOfOutputChannels : NativeInt): TJSScriptProcessorNode; overload;
+    function createScriptProcessor: TJSScriptProcessorNode; overload;
+    function createScriptProcessor(bufferSize : NativeInt): TJSScriptProcessorNode; overload;
+    function createScriptProcessor(bufferSize : NativeInt; numberOfInputChannels : NativeInt): TJSScriptProcessorNode; overload;
+    function createStereoPanner: TJSStereoPannerNode;
+    function createWaveShaper: TJSWaveShaperNode;
+    function decodeAudioData(audioData : TJSArrayBuffer; successCallback : DecodeSuccessCallback; errorCallback : DecodeErrorCallback): TJSPromise; overload;
+    function decodeAudioData(audioData : TJSArrayBuffer): TJSPromise; overload;
+    function decodeAudioData(audioData : TJSArrayBuffer; successCallback : DecodeSuccessCallback): TJSPromise; overload;
+    function resume: TJSPromise;
+    Property destination : TJSAudioDestinationNode Read Fdestination; 
+    Property sampleRate : Double Read FsampleRate; 
+    Property currentTime : Double Read FcurrentTime; 
+    Property listener : TJSAudioListener Read Flistener; 
+    Property state : AudioContextState Read Fstate; 
+    Property audioWorklet : TJSAudioWorklet Read FaudioWorklet; 
+  end;
+  
+  { --------------------------------------------------------------------
+    TJSAudioContext
+    --------------------------------------------------------------------}
+  
+  TJSAudioContext = class external name 'AudioContext'  (TJSBaseAudioContext)
+  Private
+    FbaseLatency : Double; external name 'baseLatency'; 
+    FoutputLatency : Double; external name 'outputLatency'; 
+  Public
+    function getOutputTimestamp: TJSAudioTimestamp;
+    function suspend: TJSPromise;
+    function close: TJSPromise;
+    function createMediaElementSource(mediaElement : TJSElement): TJSMediaElementAudioSourceNode;
+    function createMediaStreamSource(mediaStream : JSValue): TJSMediaStreamAudioSourceNode;
+    function createMediaStreamTrackSource(mediaStreamTrack : JSValue): TJSMediaStreamTrackAudioSourceNode;
+    function createMediaStreamDestination: TJSMediaStreamAudioDestinationNode;
+    Property baseLatency : Double Read FbaseLatency; 
+    Property outputLatency : Double Read FoutputLatency; 
+  end;
+  
+  { --------------------------------------------------------------------
+    TJSOfflineAudioContext
+    --------------------------------------------------------------------}
+  
+  TJSOfflineAudioContext = class external name 'OfflineAudioContext'  (TJSBaseAudioContext)
+  Private
+    Flength_ : NativeInt; external name 'length'; 
+  Public
+      oncomplete : TJSEVentHandler;
+    function startRendering: TJSPromise;
+    function suspend(suspendTime : Double): TJSPromise;
+    Property length_ : NativeInt Read Flength_; 
+  end;
+  
+  { --------------------------------------------------------------------
+    TJSOfflineAudioCompletionEvent
+    --------------------------------------------------------------------}
+  
+  TJSOfflineAudioCompletionEvent = class external name 'OfflineAudioCompletionEvent'  (TJSEvent)
+  Private
+    FrenderedBuffer : TJSAudioBuffer; external name 'renderedBuffer'; 
+  Public
+    Property renderedBuffer : TJSAudioBuffer Read FrenderedBuffer; 
+  end;
+  
+  { --------------------------------------------------------------------
+    TJSAudioBuffer
+    --------------------------------------------------------------------}
+  
+  TJSAudioBuffer = class external name 'AudioBuffer' 
+  Private
+    FsampleRate : Double; external name 'sampleRate'; 
+    Flength_ : NativeInt; external name 'length'; 
+    Fduration : Double; external name 'duration'; 
+    FnumberOfChannels : NativeInt; external name 'numberOfChannels'; 
+  Public
+    function getChannelData(channel : NativeInt): TJSFloat32Array;
+    Procedure copyFromChannel(destination : TJSFloat32Array; channelNumber : NativeInt; startInChannel : NativeInt); overload;
+    Procedure copyFromChannel(destination : TJSFloat32Array; channelNumber : NativeInt); overload;
+    Procedure copyToChannel(source : TJSFloat32Array; channelNumber : NativeInt; startInChannel : NativeInt); overload;
+    Procedure copyToChannel(source : TJSFloat32Array; channelNumber : NativeInt); overload;
+    Property sampleRate : Double Read FsampleRate; 
+    Property length_ : NativeInt Read Flength_; 
+    Property duration : Double Read Fduration; 
+    Property numberOfChannels : NativeInt Read FnumberOfChannels; 
+  end;
+  
+  { --------------------------------------------------------------------
+    TJSAudioNode
+    --------------------------------------------------------------------}
+  
+  TJSAudioNode = class external name 'AudioNode'  (TJSEventTarget)
+  Private
+    Fcontext : TJSBaseAudioContext; external name 'context'; 
+    FnumberOfInputs : NativeInt; external name 'numberOfInputs'; 
+    FnumberOfOutputs : NativeInt; external name 'numberOfOutputs'; 
+  Public
+      channelCount : NativeInt;
+      _channelCountMode : ChannelCountMode;external name 'channelCountMode';
+      _channelInterpretation : ChannelInterpretation;external name 'channelInterpretation';
+    function connect(destinationNode : TJSAudioNode; output : NativeInt; input : NativeInt): TJSAudioNode; overload;
+    function connect(destinationNode : TJSAudioNode): TJSAudioNode; overload;
+    function connect(destinationNode : TJSAudioNode; output : NativeInt): TJSAudioNode; overload;
+    Procedure connect(destinationParam : TJSAudioParam; output : NativeInt); overload;
+    Procedure connect(destinationParam : TJSAudioParam); overload;
+    Procedure disconnect;
+    Procedure disconnect(output : NativeInt);
+    Procedure disconnect(destinationNode : TJSAudioNode);
+    Procedure disconnect(destinationNode : TJSAudioNode; output : NativeInt);
+    Procedure disconnect(destinationNode : TJSAudioNode; output : NativeInt; input : NativeInt);
+    Procedure disconnect(destinationParam : TJSAudioParam);
+    Procedure disconnect(destinationParam : TJSAudioParam; output : NativeInt);
+    Property context : TJSBaseAudioContext Read Fcontext; 
+    Property numberOfInputs : NativeInt Read FnumberOfInputs; 
+    Property numberOfOutputs : NativeInt Read FnumberOfOutputs; 
+  end;
+  
+  { --------------------------------------------------------------------
+    TJSAudioParam
+    --------------------------------------------------------------------}
+  
+  TJSAudioParam = class external name 'AudioParam' 
+  Private
+    FdefaultValue : Double; external name 'defaultValue'; 
+    FminValue : Double; external name 'minValue'; 
+    FmaxValue : Double; external name 'maxValue'; 
+  Public
+      value : Double;
+      _automationRate : AutomationRate;external name 'automationRate';
+    function setValueAtTime(value : Double; startTime : Double): TJSAudioParam;
+    function linearRampToValueAtTime(value : Double; endTime : Double): TJSAudioParam;
+    function exponentialRampToValueAtTime(value : Double; endTime : Double): TJSAudioParam;
+    function setTargetAtTime(target : Double; startTime : Double; timeConstant : Double): TJSAudioParam;
+    function setValueCurveAtTime(values : TDoubleDynArray; startTime : Double; duration : Double): TJSAudioParam;
+    function cancelScheduledValues(cancelTime : Double): TJSAudioParam;
+    function cancelAndHoldAtTime(cancelTime : Double): TJSAudioParam;
+    Property defaultValue : Double Read FdefaultValue; 
+    Property minValue : Double Read FminValue; 
+    Property maxValue : Double Read FmaxValue; 
+  end;
+  
+  { --------------------------------------------------------------------
+    TJSAudioScheduledSourceNode
+    --------------------------------------------------------------------}
+  
+  TJSAudioScheduledSourceNode = class external name 'AudioScheduledSourceNode'  (TJSAudioNode)
+  Private
+  Public
+      onended : TJSEVentHandler;
+    Procedure start(when : Double); overload;
+    Procedure start; overload;
+    Procedure stop(when : Double); overload;
+    Procedure stop; overload;
+  end;
+  
+  { --------------------------------------------------------------------
+    TJSAnalyserNode
+    --------------------------------------------------------------------}
+  
+  TJSAnalyserNode = class external name 'AnalyserNode'  (TJSAudioNode)
+  Private
+    FfrequencyBinCount : NativeInt; external name 'frequencyBinCount'; 
+  Public
+      fftSize : NativeInt;
+      minDecibels : Double;
+      maxDecibels : Double;
+      smoothingTimeConstant : Double;
+    Procedure getFloatFrequencyData(array_ : TJSFloat32Array);
+    Procedure getByteFrequencyData(array_ : TJSUint8Array);
+    Procedure getFloatTimeDomainData(array_ : TJSFloat32Array);
+    Procedure getByteTimeDomainData(array_ : TJSUint8Array);
+    Property frequencyBinCount : NativeInt Read FfrequencyBinCount; 
+  end;
+  
+  { --------------------------------------------------------------------
+    TJSAudioBufferSourceNode
+    --------------------------------------------------------------------}
+  
+  TJSAudioBufferSourceNode = class external name 'AudioBufferSourceNode'  (TJSAudioScheduledSourceNode)
+  Private
+    FplaybackRate : TJSAudioParam; external name 'playbackRate'; 
+    Fdetune : TJSAudioParam; external name 'detune'; 
+  Public
+      buffer : TJSAudioBuffer;
+      loop : boolean;
+      loopStart : Double;
+      loopEnd : Double;
+    Procedure start(when : Double; offset : Double; duration : Double); overload;
+    Procedure start; overload;
+    Procedure start(when : Double); overload;
+    Procedure start(when : Double; offset : Double); overload;
+    Property playbackRate : TJSAudioParam Read FplaybackRate; 
+    Property detune : TJSAudioParam Read Fdetune; 
+  end;
+  
+  { --------------------------------------------------------------------
+    TJSAudioDestinationNode
+    --------------------------------------------------------------------}
+  
+  TJSAudioDestinationNode = class external name 'AudioDestinationNode'  (TJSAudioNode)
+  Private
+    FmaxChannelCount : NativeInt; external name 'maxChannelCount'; 
+  Public
+    Property maxChannelCount : NativeInt Read FmaxChannelCount; 
+  end;
+  
+  { --------------------------------------------------------------------
+    TJSAudioListener
+    --------------------------------------------------------------------}
+  
+  TJSAudioListener = class external name 'AudioListener' 
+  Private
+    FpositionX : TJSAudioParam; external name 'positionX'; 
+    FpositionY : TJSAudioParam; external name 'positionY'; 
+    FpositionZ : TJSAudioParam; external name 'positionZ'; 
+    FforwardX : TJSAudioParam; external name 'forwardX'; 
+    FforwardY : TJSAudioParam; external name 'forwardY'; 
+    FforwardZ : TJSAudioParam; external name 'forwardZ'; 
+    FupX : TJSAudioParam; external name 'upX'; 
+    FupY : TJSAudioParam; external name 'upY'; 
+    FupZ : TJSAudioParam; external name 'upZ'; 
+  Public
+    Procedure setPosition(x : Double; y : Double; z : Double);
+    Procedure setOrientation(x : Double; y : Double; z : Double; xUp : Double; yUp : Double; zUp : Double);
+    Property positionX : TJSAudioParam Read FpositionX; 
+    Property positionY : TJSAudioParam Read FpositionY; 
+    Property positionZ : TJSAudioParam Read FpositionZ; 
+    Property forwardX : TJSAudioParam Read FforwardX; 
+    Property forwardY : TJSAudioParam Read FforwardY; 
+    Property forwardZ : TJSAudioParam Read FforwardZ; 
+    Property upX : TJSAudioParam Read FupX; 
+    Property upY : TJSAudioParam Read FupY; 
+    Property upZ : TJSAudioParam Read FupZ; 
+  end;
+  
+  { --------------------------------------------------------------------
+    TJSAudioProcessingEvent
+    --------------------------------------------------------------------}
+  
+  TJSAudioProcessingEvent = class external name 'AudioProcessingEvent'  (TJSEvent)
+  Private
+    FplaybackTime : Double; external name 'playbackTime'; 
+    FinputBuffer : TJSAudioBuffer; external name 'inputBuffer'; 
+    FoutputBuffer : TJSAudioBuffer; external name 'outputBuffer'; 
+  Public
+    Property playbackTime : Double Read FplaybackTime; 
+    Property inputBuffer : TJSAudioBuffer Read FinputBuffer; 
+    Property outputBuffer : TJSAudioBuffer Read FoutputBuffer; 
+  end;
+  
+  { --------------------------------------------------------------------
+    TJSBiquadFilterNode
+    --------------------------------------------------------------------}
+  
+  TJSBiquadFilterNode = class external name 'BiquadFilterNode'  (TJSAudioNode)
+  Private
+    Ffrequency : TJSAudioParam; external name 'frequency'; 
+    Fdetune : TJSAudioParam; external name 'detune'; 
+    FQ : TJSAudioParam; external name 'Q'; 
+    Fgain : TJSAudioParam; external name 'gain'; 
+  Public
+      type_ : BiquadFilterType;external name 'type';
+    Procedure getFrequencyResponse(frequencyHz : TJSFloat32Array; magResponse : TJSFloat32Array; phaseResponse : TJSFloat32Array);
+    Property frequency : TJSAudioParam Read Ffrequency; 
+    Property detune : TJSAudioParam Read Fdetune; 
+    Property Q : TJSAudioParam Read FQ; 
+    Property gain : TJSAudioParam Read Fgain; 
+  end;
+  
+  { --------------------------------------------------------------------
+    TJSChannelMergerNode
+    --------------------------------------------------------------------}
+  
+  TJSChannelMergerNode = class external name 'ChannelMergerNode'  (TJSAudioNode)
+  Private
+  Public
+  end;
+  
+  { --------------------------------------------------------------------
+    TJSChannelSplitterNode
+    --------------------------------------------------------------------}
+  
+  TJSChannelSplitterNode = class external name 'ChannelSplitterNode'  (TJSAudioNode)
+  Private
+  Public
+  end;
+  
+  { --------------------------------------------------------------------
+    TJSConstantSourceNode
+    --------------------------------------------------------------------}
+  
+  TJSConstantSourceNode = class external name 'ConstantSourceNode'  (TJSAudioScheduledSourceNode)
+  Private
+    Foffset : TJSAudioParam; external name 'offset'; 
+  Public
+    Property offset : TJSAudioParam Read Foffset; 
+  end;
+  
+  { --------------------------------------------------------------------
+    TJSConvolverNode
+    --------------------------------------------------------------------}
+  
+  TJSConvolverNode = class external name 'ConvolverNode'  (TJSAudioNode)
+  Private
+  Public
+      buffer : TJSAudioBuffer;
+      normalize : boolean;
+  end;
+  
+  { --------------------------------------------------------------------
+    TJSDelayNode
+    --------------------------------------------------------------------}
+  
+  TJSDelayNode = class external name 'DelayNode'  (TJSAudioNode)
+  Private
+    FdelayTime : TJSAudioParam; external name 'delayTime'; 
+  Public
+    Property delayTime : TJSAudioParam Read FdelayTime; 
+  end;
+  
+  { --------------------------------------------------------------------
+    TJSDynamicsCompressorNode
+    --------------------------------------------------------------------}
+  
+  TJSDynamicsCompressorNode = class external name 'DynamicsCompressorNode'  (TJSAudioNode)
+  Private
+    Fthreshold : TJSAudioParam; external name 'threshold'; 
+    Fknee : TJSAudioParam; external name 'knee'; 
+    Fratio : TJSAudioParam; external name 'ratio'; 
+    Freduction : Double; external name 'reduction'; 
+    Fattack : TJSAudioParam; external name 'attack'; 
+    Frelease : TJSAudioParam; external name 'release'; 
+  Public
+    Property threshold : TJSAudioParam Read Fthreshold; 
+    Property knee : TJSAudioParam Read Fknee; 
+    Property ratio : TJSAudioParam Read Fratio; 
+    Property reduction : Double Read Freduction; 
+    Property attack : TJSAudioParam Read Fattack; 
+    Property release : TJSAudioParam Read Frelease; 
+  end;
+  
+  { --------------------------------------------------------------------
+    TJSGainNode
+    --------------------------------------------------------------------}
+  
+  TJSGainNode = class external name 'GainNode'  (TJSAudioNode)
+  Private
+    Fgain : TJSAudioParam; external name 'gain'; 
+  Public
+    Property gain : TJSAudioParam Read Fgain; 
+  end;
+  
+  { --------------------------------------------------------------------
+    TJSIIRFilterNode
+    --------------------------------------------------------------------}
+  
+  TJSIIRFilterNode = class external name 'IIRFilterNode'  (TJSAudioNode)
+  Private
+  Public
+    Procedure getFrequencyResponse(frequencyHz : TJSFloat32Array; magResponse : TJSFloat32Array; phaseResponse : TJSFloat32Array);
+  end;
+  
+  { --------------------------------------------------------------------
+    TJSMediaElementAudioSourceNode
+    --------------------------------------------------------------------}
+  
+  TJSMediaElementAudioSourceNode = class external name 'MediaElementAudioSourceNode'  (TJSAudioNode)
+  Private
+    FmediaElement : TJSElement; external name 'mediaElement'; 
+  Public
+    Property mediaElement : TJSElement Read FmediaElement; 
+  end;
+  
+  { --------------------------------------------------------------------
+    TJSMediaStreamAudioDestinationNode
+    --------------------------------------------------------------------}
+  
+  TJSMediaStreamAudioDestinationNode = class external name 'MediaStreamAudioDestinationNode'  (TJSAudioNode)
+  Private
+    Fstream : JSValue; external name 'stream'; 
+  Public
+    Property stream : JSValue Read Fstream; 
+  end;
+  
+  { --------------------------------------------------------------------
+    TJSMediaStreamAudioSourceNode
+    --------------------------------------------------------------------}
+  
+  TJSMediaStreamAudioSourceNode = class external name 'MediaStreamAudioSourceNode'  (TJSAudioNode)
+  Private
+    FmediaStream : JSValue; external name 'mediaStream'; 
+  Public
+    Property mediaStream : JSValue Read FmediaStream; 
+  end;
+  
+  { --------------------------------------------------------------------
+    TJSMediaStreamTrackAudioSourceNode
+    --------------------------------------------------------------------}
+  
+  TJSMediaStreamTrackAudioSourceNode = class external name 'MediaStreamTrackAudioSourceNode'  (TJSAudioNode)
+  Private
+  Public
+  end;
+  
+  { --------------------------------------------------------------------
+    TJSOscillatorNode
+    --------------------------------------------------------------------}
+  
+  TJSOscillatorNode = class external name 'OscillatorNode'  (TJSAudioScheduledSourceNode)
+  Private
+    Ffrequency : TJSAudioParam; external name 'frequency'; 
+    Fdetune : TJSAudioParam; external name 'detune'; 
+  Public
+      type_ : OscillatorType;external name 'type';
+    Procedure setPeriodicWave(periodicWave : TJSPeriodicWave);
+    Property frequency : TJSAudioParam Read Ffrequency; 
+    Property detune : TJSAudioParam Read Fdetune; 
+  end;
+  
+  { --------------------------------------------------------------------
+    TJSPannerNode
+    --------------------------------------------------------------------}
+  
+  TJSPannerNode = class external name 'PannerNode'  (TJSAudioNode)
+  Private
+    FpositionX : TJSAudioParam; external name 'positionX'; 
+    FpositionY : TJSAudioParam; external name 'positionY'; 
+    FpositionZ : TJSAudioParam; external name 'positionZ'; 
+    ForientationX : TJSAudioParam; external name 'orientationX'; 
+    ForientationY : TJSAudioParam; external name 'orientationY'; 
+    ForientationZ : TJSAudioParam; external name 'orientationZ'; 
+  Public
+      panningModel : PanningModelType;
+      distanceModel : DistanceModelType;
+      refDistance : Double;
+      maxDistance : Double;
+      rolloffFactor : Double;
+      coneInnerAngle : Double;
+      coneOuterAngle : Double;
+      coneOuterGain : Double;
+    Procedure setPosition(x : Double; y : Double; z : Double);
+    Procedure setOrientation(x : Double; y : Double; z : Double);
+    Property positionX : TJSAudioParam Read FpositionX; 
+    Property positionY : TJSAudioParam Read FpositionY; 
+    Property positionZ : TJSAudioParam Read FpositionZ; 
+    Property orientationX : TJSAudioParam Read ForientationX; 
+    Property orientationY : TJSAudioParam Read ForientationY; 
+    Property orientationZ : TJSAudioParam Read ForientationZ; 
+  end;
+  
+  { --------------------------------------------------------------------
+    TJSPeriodicWave
+    --------------------------------------------------------------------}
+  
+  TJSPeriodicWave = class external name 'PeriodicWave' 
+  Private
+  Public
+  end;
+  
+  { --------------------------------------------------------------------
+    TJSScriptProcessorNode
+    --------------------------------------------------------------------}
+  
+  TJSScriptProcessorNode = class external name 'ScriptProcessorNode'  (TJSAudioNode)
+  Private
+    FbufferSize : Integer; external name 'bufferSize'; 
+  Public
+      onaudioprocess : TJSEVentHandler;
+    Property bufferSize : Integer Read FbufferSize; 
+  end;
+  
+  { --------------------------------------------------------------------
+    TJSStereoPannerNode
+    --------------------------------------------------------------------}
+  
+  TJSStereoPannerNode = class external name 'StereoPannerNode'  (TJSAudioNode)
+  Private
+    Fpan : TJSAudioParam; external name 'pan'; 
+  Public
+    Property pan : TJSAudioParam Read Fpan; 
+  end;
+  
+  { --------------------------------------------------------------------
+    TJSWaveShaperNode
+    --------------------------------------------------------------------}
+  
+  TJSWaveShaperNode = class external name 'WaveShaperNode'  (TJSAudioNode)
+  Private
+  Public
+      curve : TJSFloat32Array;
+      oversample : OverSampleType;
+  end;
+  
+  { --------------------------------------------------------------------
+    TJSAudioWorklet
+    --------------------------------------------------------------------}
+  
+  TJSAudioWorklet = class external name 'AudioWorklet'  (TJSOBject)
+  Private
+  Public
+  end;
+  
+  { --------------------------------------------------------------------
+    TJSAudioWorkletGlobalScope
+    --------------------------------------------------------------------}
+  
+  TJSAudioWorkletGlobalScope = class external name 'AudioWorkletGlobalScope'  (TJSObject)
+  Private
+    FcurrentFrame : NativeInt; external name 'currentFrame'; 
+    FcurrentTime : Double; external name 'currentTime'; 
+    FsampleRate : Double; external name 'sampleRate'; 
+  Public
+    Procedure registerProcessor(name : String; processorCtor : TProcedure);
+    Property currentFrame : NativeInt Read FcurrentFrame; 
+    Property currentTime : Double Read FcurrentTime; 
+    Property sampleRate : Double Read FsampleRate; 
+  end;
+  
+  { --------------------------------------------------------------------
+    TJSAudioParamMap
+    --------------------------------------------------------------------}
+  
+  TJSAudioParamMap = class external name 'AudioParamMap' 
+  Private
+  Public
+  end;
+  
+  { --------------------------------------------------------------------
+    TJSAudioWorkletNode
+    --------------------------------------------------------------------}
+  
+  TJSAudioWorkletNode = class external name 'AudioWorkletNode'  (TJSAudioNode)
+  Private
+    Fparameters : TJSAudioParamMap; external name 'parameters'; 
+    Fport : TJSMessagePort; external name 'port'; 
+  Public
+      onprocessorerror : TJSEVentHandler;
+    Property parameters : TJSAudioParamMap Read Fparameters; 
+    Property port : TJSMessagePort Read Fport; 
+  end;
+  
+  { --------------------------------------------------------------------
+    TJSAudioWorkletProcessor
+    --------------------------------------------------------------------}
+  
+  TJSAudioWorkletProcessor = class external name 'AudioWorkletProcessor' 
+  Private
+    Fport : TJSMessagePort; external name 'port'; 
+  Public
+    Property port : TJSMessagePort Read Fport; 
+  end;
+
+implementation
+
+
+end.

+ 661 - 658
packages/rtl/webgl.pas

@@ -1,694 +1,697 @@
-unit webgl;
+Unit webgl;
 
-{$mode objfpc}
+{$MODE ObjFPC}
+{$H+}
 {$modeswitch externalclass}
 
 interface
 
-uses JS, Web;
+uses SysUtils, JS,web,types;
 
+{
+  Automatically generated file by TWebIDLToPas on 2018-06-23 15:31:57
+  
+  Used command-line options : 
+  -i
+  webgl.idl
+  -v
+  v2
+  -t
+  EventTarget=TJSEventTarget,DOMHighResTimeStamp=TJSDOMHighResTimeStamp,HTMLMediaElement=TJSElement,MediaStream=JSValue,MediaStreamTrack=JSValue,EventHandler=TJSEVentHandler,Promise=TJSPromise,Event=TJSEvent,Worklet=TJSOBject,WorkletGlobalScope=TJSObject,VoidFunction=TProcedure,MessagePort=TJSMessagePort,HTMLCanvasElement=TJSHTMLCanvasElement,BufferSource=TJSBufferSource,ArrayBufferView=TJSTypedArray
+  -x
+  web,types
+  -d
+  -p
+  
+  Command-line options translate to: 
+  
+  Options : [coDictionaryAsClass,coaddOptionsToheader]
+  Keyword prefix : 
+  Keyword suffix : _
+  Class prefix : TJS
+  Class suffix : 
+  Field prefix : F
+  WEBIDLversion : v2
+  Type aliases:
+  EventTarget=TJSEventTarget
+  DOMHighResTimeStamp=TJSDOMHighResTimeStamp
+  HTMLMediaElement=TJSElement
+  MediaStream=JSValue
+  MediaStreamTrack=JSValue
+  EventHandler=TJSEVentHandler
+  Promise=TJSPromise
+  Event=TJSEvent
+  Worklet=TJSOBject
+  WorkletGlobalScope=TJSObject
+  VoidFunction=TProcedure
+  MessagePort=TJSMessagePort
+  HTMLCanvasElement=TJSHTMLCanvasElement
+  BufferSource=TJSBufferSource
+  ArrayBufferView=TJSTypedArray
+}
 Type
-  GLenum = Cardinal;
-  GLboolean = Boolean;
-  GLbitfield = Cardinal;
-  GLbyte = ShortInt;         (* 'byte' should be a signed 8 bit type. *)
+  // Forward class definitions
+  TJSWebGLObject = Class;
+  TJSWebGLBuffer = Class;
+  TJSWebGLFramebuffer = Class;
+  TJSWebGLProgram = Class;
+  TJSWebGLRenderbuffer = Class;
+  TJSWebGLShader = Class;
+  TJSWebGLTexture = Class;
+  TJSWebGLUniformLocation = Class;
+  TJSWebGLActiveInfo = Class;
+  TJSWebGLShaderPrecisionFormat = Class;
+  TJSWebGLRenderingContextBase = Class;
+  TJSWebGLRenderingContext = Class;
+  TJSWebGLContextEvent = Class;
+  TJSWebGLContextAttributes = Class;
+  TJSWebGLContextEventInit = Class;
+  WebGLPowerPreference = String;
+  GLenum = NativeInt;
+  GLboolean = boolean;
+  GLbitfield = NativeInt;
+  GLbyte = byte;
   GLshort = Integer;
   GLint = Integer;
   GLsizei = Integer;
   GLintptr = NativeInt;
   GLsizeiptr = NativeInt;
-// Ideally the typedef below would use 'unsigned byte', but that doesn't currently exist in Web IDL.
-  GLubyte = Byte;        (* 'octet' should be an unsigned 8 bit type. *)
-  GLushort = Word;
-  GLuint = Cardinal;
+  GLubyte = Byte;
+  GLushort = Cardinal;
+  GLuint = NativeInt;
   GLfloat = Double;
   GLclampf = Double;
-
-  TJSWebGLPowerPreference = String;
-// "default", "low-power", "high-performance"
-
-
-  TJSWebGLContextAttributes  = Class external name 'WebGLContextAttributes' (TJSObject)
-    alpha :GLboolean;
+  // Union of ImageBitmap, ImageData, HTMLImageElement, HTMLCanvasElement, HTMLVideoElement
+  TexImageSource = JSValue; 
+  // Union of Float32Array, sequence
+  Float32List = JSValue; 
+  // Union of Int32Array, sequence
+  Int32List = JSValue; 
+  
+  { --------------------------------------------------------------------
+    TJSWebGLContextAttributes
+    --------------------------------------------------------------------}
+  
+  TJSWebGLContextAttributes = class(TJSObject)
+    alpha : GLboolean;
     depth : GLboolean;
-    stencil :  GLboolean;
+    stencil : GLboolean;
     antialias : GLboolean;
     premultipliedAlpha : GLboolean;
     preserveDrawingBuffer : GLboolean;
-    powerPreference  : string;
-    failIfMajorPerformanceCaveat : GLBoolean;
+    powerPreference : WebGLPowerPreference;
+    failIfMajorPerformanceCaveat : GLboolean;
   end;
-
-  TJSWebGLObject = class external name 'WebGLObject' (TJSObject);
-  TJSWebGLBuffer = Class external name 'WebGLBuffer' (TJSWebGLObject);
-  TJSWebGLFramebuffer = Class external name 'WebGLFramebuffer' (TJSWebGLObject);
-  TJSWebGLProgram = Class external name 'WebGLProgram' (TJSWebGLObject);
-  TJSWebGLRenderbuffer = Class external name 'WebGLRenderbuffer' (TJSWebGLObject);
-  TJSWebGLShader = Class external name 'WebGLShader' (TJSWebGLObject);
-  TJSWebGLTexture = Class external name 'WebGLTexture' (TJSWebGLObject);
-  TJSWebGLUniformLocation = class external name 'WebGLUniformLocation' (TJSWebGLObject);
-
-  TJSWebGLActiveInfo = Class external name 'WebGLActiveInfo' (TJSOBject)
+  
+  { --------------------------------------------------------------------
+    TJSWebGLContextEventInit
+    --------------------------------------------------------------------}
+  
+  TJSWebGLContextEventInit = class(TJSObject)
+    statusMessage : String;
+  end;
+  
+  { --------------------------------------------------------------------
+    TJSWebGLObject
+    --------------------------------------------------------------------}
+  
+  TJSWebGLObject = class external name 'WebGLObject' 
   Private
-    Fsize : GLint; external name 'size';
-    Ftype : GLenum; external name 'type';
-    Fname : String; external name 'name';
   Public
-    Property size : GLint read Fsize;
-    Property &type : GLenum read Ftype;
-    Property name : String read Fname;
+    
   end;
-
-  TJSWebGLShaderPrecisionFormat = Class external name 'WebGLShaderPrecisionFormat' (TJSObject)
+  
+  { --------------------------------------------------------------------
+    TJSWebGLBuffer
+    --------------------------------------------------------------------}
+  
+  TJSWebGLBuffer = class external name 'WebGLBuffer'  (TJSWebGLObject)
   Private
-    FrangeMin : GLint; external name 'rangeMin';
-    FrangeMax : GLint; external name 'rangeMax';
-    Fprecision : GLint; external name 'precision';
   Public
-    Property rangeMin : GLint read FrangeMin;
-    Property rangeMax : GLint read FrangeMax;
-    Property precision : GLint read Fprecision;
   end;
-
-{
- typedef (ImageBitmap or
-         ImageData or
-         HTMLImageElement or
-         HTMLCanvasElement or
-         HTMLVideoElement) 
-}
-
-  TJSArrayBufferView = TJSTypedArray;
-  TJSTexImageSource = JSValue;
-  TJSFloat32List = Array of GLFloat;
-  TJSInt32List = Array of integer;
-  TJSUInt32List = Array of longword;
-
-  TJSWebGLShaderArray = array of TJSWebGLShader;
-  TJSWebGLRenderingContextBase = Class External name 'WebGLRenderingContextBase' (TJSObject)
-
+  
+  { --------------------------------------------------------------------
+    TJSWebGLFramebuffer
+    --------------------------------------------------------------------}
+  
+  TJSWebGLFramebuffer = class external name 'WebGLFramebuffer'  (TJSWebGLObject)
+  Private
   Public
-
-  (* ClearBufferMask *)
-  const
-    DEPTH_BUFFER_BIT : Nativeint;
-    STENCIL_BUFFER_BIT : NativeInt;
-    COLOR_BUFFER_BIT : NativeInt;
-
-   (* BeginMode *)
-    POINTS      : NativeInt;
-    LINES       : NativeInt;
-    LINE_LOOP      : NativeInt;
-    LINE_STRIP      : NativeInt;
-    TRIANGLES      : NativeInt;
-    TRIANGLE_STRIP     : NativeInt;
-    TRIANGLE_FAN     : NativeInt;
-
-   (* AlphaFunction (not supported in ES20) *)
-   (*  NEVER *)
-   (*  LESS *)
-   (*  EQUAL *)
-   (*  LEQUAL *)
-   (*  GREATER *)
-   (*  NOTEQUAL *)
-   (*  GEQUAL *)
-   (*  ALWAYS *)
-
-   (* BlendingFactorDest *)
-    ZERO       : NativeInt;
-    ONE       : NativeInt;
-    SRC_COLOR      : NativeInt;
-    ONE_MINUS_SRC_COLOR   : NativeInt;
-    SRC_ALPHA      : NativeInt;
-    ONE_MINUS_SRC_ALPHA   : NativeInt;
-    DST_ALPHA      : NativeInt;
-    ONE_MINUS_DST_ALPHA   : NativeInt;
-
-   (* BlendingFactorSrc *)
-   (*  ZERO *)
-   (*  ONE *)
-    DST_COLOR      : NativeInt;
-    ONE_MINUS_DST_COLOR   : NativeInt;
-    SRC_ALPHA_SATURATE    : NativeInt;
-   (*  SRC_ALPHA *)
-   (*  ONE_MINUS_SRC_ALPHA *)
-   (*  DST_ALPHA *)
-   (*  ONE_MINUS_DST_ALPHA *)
-
-   (* BlendEquationSeparate *)
-    FUNC_ADD      : NativeInt;
-    BLEND_EQUATION     : NativeInt;
-    BLEND_EQUATION_RGB   : Nativeint; (* same as BLEND_EQUATION *)
-    BLEND_EQUATION_ALPHA   : NativeInt;
-
-   (* BlendSubtract *)
-    FUNC_SUBTRACT     : NativeInt;
-    FUNC_REVERSE_SUBTRACT   : NativeInt;
-
-   (* Separate Blend Functions *)
-    BLEND_DST_RGB     : NativeInt;
-    BLEND_SRC_RGB     : NativeInt;
-    BLEND_DST_ALPHA    : NativeInt;
-    BLEND_SRC_ALPHA    : NativeInt;
-    CONSTANT_COLOR     : NativeInt;
-    ONE_MINUS_CONSTANT_COLOR  : NativeInt;
-    CONSTANT_ALPHA     : NativeInt;
-    ONE_MINUS_CONSTANT_ALPHA  : NativeInt;
-    BLEND_COLOR     : NativeInt;
-
-   (* Buffer Objects *)
-    ARRAY_BUFFER     : NativeInt;
-    ELEMENT_ARRAY_BUFFER   : NativeInt;
-    ARRAY_BUFFER_BINDING   : NativeInt;
-    ELEMENT_ARRAY_BUFFER_BINDING : NativeInt;
-
-    STREAM_DRAW     : NativeInt;
-    STATIC_DRAW     : NativeInt;
-    DYNAMIC_DRAW     : NativeInt;
-
-    BUFFER_SIZE     : NativeInt;
-    BUFFER_USAGE     : NativeInt;
-
-    CURRENT_VERTEX_ATTRIB   : NativeInt;
-
-   (* CullFaceMode *)
-    FRONT       : NativeInt;
-    BACK       : NativeInt;
-    FRONT_AND_BACK     : NativeInt;
-
-   (* DepthFunction *)
-   (*  NEVER *)
-   (*  LESS *)
-   (*  EQUAL *)
-   (*  LEQUAL *)
-   (*  GREATER *)
-   (*  NOTEQUAL *)
-   (*  GEQUAL *)
-   (*  ALWAYS *)
-
-   (* EnableCap *)
-   (* TEXTURE_2D *)
-    CULL_FACE      : NativeInt;
-    BLEND       : NativeInt;
-    DITHER       : NativeInt;
-    STENCIL_TEST     : NativeInt;
-    DEPTH_TEST      : NativeInt;
-    SCISSOR_TEST     : NativeInt;
-    POLYGON_OFFSET_FILL   : NativeInt;
-    SAMPLE_ALPHA_TO_COVERAGE  : NativeInt;
-    SAMPLE_COVERAGE    : NativeInt;
-
-   (* ErrorCode *)
-    NO_ERROR      : NativeInt;
-    INVALID_ENUM     : NativeInt;
-    INVALID_VALUE     : NativeInt;
-    INVALID_OPERATION    : NativeInt;
-    OUT_OF_MEMORY     : NativeInt;
-
-   (* FrontFaceDirection *)
-    CW        : NativeInt;
-    CCW       : NativeInt;
-
-   (* GetPName *)
-    LINE_WIDTH      : NativeInt;
-    ALIASED_POINT_SIZE_RANGE  : NativeInt;
-    ALIASED_LINE_WIDTH_RANGE  : NativeInt;
-    CULL_FACE_MODE     : NativeInt;
-    FRONT_FACE      : NativeInt;
-    DEPTH_RANGE     : NativeInt;
-    DEPTH_WRITEMASK    : NativeInt;
-    DEPTH_CLEAR_VALUE    : NativeInt;
-    DEPTH_FUNC      : NativeInt;
-    STENCIL_CLEAR_VALUE   : NativeInt;
-    STENCIL_FUNC     : NativeInt;
-    STENCIL_FAIL     : NativeInt;
-    STENCIL_PASS_DEPTH_FAIL  : NativeInt;
-    STENCIL_PASS_DEPTH_PASS  : NativeInt;
-    STENCIL_REF     : NativeInt;
-    STENCIL_VALUE_MASK    : NativeInt;
-    STENCIL_WRITEMASK    : NativeInt;
-    STENCIL_BACK_FUNC    : NativeInt;
-    STENCIL_BACK_FAIL    : NativeInt;
-    STENCIL_BACK_PASS_DEPTH_FAIL : NativeInt;
-    STENCIL_BACK_PASS_DEPTH_PASS : NativeInt;
-    STENCIL_BACK_REF    : NativeInt;
-    STENCIL_BACK_VALUE_MASK  : NativeInt;
-    STENCIL_BACK_WRITEMASK   : NativeInt;
-    _VIEWPORT      : NativeInt;
-    SCISSOR_BOX     : NativeInt;
-   (*  SCISSOR_TEST *)
-    COLOR_CLEAR_VALUE    : NativeInt;
-    COLOR_WRITEMASK    : NativeInt;
-    UNPACK_ALIGNMENT    : NativeInt;
-    PACK_ALIGNMENT     : NativeInt;
-    MAX_TEXTURE_SIZE    : NativeInt;
-    MAX_VIEWPORT_DIMS    : NativeInt;
-    SUBPIXEL_BITS     : NativeInt;
-    RED_BITS      : NativeInt;
-    GREEN_BITS      : NativeInt;
-    BLUE_BITS      : NativeInt;
-    ALPHA_BITS      : NativeInt;
-    DEPTH_BITS      : NativeInt;
-    STENCIL_BITS     : NativeInt;
-    POLYGON_OFFSET_UNITS   : NativeInt;
-   (*  POLYGON_OFFSET_FILL *)
-    POLYGON_OFFSET_FACTOR   : NativeInt;
-    TEXTURE_BINDING_2D    : NativeInt;
-    SAMPLE_BUFFERS     : NativeInt;
-    SAMPLES      : NativeInt;
-    SAMPLE_COVERAGE_VALUE   : NativeInt;
-    SAMPLE_COVERAGE_INVERT   : NativeInt;
-
-   (* GetTextureParameter *)
-   (*  TEXTURE_MAG_FILTER *)
-   (*  TEXTURE_MIN_FILTER *)
-   (*  TEXTURE_WRAP_S *)
-   (*  TEXTURE_WRAP_T *)
-
-    COMPRESSED_TEXTURE_FORMATS  : NativeInt;
-
-   (* HintMode *)
-    DONT_CARE      : NativeInt;
-    FASTEST      : NativeInt;
-    NICEST       : NativeInt;
-
-   (* HintTarget *)
-    GENERATE_MIPMAP_HINT   : NativeInt;
-
-   (* DataType *)
-    BYTE       : NativeInt;
-    UNSIGNED_BYTE     : NativeInt;
-    SHORT       : NativeInt;
-    UNSIGNED_SHORT     : NativeInt;
-    INT       : NativeInt;
-    UNSIGNED_INT     : NativeInt;
-    FLOAT       : NativeInt;
-
-   (* PixelFormat *)
-    DEPTH_COMPONENT    : NativeInt;
-    ALPHA       : NativeInt;
-    RGB       : NativeInt;
-    RGBA       : NativeInt;
-    LUMINANCE      : NativeInt;
-    LUMINANCE_ALPHA    : NativeInt;
-
-   (* PixelType *)
-   (*  UNSIGNED_BYTE *)
-    UNSIGNED_SHORT_4_4_4_4   : NativeInt;
-    UNSIGNED_SHORT_5_5_5_1   : NativeInt;
-    UNSIGNED_SHORT_5_6_5   : NativeInt;
-
-   (* Shaders *)
-    FRAGMENT_SHADER     : NativeInt;
-    VERTEX_SHADER     : NativeInt;
-    MAX_VERTEX_ATTRIBS    : NativeInt;
-    MAX_VERTEX_UNIFORM_VECTORS  : NativeInt;
-    MAX_VARYING_VECTORS    : NativeInt;
-    MAX_COMBINED_TEXTURE_IMAGE_UNITS : NativeInt;
-    MAX_VERTEX_TEXTURE_IMAGE_UNITS : NativeInt;
-    MAX_TEXTURE_IMAGE_UNITS   : NativeInt;
-    MAX_FRAGMENT_UNIFORM_VECTORS  : NativeInt;
-    SHADER_TYPE      : NativeInt;
-    DELETE_STATUS     : NativeInt;
-    LINK_STATUS      : NativeInt;
-    VALIDATE_STATUS     : NativeInt;
-    ATTACHED_SHADERS     : NativeInt;
-    ACTIVE_UNIFORMS     : NativeInt;
-    ACTIVE_ATTRIBUTES    : NativeInt;
-    SHADING_LANGUAGE_VERSION   : NativeInt;
-    CURRENT_PROGRAM     : NativeInt;
-
-   (* StencilFunction *)
-    NEVER       : NativeInt;
-    LESS       : NativeInt;
-    EQUAL       : NativeInt;
-    LEQUAL       : NativeInt;
-    GREATER      : NativeInt;
-    NOTEQUAL      : NativeInt;
-    GEQUAL       : NativeInt;
-    ALWAYS       : NativeInt;
-
-   (* StencilOp *)
-   (*  ZERO *)
-    KEEP       : NativeInt;
-    REPLACE      : NativeInt;
-    INCR       : NativeInt;
-    DECR       : NativeInt;
-    INVERT       : NativeInt;
-    INCR_WRAP      : NativeInt;
-    DECR_WRAP      : NativeInt;
-
-   (* StringName *)
-    VENDOR       : NativeInt;
-    RENDERER      : NativeInt;
-    VERSION      : NativeInt;
-
-   (* TextureMagFilter *)
-    NEAREST      : NativeInt;
-    LINEAR       : NativeInt;
-
-   (* TextureMinFilter *)
-   (*  NEAREST *)
-   (*  LINEAR *)
-    NEAREST_MIPMAP_NEAREST   : NativeInt;
-    LINEAR_MIPMAP_NEAREST   : NativeInt;
-    NEAREST_MIPMAP_LINEAR   : NativeInt;
-    LINEAR_MIPMAP_LINEAR   : NativeInt;
-
-   (* TextureParameterName *)
-    TEXTURE_MAG_FILTER    : NativeInt;
-    TEXTURE_MIN_FILTER    : NativeInt;
-    TEXTURE_WRAP_S     : NativeInt;
-    TEXTURE_WRAP_T     : NativeInt;
-
-   (* TextureTarget *)
-    TEXTURE_2D      : NativeInt;
-    TEXTURE      : NativeInt;
-
-    TEXTURE_CUBE_MAP    : NativeInt;
-    TEXTURE_BINDING_CUBE_MAP  : NativeInt;
-    TEXTURE_CUBE_MAP_POSITIVE_X : NativeInt;
-    TEXTURE_CUBE_MAP_NEGATIVE_X : NativeInt;
-    TEXTURE_CUBE_MAP_POSITIVE_Y : NativeInt;
-    TEXTURE_CUBE_MAP_NEGATIVE_Y : NativeInt;
-    TEXTURE_CUBE_MAP_POSITIVE_Z : NativeInt;
-    TEXTURE_CUBE_MAP_NEGATIVE_Z : NativeInt;
-    MAX_CUBE_MAP_TEXTURE_SIZE  : NativeInt;
-
-   (* TextureUnit *)
-    TEXTURE0      : NativeInt;
-    TEXTURE1      : NativeInt;
-    TEXTURE2      : NativeInt;
-    TEXTURE3      : NativeInt;
-    TEXTURE4      : NativeInt;
-    TEXTURE5      : NativeInt;
-    TEXTURE6      : NativeInt;
-    TEXTURE7      : NativeInt;
-    TEXTURE8      : NativeInt;
-    TEXTURE9      : NativeInt;
-    TEXTURE10      : NativeInt;
-    TEXTURE11      : NativeInt;
-    TEXTURE12      : NativeInt;
-    TEXTURE13      : NativeInt;
-    TEXTURE14      : NativeInt;
-    TEXTURE15      : NativeInt;
-    TEXTURE16      : NativeInt;
-    TEXTURE17      : NativeInt;
-    TEXTURE18      : NativeInt;
-    TEXTURE19      : NativeInt;
-    TEXTURE20      : NativeInt;
-    TEXTURE21      : NativeInt;
-    TEXTURE22      : NativeInt;
-    TEXTURE23      : NativeInt;
-    TEXTURE24      : NativeInt;
-    TEXTURE25      : NativeInt;
-    TEXTURE26      : NativeInt;
-    TEXTURE27      : NativeInt;
-    TEXTURE28      : NativeInt;
-    TEXTURE29      : NativeInt;
-    TEXTURE30      : NativeInt;
-    TEXTURE31      : NativeInt;
-    ACTIVE_TEXTURE     : NativeInt;
-
-   (* TextureWrapMode *)
-    _REPEAT       : NativeInt;
-    CLAMP_TO_EDGE     : NativeInt;
-    MIRRORED_REPEAT    : NativeInt;
-
-   (* Uniform Types *)
-    FLOAT_VEC2      : NativeInt;
-    FLOAT_VEC3      : NativeInt;
-    FLOAT_VEC4      : NativeInt;
-    INT_VEC2      : NativeInt;
-    INT_VEC3      : NativeInt;
-    INT_VEC4      : NativeInt;
-    BOOL       : NativeInt;
-    BOOL_VEC2      : NativeInt;
-    BOOL_VEC3      : NativeInt;
-    BOOL_VEC4      : NativeInt;
-    FLOAT_MAT2      : NativeInt;
-    FLOAT_MAT3      : NativeInt;
-    FLOAT_MAT4      : NativeInt;
-    SAMPLER_2D      : NativeInt;
-    SAMPLER_CUBE     : NativeInt;
-
-   (* Vertex Arrays *)
-    VERTEX_ATTRIB_ARRAY_ENABLED  : NativeInt;
-    VERTEX_ATTRIB_ARRAY_SIZE   : NativeInt;
-    VERTEX_ATTRIB_ARRAY_STRIDE   : NativeInt;
-    VERTEX_ATTRIB_ARRAY_TYPE   : NativeInt;
-    VERTEX_ATTRIB_ARRAY_NORMALIZED  : NativeInt;
-    VERTEX_ATTRIB_ARRAY_POINTER  : NativeInt;
-    VERTEX_ATTRIB_ARRAY_BUFFER_BINDING : NativeInt;
-
-   (* Read Format *)
-    IMPLEMENTATION_COLOR_READ_TYPE : NativeInt;
-    IMPLEMENTATION_COLOR_READ_FORMAT : NativeInt;
-
-   (* Shader Source *)
-    COMPILE_STATUS     : NativeInt;
-
-   (* Shader Precision-Specified Types *)
-    LOW_FLOAT      : NativeInt;
-    MEDIUM_FLOAT     : NativeInt;
-    HIGH_FLOAT      : NativeInt;
-    LOW_INT      : NativeInt;
-    MEDIUM_INT      : NativeInt;
-    HIGH_INT      : NativeInt;
-
-   (* Framebuffer Object. *)
-    FRAMEBUFFER     : NativeInt;
-    RENDERBUFFER     : NativeInt;
-
-    RGBA4       : NativeInt;
-    RGB5_A1      : NativeInt;
-    RGB565       : NativeInt;
-    DEPTH_COMPONENT16    : NativeInt;
-    STENCIL_INDEX8     : NativeInt;
-    DEPTH_STENCIL     : NativeInt;
-
-    RENDERBUFFER_WIDTH    : NativeInt;
-    RENDERBUFFER_HEIGHT   : NativeInt;
-    RENDERBUFFER_INTERNAL_FORMAT : NativeInt;
-    RENDERBUFFER_RED_SIZE   : NativeInt;
-    RENDERBUFFER_GREEN_SIZE  : NativeInt;
-    RENDERBUFFER_BLUE_SIZE   : NativeInt;
-    RENDERBUFFER_ALPHA_SIZE  : NativeInt;
-    RENDERBUFFER_DEPTH_SIZE  : NativeInt;
-    RENDERBUFFER_STENCIL_SIZE  : NativeInt;
-
-    FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE   : NativeInt;
-    FRAMEBUFFER_ATTACHMENT_OBJECT_NAME   : NativeInt;
-    FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL   : NativeInt;
-    FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE : NativeInt;
-
-    COLOR_ATTACHMENT0    : NativeInt;
-    DEPTH_ATTACHMENT    : NativeInt;
-    STENCIL_ATTACHMENT    : NativeInt;
-    DEPTH_STENCIL_ATTACHMENT  : NativeInt;
-
-    NONE       : NativeInt;
-
-    FRAMEBUFFER_COMPLETE      : NativeInt;
-    FRAMEBUFFER_INCOMPLETE_ATTACHMENT   : NativeInt;
-    FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT : NativeInt;
-    FRAMEBUFFER_INCOMPLETE_DIMENSIONS   : NativeInt;
-    FRAMEBUFFER_UNSUPPORTED     : NativeInt;
-
-    FRAMEBUFFER_BINDING   : NativeInt;
-    RENDERBUFFER_BINDING   : NativeInt;
-    MAX_RENDERBUFFER_SIZE   : NativeInt;
-
-    INVALID_FRAMEBUFFER_OPERATION : NativeInt;
-
-   (* WebGL-specific enums *)
-    UNPACK_FLIP_Y_WEBGL   : NativeInt;
-    UNPACK_PREMULTIPLY_ALPHA_WEBGL : NativeInt;
-    CONTEXT_LOST_WEBGL    : NativeInt;
-    UNPACK_COLORSPACE_CONVERSION_WEBGL : NativeInt;
-    BROWSER_DEFAULT_WEBGL   : NativeInt;
-
+  end;
+  
+  { --------------------------------------------------------------------
+    TJSWebGLProgram
+    --------------------------------------------------------------------}
+  
+  TJSWebGLProgram = class external name 'WebGLProgram'  (TJSWebGLObject)
   Private
-    Fcanvas : TJSHTMLCanvasElement; external name 'canvas';
-    FdrawingBufferWidth : GLsizei; external name 'drawingBufferWidth';
-    FdrawingBufferHeight : GLsizei; external name 'drawingBufferHeight';
   Public
-    function getContextAttributes() : TJSWebGLContextAttributes;
-    function isContextLost() : boolean ;
-    function getSupportedExtensions() : TJSStringDynArray;
-    function getExtension(name : String) : TJSobject;
-    procedure activeTexture(texture : GLenum);
-    procedure attachShader(aprogram : TJSWebGLProgram ; shader : TJSWebGLShader);
-    procedure bindAttribLocation(WebGLProgram : TJSWebGLProgram ; index : GLuint; name : String);
-    procedure bindBuffer(target : GLenum; buffer : TJSWebGLBuffer );
-    procedure bindFramebuffer(target : GLenum; framebuffer : TJSWebGLFramebuffer );
-    procedure bindRenderbuffer(target : GLenum; renderbuffer : TJSWebGLRenderbuffer);
-    procedure bindTexture(target : GLenum; texture : TJSWebGLTexture);
-    procedure blendColor(red : GLclampf; green : GLclampf; blue : GLclampf; alpha : GLclampf);
-    procedure blendEquation(RGB : GLenum; mode : GLenum);
-    procedure blendEquationSeparate(Alpha : GLenum; mode : GLenum);
-    procedure blendFunc(sfactor : GLenum; dfactor : GLenum);
-    procedure blendFuncSeparate(srcRGB : GLenum; dstRGB : GLenum ; dstAlpha : GLenum; srcAlpha : GLenum);
-
-    procedure bufferData(target : GLenum; size : GLsizeiptr ; usage : GLenum);
-    procedure bufferData(target : GLenum;  data : TJSBufferSource ; usage : GLenum);
-    procedure bufferSubData(target : GLenum; offset : GLintptr; data : TJSBufferSource);
-
-    function checkFramebufferStatus(target : GLenum) :String;
-    procedure clear(mask : GLbitfield);
-    procedure clearColor(red: GLclampf ; green : GLclampf; blue: GLclampf ; alpha: GLclampf );
-    procedure clearDepth(depth : GLclampf);
-    procedure clearStencil(s : GLint);
-    procedure colorMask(red : GLboolean ; green : GLboolean ; blue : GLboolean; alpha: GLboolean );
-    procedure compileShader(shader : TJSWebGLShader);
-    procedure compressedTexImage2D(target : GLenum ; level : GLint; internalformat : GLenum ; width : GLsizei; height : GLsizei ; border : GLint; data : TJSArrayBufferView);
-    procedure compressedTexSubImage2D(target : GLenum; level: GLint ; xoffset : GLint; yoffset : GLint ; width : GLsizei; height: GLsizei ; format : GLenum; data: TJSArrayBufferView );
-    procedure copyTexImage2D(target : GLenum; level : GLint ; internalformat : GLenum; x: GLint ; y : GLint; width : GLsizei ; height : GLsizei;border: GLint );
-    procedure copyTexSubImage2D(target : GLenum; level: GLint ; xoffset : GLint; yoffset : GLint ; x : GLint; y: GLint ; width : GLsizei; height: GLsizei );
-
-    function createBuffer() : TJSWebGLBuffer;
-    function createFramebuffer() : TJSWebGLFramebuffer;
-    function createProgram() : TJSWebGLProgram;
-    function createRenderbuffer() : TJSWebGLRenderbuffer;
-    function createShader(atype : GLenum) : TJSWebGLShader;
-    function createTexture() : TJSWebGLTexture;
-    procedure cullFace(mode : GLenum);
-
-    procedure deleteBuffer(buffer : TJSWebGLBuffer);
-    procedure deleteFramebuffer(framebuffer : TJSWebGLFramebuffer);
-    procedure deleteProgram(aprogram : TJSWebGLProgram);
-    procedure deleteRenderbuffer(renderbuffer : TJSWebGLRenderbuffer);
-    procedure deleteShader(shader : TJSWebGLShader);
-    procedure deleteTexture(texture : TJSWebGLTexture);
-
-    procedure depthFunc(func : GLenum);
-    procedure depthMask(flag : GLboolean);
-    procedure depthRange(zNear: GLclampf ; zFar : GLclampf);
-    procedure detachShader(aprogram : TJSWebGLProgram; shader: TJSWebGLShader );
-    procedure disable(cap : GLenum);
-    procedure disableVertexAttribArray(index : GLuint);
-    procedure drawArrays(mode: GLenum ; first : GLint; count: GLsizei );
-    procedure drawElements(mode : GLenum; count: GLsizei ; atype : GLenum; offset: GLintptr );
-
-    procedure enable(cap : GLenum);
-    procedure enableVertexAttribArray(index : GLuint);
-    procedure finish();
-    procedure flush();
-    procedure framebufferRenderbuffer(target: GLenum ; attachment : GLenum; renderbuffertarget: GLenum; renderbuffer: TJSWebGLRenderbuffer );
-    procedure framebufferTexture2D(target : GLenum; attachment:GLenum ;textarget: GLenum ; texture : TJSWebGLTexture; level: GLint );
-    procedure frontFace(mode : GLenum);
-    procedure generateMipmap(target : GLenum);
-    function getActiveAttrib(aprogram: TJSWebGLProgram ; index : GLuint) : TJSWebGLActiveInfo;
-    function getActiveUniform(aprogram : TJSWebGLProgram; index: GLuint ) : TJSWebGLActiveInfo;
-    function getAttachedShaders(aprogram: TJSWebGLProgram) : TJSWebGLShaderArray ;
-    function getAttribLocation(aprogram :TJSWebGLProgram ; name : String) : GLint ;
-    function getBufferParameter(target : GLenum; pname: GLenum ) : JSValue;
-    function getParameter(pname : GLenum) : JSValue;
-    function getError() : Integer;
-    function getFramebufferAttachmentParameter(target: GLenum ; attachment : GLenum; pname : GLenum ) : JSValue;
-    function getProgramParameter(aprogram : TJSWebGLProgram; pname : GLenum) : JSValue;
-    Function getProgramInfoLog(aprogram : TJSWebGLProgram) : String;
-    function getRenderbufferParameter(target: GLenum ; pname : GLenum) : JSValue;
-    function getShaderParameter(shader : TJSWebGLShader; pname: GLenum ) : JSValue;
-    Function getShaderPrecisionFormat(shadertype : GLenum; precisiontype:GLenum ) : TJSWebGLShaderPrecisionFormat;
-    function getShaderInfoLog(shader : TJSWebGLShader) : TJSString;
-    function getShaderSource(shader : TJSWebGLShader) : TJSString;
-    function getTexParameter(target: GLenum ; pname : GLenum) : JSValue;
-    function getUniform(aprogram : TJSWebGLProgram; location: TJSWebGLUniformLocation ) : JSValue;
-    function getUniformLocation(aprogram : TJSWebGLProgram; name :String )  : TJSWebGLUniformLocation;
-    Function getVertexAttrib(index : GLuint; pname: GLenum ) : JSValue;
-    Function getVertexAttribOffset(index : GLuint; pname: GLenum ) : GLintptr ;
-    procedure hint(target : GLenum; mode: GLenum );
-    function isBuffer(buffer : TJSWebGLBuffer) : GLBoolean;
-    function isEnabled(cap : GLenum) : GLBoolean;
-    function isFramebuffer(framebuffer : TJSWebGLFramebuffer) : GLBoolean;
-    function isProgram(aprogram : TJSWebGLProgram) : GLBoolean;
-    function isRenderbuffer(renderbuffer : TJSWebGLRenderbuffer) : GLBoolean;
-    function isShader(shader : TJSWebGLShader) : GLBoolean;
-    function isTexture(texture : TJSWebGLTexture) : GLBoolean;
-    procedure lineWidth(width : GLfloat);
-    procedure linkProgram(aprogram : TJSWebGLProgram);
-    procedure pixelStorei(pname: GLenum ; param : GLint);
-    procedure polygonOffset(factor : GLfloat; units: GLfloat );
-    procedure readPixels(x : GLint; y : GLint ; width : GLsizei; height : GLsizei ; format : GLenum; atype: GLenum ;  pixels: TJSArrayBufferView );
-    procedure renderbufferStorage(target : GLenum; internalformat :GLenum ; width : GLsizei; height: GLsizei );
-    procedure sampleCoverage(value : GLclampf; invert: GLboolean );
-    procedure scissor(x : GLint; y : GLint ; width : GLsizei; height : GLsizei);
-    procedure shaderSource(shader : TJSWebGLShader; source: String);
-    procedure stencilFunc(func : GLenum; ref: GLint ; mask : GLuint);
-    procedure stencilFuncSeparate(face : GLenum; func: GLenum ; ref : GLint; mask: GLuint );
-    procedure stencilMask(mask : GLuint);
-    procedure stencilMaskSeparate(face : GLenum ; mask : GLuint);
-    procedure stencilOp(fail : GLenum; zfail : GLEnum; zpass : GLenum);
-    procedure stencilOpSeparate(face : GLenum; fail : GLEnum; zfail : GLenum; zpass: GLenum );
-    procedure texImage2D(target : GLenum; level : GLint; internalformat : GLint; width: GLsizei ; height : GLsizei; border: GLint ; format : GLenum; atype : GLEnum; pixels : TJSArrayBufferView ) ;
-    procedure texImage2D(target : GLenum; level : GLint; internalformat : GLint; format : GLEnum; atype : GLenum; source : TJSTexImageSource ); // May throw DOMException
-
-    procedure texParameterf(target : GLenum; pname : GLEnum; param : GLfloat);
-    procedure texParameteri(target : GLenum; pname : GLEnum; param : GLint);
-
-    procedure texSubImage2D(target : GLenum; level : GLint; xoffset : GLint; yoffset : GLint; width : GLsizei; height : GLsizei ; format : GLenum; atype : GLenum ;  pixels : TJSArrayBufferView);
-    procedure texSubImage2D(target : GLenum; level : GLint; xoffset : GLint; yoffset : GLint; format : GLenum; atype : GLenum ; source: TJSTexImageSource ); // May throw DOMException
-
-    procedure uniform1f(location : TJSWebGLUniformLocation; x : GLFLoat);
-    procedure uniform2f(location : TJSWebGLUniformLocation; x : GLFLoat; y : GLfloat);
-    procedure uniform3f(location : TJSWebGLUniformLocation; x : GLFLoat; y : GLFLoat; z : GLFLoat);
-    procedure uniform4f(location : TJSWebGLUniformLocation; x : GLFLoat; y : GLFLoat; z : GLfloat; w : GLFLoat);
-
-    procedure uniform1i(location : TJSWebGLUniformLocation; x : GLint);
-    procedure uniform2i(location : TJSWebGLUniformLocation; x : GLint; y : GLint);
-    procedure uniform3i(location : TJSWebGLUniformLocation; x : GLint; y : GLint; z : GLint);
-    procedure uniform4i(location : TJSWebGLUniformLocation; x : GLint; y : GLint; z : GLint; w : GLint);
-
-    procedure uniform1fv(location : TJSWebGLUniformLocation; v : TJSFloat32List );
-    procedure uniform2fv(location : TJSWebGLUniformLocation; v : TJSFloat32List );
-    procedure uniform3fv(location : TJSWebGLUniformLocation; v : TJSFloat32List );
-    procedure uniform4fv(location : TJSWebGLUniformLocation; v : TJSFloat32List );
-
-    procedure uniform1iv(location : TJSWebGLUniformLocation; v: TJSInt32List );
-    procedure uniform2iv(location : TJSWebGLUniformLocation; v: TJSInt32List );
-    procedure uniform3iv(location : TJSWebGLUniformLocation; v: TJSInt32List );
-    procedure uniform4iv(location : TJSWebGLUniformLocation; v: TJSInt32List );
-
-    procedure uniformMatrix2fv(location : TJSWebGLUniformLocation; transpose: GLboolean ; value : TJSFloat32List);
-    procedure uniformMatrix3fv(location : TJSWebGLUniformLocation; transpose: GLboolean ; value : TJSFloat32List);
-    procedure uniformMatrix4fv(location : TJSWebGLUniformLocation; transpose: GLboolean ; value : TJSFloat32List);
-
-    procedure useProgram(aprogram : TJSWebGLProgram);
-    procedure validateProgram(aprogram : TJSWebGLProgram);
-
-    procedure vertexAttrib1f(index: GLuint; x : GLfloat);
-    procedure vertexAttrib2f(index : GLuint; x : GLFLoat; y : GLfloat);
-    procedure vertexAttrib3f(index : GLuint; x : GLFLoat; y : GLfloat; z : GLFLoat);
-    procedure vertexAttrib4f(index : GLuint; x : GLFLoat; y : GLfloat; z : GLFLoat; w : GLFLoat);
-
-    procedure vertexAttrib1fv(index : GLuint; values : TJSFloat32List );
-    procedure vertexAttrib2fv(index : GLuint; values : TJSFloat32List );
-    procedure vertexAttrib3fv(index : GLuint; values : TJSFloat32List );
-    procedure vertexAttrib4fv(index : GLuint; values : TJSFloat32List );
-
-    procedure vertexAttribPointer(index : GLuint; size : GLInt; atype : GLEnum; normalized : GLboolean; stride: GLsizei; aoffset: GLintptr );
-    procedure viewport(x : GLint; y : GLint; width: GLsizei; height: GLsizei );
-    Property canvas : TJSHTMLCanvasElement read Fcanvas;
-    Property drawingBufferWidth : GLsizei read FdrawingBufferWidth;
-    Property drawingBufferHeight : GLsizei read FdrawingBufferHeight;
   end;
-
-  TJSWebGLRenderingContext = Class external name 'WebGLRenderingContext' (TJSWebGLRenderingContextBase);
-
-
-  TJSWebGLContextEvent = class external name 'WebGLContextEvent'  (TJSEvent)
+  
+  { --------------------------------------------------------------------
+    TJSWebGLRenderbuffer
+    --------------------------------------------------------------------}
+  
+  TJSWebGLRenderbuffer = class external name 'WebGLRenderbuffer'  (TJSWebGLObject)
   Private
-    FstatusMessage : String; external name 'statusMessage';
-  public
-    Property statusMessage : String read FstatusMessage;
+  Public
   end;
-
-  // EventInit is defined in the DOM4 specification.
-  TJSWebGLContext = class external name 'WebGLContext' (TJSEvent)
-    statusMessage : String;
+  
+  { --------------------------------------------------------------------
+    TJSWebGLShader
+    --------------------------------------------------------------------}
+  
+  TJSWebGLShader = class external name 'WebGLShader'  (TJSWebGLObject)
+  Private
+  Public
+  end;
+  
+  { --------------------------------------------------------------------
+    TJSWebGLTexture
+    --------------------------------------------------------------------}
+  
+  TJSWebGLTexture = class external name 'WebGLTexture'  (TJSWebGLObject)
+  Private
+  Public
+  end;
+  
+  { --------------------------------------------------------------------
+    TJSWebGLUniformLocation
+    --------------------------------------------------------------------}
+  
+  TJSWebGLUniformLocation = class external name 'WebGLUniformLocation' 
+  Private
+  Public
+  end;
+  
+  { --------------------------------------------------------------------
+    TJSWebGLActiveInfo
+    --------------------------------------------------------------------}
+  
+  TJSWebGLActiveInfo = class external name 'WebGLActiveInfo' 
+  Private
+    Fsize : GLint; external name 'size'; 
+    Ftype_ : GLenum; external name 'type'; 
+    Fname : String; external name 'name'; 
+  Public
+    Property size : GLint Read Fsize; 
+    Property type_ : GLenum Read Ftype_; 
+    Property name : String Read Fname; 
+  end;
+  
+  { --------------------------------------------------------------------
+    TJSWebGLShaderPrecisionFormat
+    --------------------------------------------------------------------}
+  
+  TJSWebGLShaderPrecisionFormat = class external name 'WebGLShaderPrecisionFormat' 
+  Private
+    FrangeMin : GLint; external name 'rangeMin'; 
+    FrangeMax : GLint; external name 'rangeMax'; 
+    Fprecision : GLint; external name 'precision'; 
+  Public
+    Property rangeMin : GLint Read FrangeMin; 
+    Property rangeMax : GLint Read FrangeMax; 
+    Property precision : GLint Read Fprecision; 
+  end;
+  
+  { --------------------------------------------------------------------
+    TJSWebGLRenderingContextBase
+    --------------------------------------------------------------------}
+  
+  TStringDynArray = Array of String;
+  TTJSWebGLShaderDynArray = Array of TJSWebGLShader;
+  TGLfloatDynArray = Array of GLfloat;
+  TGLintDynArray = Array of GLint;
+  
+  TJSWebGLRenderingContextBase = class external name 'WebGLRenderingContextBase' 
+  Private
+    Fcanvas : TJSHTMLCanvasElement; external name 'canvas'; 
+    FdrawingBufferWidth : GLsizei; external name 'drawingBufferWidth'; 
+    FdrawingBufferHeight : GLsizei; external name 'drawingBufferHeight'; 
+  Public
+    Const
+      DEPTH_BUFFER_BIT = $00000100;
+      STENCIL_BUFFER_BIT = $00000400;
+      COLOR_BUFFER_BIT = $00004000;
+      POINTS = $0000;
+      LINES = $0001;
+      LINE_LOOP = $0002;
+      LINE_STRIP = $0003;
+      TRIANGLES = $0004;
+      TRIANGLE_STRIP = $0005;
+      TRIANGLE_FAN = $0006;
+      ZERO = 0;
+      ONE = 1;
+      SRC_COLOR = $0300;
+      ONE_MINUS_SRC_COLOR = $0301;
+      SRC_ALPHA = $0302;
+      ONE_MINUS_SRC_ALPHA = $0303;
+      DST_ALPHA = $0304;
+      ONE_MINUS_DST_ALPHA = $0305;
+      DST_COLOR = $0306;
+      ONE_MINUS_DST_COLOR = $0307;
+      SRC_ALPHA_SATURATE = $0308;
+      FUNC_ADD = $8006;
+      BLEND_EQUATION = $8009;
+      BLEND_EQUATION_RGB = $8009;
+      BLEND_EQUATION_ALPHA = $883D;
+      FUNC_SUBTRACT = $800A;
+      FUNC_REVERSE_SUBTRACT = $800B;
+      BLEND_DST_RGB = $80C8;
+      BLEND_SRC_RGB = $80C9;
+      BLEND_DST_ALPHA = $80CA;
+      BLEND_SRC_ALPHA = $80CB;
+      CONSTANT_COLOR = $8001;
+      ONE_MINUS_CONSTANT_COLOR = $8002;
+      CONSTANT_ALPHA = $8003;
+      ONE_MINUS_CONSTANT_ALPHA = $8004;
+      BLEND_COLOR = $8005;
+      ARRAY_BUFFER = $8892;
+      ELEMENT_ARRAY_BUFFER = $8893;
+      ARRAY_BUFFER_BINDING = $8894;
+      ELEMENT_ARRAY_BUFFER_BINDING = $8895;
+      STREAM_DRAW = $88E0;
+      STATIC_DRAW = $88E4;
+      DYNAMIC_DRAW = $88E8;
+      BUFFER_SIZE = $8764;
+      BUFFER_USAGE = $8765;
+      CURRENT_VERTEX_ATTRIB = $8626;
+      FRONT = $0404;
+      BACK = $0405;
+      FRONT_AND_BACK = $0408;
+      CULL_FACE = $0B44;
+      BLEND = $0BE2;
+      DITHER = $0BD0;
+      STENCIL_TEST = $0B90;
+      DEPTH_TEST = $0B71;
+      SCISSOR_TEST = $0C11;
+      POLYGON_OFFSET_FILL = $8037;
+      SAMPLE_ALPHA_TO_COVERAGE = $809E;
+      SAMPLE_COVERAGE = $80A0;
+      NO_ERROR = 0;
+      INVALID_ENUM = $0500;
+      INVALID_VALUE = $0501;
+      INVALID_OPERATION = $0502;
+      OUT_OF_MEMORY = $0505;
+      CW = $0900;
+      CCW = $0901;
+      LINE_WIDTH = $0B21;
+      ALIASED_POINT_SIZE_RANGE = $846D;
+      ALIASED_LINE_WIDTH_RANGE = $846E;
+      CULL_FACE_MODE = $0B45;
+      FRONT_FACE = $0B46;
+      DEPTH_RANGE = $0B70;
+      DEPTH_WRITEMASK = $0B72;
+      DEPTH_CLEAR_VALUE = $0B73;
+      DEPTH_FUNC = $0B74;
+      STENCIL_CLEAR_VALUE = $0B91;
+      STENCIL_FUNC = $0B92;
+      STENCIL_FAIL = $0B94;
+      STENCIL_PASS_DEPTH_FAIL = $0B95;
+      STENCIL_PASS_DEPTH_PASS = $0B96;
+      STENCIL_REF = $0B97;
+      STENCIL_VALUE_MASK = $0B93;
+      STENCIL_WRITEMASK = $0B98;
+      STENCIL_BACK_FUNC = $8800;
+      STENCIL_BACK_FAIL = $8801;
+      STENCIL_BACK_PASS_DEPTH_FAIL = $8802;
+      STENCIL_BACK_PASS_DEPTH_PASS = $8803;
+      STENCIL_BACK_REF = $8CA3;
+      STENCIL_BACK_VALUE_MASK = $8CA4;
+      STENCIL_BACK_WRITEMASK = $8CA5;
+      VIEWPORT_ = $0BA2;
+      SCISSOR_BOX = $0C10;
+      COLOR_CLEAR_VALUE = $0C22;
+      COLOR_WRITEMASK = $0C23;
+      UNPACK_ALIGNMENT = $0CF5;
+      PACK_ALIGNMENT = $0D05;
+      MAX_TEXTURE_SIZE = $0D33;
+      MAX_VIEWPORT_DIMS = $0D3A;
+      SUBPIXEL_BITS = $0D50;
+      RED_BITS = $0D52;
+      GREEN_BITS = $0D53;
+      BLUE_BITS = $0D54;
+      ALPHA_BITS = $0D55;
+      DEPTH_BITS = $0D56;
+      STENCIL_BITS = $0D57;
+      POLYGON_OFFSET_UNITS = $2A00;
+      POLYGON_OFFSET_FACTOR = $8038;
+      TEXTURE_BINDING_2D = $8069;
+      SAMPLE_BUFFERS = $80A8;
+      SAMPLES = $80A9;
+      SAMPLE_COVERAGE_VALUE = $80AA;
+      SAMPLE_COVERAGE_INVERT = $80AB;
+      COMPRESSED_TEXTURE_FORMATS = $86A3;
+      DONT_CARE = $1100;
+      FASTEST = $1101;
+      NICEST = $1102;
+      GENERATE_MIPMAP_HINT = $8192;
+      BYTE = $1400;
+      UNSIGNED_BYTE = $1401;
+      SHORT = $1402;
+      UNSIGNED_SHORT = $1403;
+      INT = $1404;
+      UNSIGNED_INT = $1405;
+      FLOAT = $1406;
+      DEPTH_COMPONENT = $1902;
+      ALPHA = $1906;
+      RGB = $1907;
+      RGBA = $1908;
+      LUMINANCE = $1909;
+      LUMINANCE_ALPHA = $190A;
+      UNSIGNED_SHORT_4_4_4_4 = $8033;
+      UNSIGNED_SHORT_5_5_5_1 = $8034;
+      UNSIGNED_SHORT_5_6_5 = $8363;
+      FRAGMENT_SHADER = $8B30;
+      VERTEX_SHADER = $8B31;
+      MAX_VERTEX_ATTRIBS = $8869;
+      MAX_VERTEX_UNIFORM_VECTORS = $8DFB;
+      MAX_VARYING_VECTORS = $8DFC;
+      MAX_COMBINED_TEXTURE_IMAGE_UNITS = $8B4D;
+      MAX_VERTEX_TEXTURE_IMAGE_UNITS = $8B4C;
+      MAX_TEXTURE_IMAGE_UNITS = $8872;
+      MAX_FRAGMENT_UNIFORM_VECTORS = $8DFD;
+      SHADER_TYPE = $8B4F;
+      DELETE_STATUS = $8B80;
+      LINK_STATUS = $8B82;
+      VALIDATE_STATUS = $8B83;
+      ATTACHED_SHADERS = $8B85;
+      ACTIVE_UNIFORMS = $8B86;
+      ACTIVE_ATTRIBUTES = $8B89;
+      SHADING_LANGUAGE_VERSION = $8B8C;
+      CURRENT_PROGRAM = $8B8D;
+      NEVER = $0200;
+      LESS = $0201;
+      EQUAL = $0202;
+      LEQUAL = $0203;
+      GREATER = $0204;
+      NOTEQUAL = $0205;
+      GEQUAL = $0206;
+      ALWAYS = $0207;
+      KEEP = $1E00;
+      REPLACE = $1E01;
+      INCR = $1E02;
+      DECR = $1E03;
+      INVERT = $150A;
+      INCR_WRAP = $8507;
+      DECR_WRAP = $8508;
+      VENDOR = $1F00;
+      RENDERER = $1F01;
+      VERSION = $1F02;
+      NEAREST = $2600;
+      LINEAR = $2601;
+      NEAREST_MIPMAP_NEAREST = $2700;
+      LINEAR_MIPMAP_NEAREST = $2701;
+      NEAREST_MIPMAP_LINEAR = $2702;
+      LINEAR_MIPMAP_LINEAR = $2703;
+      TEXTURE_MAG_FILTER = $2800;
+      TEXTURE_MIN_FILTER = $2801;
+      TEXTURE_WRAP_S = $2802;
+      TEXTURE_WRAP_T = $2803;
+      TEXTURE_2D = $0DE1;
+      TEXTURE = $1702;
+      TEXTURE_CUBE_MAP = $8513;
+      TEXTURE_BINDING_CUBE_MAP = $8514;
+      TEXTURE_CUBE_MAP_POSITIVE_X = $8515;
+      TEXTURE_CUBE_MAP_NEGATIVE_X = $8516;
+      TEXTURE_CUBE_MAP_POSITIVE_Y = $8517;
+      TEXTURE_CUBE_MAP_NEGATIVE_Y = $8518;
+      TEXTURE_CUBE_MAP_POSITIVE_Z = $8519;
+      TEXTURE_CUBE_MAP_NEGATIVE_Z = $851A;
+      MAX_CUBE_MAP_TEXTURE_SIZE = $851C;
+      TEXTURE0 = $84C0;
+      TEXTURE1 = $84C1;
+      TEXTURE2 = $84C2;
+      TEXTURE3 = $84C3;
+      TEXTURE4 = $84C4;
+      TEXTURE5 = $84C5;
+      TEXTURE6 = $84C6;
+      TEXTURE7 = $84C7;
+      TEXTURE8 = $84C8;
+      TEXTURE9 = $84C9;
+      TEXTURE10 = $84CA;
+      TEXTURE11 = $84CB;
+      TEXTURE12 = $84CC;
+      TEXTURE13 = $84CD;
+      TEXTURE14 = $84CE;
+      TEXTURE15 = $84CF;
+      TEXTURE16 = $84D0;
+      TEXTURE17 = $84D1;
+      TEXTURE18 = $84D2;
+      TEXTURE19 = $84D3;
+      TEXTURE20 = $84D4;
+      TEXTURE21 = $84D5;
+      TEXTURE22 = $84D6;
+      TEXTURE23 = $84D7;
+      TEXTURE24 = $84D8;
+      TEXTURE25 = $84D9;
+      TEXTURE26 = $84DA;
+      TEXTURE27 = $84DB;
+      TEXTURE28 = $84DC;
+      TEXTURE29 = $84DD;
+      TEXTURE30 = $84DE;
+      TEXTURE31 = $84DF;
+      ACTIVE_TEXTURE = $84E0;
+      REPEAT_ = $2901;
+      CLAMP_TO_EDGE = $812F;
+      MIRRORED_REPEAT = $8370;
+      FLOAT_VEC2 = $8B50;
+      FLOAT_VEC3 = $8B51;
+      FLOAT_VEC4 = $8B52;
+      INT_VEC2 = $8B53;
+      INT_VEC3 = $8B54;
+      INT_VEC4 = $8B55;
+      BOOL = $8B56;
+      BOOL_VEC2 = $8B57;
+      BOOL_VEC3 = $8B58;
+      BOOL_VEC4 = $8B59;
+      FLOAT_MAT2 = $8B5A;
+      FLOAT_MAT3 = $8B5B;
+      FLOAT_MAT4 = $8B5C;
+      SAMPLER_2D = $8B5E;
+      SAMPLER_CUBE = $8B60;
+      VERTEX_ATTRIB_ARRAY_ENABLED = $8622;
+      VERTEX_ATTRIB_ARRAY_SIZE = $8623;
+      VERTEX_ATTRIB_ARRAY_STRIDE = $8624;
+      VERTEX_ATTRIB_ARRAY_TYPE = $8625;
+      VERTEX_ATTRIB_ARRAY_NORMALIZED = $886A;
+      VERTEX_ATTRIB_ARRAY_POINTER = $8645;
+      VERTEX_ATTRIB_ARRAY_BUFFER_BINDING = $889F;
+      IMPLEMENTATION_COLOR_READ_TYPE = $8B9A;
+      IMPLEMENTATION_COLOR_READ_FORMAT = $8B9B;
+      COMPILE_STATUS = $8B81;
+      LOW_FLOAT = $8DF0;
+      MEDIUM_FLOAT = $8DF1;
+      HIGH_FLOAT = $8DF2;
+      LOW_INT = $8DF3;
+      MEDIUM_INT = $8DF4;
+      HIGH_INT = $8DF5;
+      FRAMEBUFFER = $8D40;
+      RENDERBUFFER = $8D41;
+      RGBA4 = $8056;
+      RGB5_A1 = $8057;
+      RGB565 = $8D62;
+      DEPTH_COMPONENT16 = $81A5;
+      STENCIL_INDEX8 = $8D48;
+      DEPTH_STENCIL = $84F9;
+      RENDERBUFFER_WIDTH = $8D42;
+      RENDERBUFFER_HEIGHT = $8D43;
+      RENDERBUFFER_INTERNAL_FORMAT = $8D44;
+      RENDERBUFFER_RED_SIZE = $8D50;
+      RENDERBUFFER_GREEN_SIZE = $8D51;
+      RENDERBUFFER_BLUE_SIZE = $8D52;
+      RENDERBUFFER_ALPHA_SIZE = $8D53;
+      RENDERBUFFER_DEPTH_SIZE = $8D54;
+      RENDERBUFFER_STENCIL_SIZE = $8D55;
+      FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE = $8CD0;
+      FRAMEBUFFER_ATTACHMENT_OBJECT_NAME = $8CD1;
+      FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL = $8CD2;
+      FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE = $8CD3;
+      COLOR_ATTACHMENT0 = $8CE0;
+      DEPTH_ATTACHMENT = $8D00;
+      STENCIL_ATTACHMENT = $8D20;
+      DEPTH_STENCIL_ATTACHMENT = $821A;
+      NONE = 0;
+      FRAMEBUFFER_COMPLETE = $8CD5;
+      FRAMEBUFFER_INCOMPLETE_ATTACHMENT = $8CD6;
+      FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT = $8CD7;
+      FRAMEBUFFER_INCOMPLETE_DIMENSIONS = $8CD9;
+      FRAMEBUFFER_UNSUPPORTED = $8CDD;
+      FRAMEBUFFER_BINDING = $8CA6;
+      RENDERBUFFER_BINDING = $8CA7;
+      MAX_RENDERBUFFER_SIZE = $84E8;
+      INVALID_FRAMEBUFFER_OPERATION = $0506;
+      UNPACK_FLIP_Y_WEBGL = $9240;
+      UNPACK_PREMULTIPLY_ALPHA_WEBGL = $9241;
+      CONTEXT_LOST_WEBGL = $9242;
+      UNPACK_COLORSPACE_CONVERSION_WEBGL = $9243;
+      BROWSER_DEFAULT_WEBGL = $9244;
+  Public
+    function getContextAttributes: TJSWebGLContextAttributes;
+    function isContextLost: boolean;
+    function getSupportedExtensions: TStringDynArray;
+    function getExtension(name : String): TJSObject;
+    Procedure activeTexture(texture : GLenum);
+    Procedure attachShader(program_ : TJSWebGLProgram; shader : TJSWebGLShader);
+    Procedure bindAttribLocation(program_ : TJSWebGLProgram; index : GLuint; name : String);
+    Procedure bindBuffer(target : GLenum; buffer : TJSWebGLBuffer);
+    Procedure bindFramebuffer(target : GLenum; framebuffer : TJSWebGLFramebuffer);
+    Procedure bindRenderbuffer(target : GLenum; renderbuffer : TJSWebGLRenderbuffer);
+    Procedure bindTexture(target : GLenum; texture : TJSWebGLTexture);
+    Procedure blendColor(red : GLclampf; green : GLclampf; blue : GLclampf; alpha : GLclampf);
+    Procedure blendEquation(mode : GLenum);
+    Procedure blendEquationSeparate(modeRGB : GLenum; modeAlpha : GLenum);
+    Procedure blendFunc(sfactor : GLenum; dfactor : GLenum);
+    Procedure blendFuncSeparate(srcRGB : GLenum; dstRGB : GLenum; srcAlpha : GLenum; dstAlpha : GLenum);
+    Procedure bufferData(target : GLenum; size : GLsizeiptr; usage : GLenum);
+    Procedure bufferData(target : GLenum; data : TJSBufferSource; usage : GLenum);
+    Procedure bufferSubData(target : GLenum; offset : GLintptr; data : TJSBufferSource);
+    function checkFramebufferStatus(target : GLenum): GLenum;
+    Procedure clear(mask : GLbitfield);
+    Procedure clearColor(red : GLclampf; green : GLclampf; blue : GLclampf; alpha : GLclampf);
+    Procedure clearDepth(depth : GLclampf);
+    Procedure clearStencil(s : GLint);
+    Procedure colorMask(red : GLboolean; green : GLboolean; blue : GLboolean; alpha : GLboolean);
+    Procedure compileShader(shader : TJSWebGLShader);
+    Procedure compressedTexImage2D(target : GLenum; level : GLint; internalformat : GLenum; width : GLsizei; height : GLsizei; border : GLint; data : TJSTypedArray);
+    Procedure compressedTexSubImage2D(target : GLenum; level : GLint; xoffset : GLint; yoffset : GLint; width : GLsizei; height : GLsizei; format : GLenum; data : TJSTypedArray);
+    Procedure copyTexImage2D(target : GLenum; level : GLint; internalformat : GLenum; x : GLint; y : GLint; width : GLsizei; height : GLsizei; border : GLint);
+    Procedure copyTexSubImage2D(target : GLenum; level : GLint; xoffset : GLint; yoffset : GLint; x : GLint; y : GLint; width : GLsizei; height : GLsizei);
+    function createBuffer: TJSWebGLBuffer;
+    function createFramebuffer: TJSWebGLFramebuffer;
+    function createProgram: TJSWebGLProgram;
+    function createRenderbuffer: TJSWebGLRenderbuffer;
+    function createShader(type_ : GLenum): TJSWebGLShader;
+    function createTexture: TJSWebGLTexture;
+    Procedure cullFace(mode : GLenum);
+    Procedure deleteBuffer(buffer : TJSWebGLBuffer);
+    Procedure deleteFramebuffer(framebuffer : TJSWebGLFramebuffer);
+    Procedure deleteProgram(program_ : TJSWebGLProgram);
+    Procedure deleteRenderbuffer(renderbuffer : TJSWebGLRenderbuffer);
+    Procedure deleteShader(shader : TJSWebGLShader);
+    Procedure deleteTexture(texture : TJSWebGLTexture);
+    Procedure depthFunc(func : GLenum);
+    Procedure depthMask(flag : GLboolean);
+    Procedure depthRange(zNear : GLclampf; zFar : GLclampf);
+    Procedure detachShader(program_ : TJSWebGLProgram; shader : TJSWebGLShader);
+    Procedure disable(cap : GLenum);
+    Procedure disableVertexAttribArray(index : GLuint);
+    Procedure drawArrays(mode : GLenum; first : GLint; count : GLsizei);
+    Procedure drawElements(mode : GLenum; count : GLsizei; type_ : GLenum; offset : GLintptr);
+    Procedure enable(cap : GLenum);
+    Procedure enableVertexAttribArray(index : GLuint);
+    Procedure finish;
+    Procedure flush;
+    Procedure framebufferRenderbuffer(target : GLenum; attachment : GLenum; renderbuffertarget : GLenum; renderbuffer : TJSWebGLRenderbuffer);
+    Procedure framebufferTexture2D(target : GLenum; attachment : GLenum; textarget : GLenum; texture : TJSWebGLTexture; level : GLint);
+    Procedure frontFace(mode : GLenum);
+    Procedure generateMipmap(target : GLenum);
+    function getActiveAttrib(program_ : TJSWebGLProgram; index : GLuint): TJSWebGLActiveInfo;
+    function getActiveUniform(program_ : TJSWebGLProgram; index : GLuint): TJSWebGLActiveInfo;
+    function getAttachedShaders(program_ : TJSWebGLProgram): TTJSWebGLShaderDynArray;
+    function getAttribLocation(program_ : TJSWebGLProgram; name : String): GLint;
+    function getBufferParameter(target : GLenum; pname : GLenum): JSValue;
+    function getParameter(pname : GLenum): JSValue;
+    function getError: GLenum;
+    function getFramebufferAttachmentParameter(target : GLenum; attachment : GLenum; pname : GLenum): JSValue;
+    function getProgramParameter(program_ : TJSWebGLProgram; pname : GLenum): JSValue;
+    function getProgramInfoLog(program_ : TJSWebGLProgram): String;
+    function getRenderbufferParameter(target : GLenum; pname : GLenum): JSValue;
+    function getShaderParameter(shader : TJSWebGLShader; pname : GLenum): JSValue;
+    function getShaderPrecisionFormat(shadertype : GLenum; precisiontype : GLenum): TJSWebGLShaderPrecisionFormat;
+    function getShaderInfoLog(shader : TJSWebGLShader): String;
+    function getShaderSource(shader : TJSWebGLShader): String;
+    function getTexParameter(target : GLenum; pname : GLenum): JSValue;
+    function getUniform(program_ : TJSWebGLProgram; location : TJSWebGLUniformLocation): JSValue;
+    function getUniformLocation(program_ : TJSWebGLProgram; name : String): TJSWebGLUniformLocation;
+    function getVertexAttrib(index : GLuint; pname : GLenum): JSValue;
+    function getVertexAttribOffset(index : GLuint; pname : GLenum): GLintptr;
+    Procedure hint(target : GLenum; mode : GLenum);
+    function isBuffer(buffer : TJSWebGLBuffer): GLboolean;
+    function isEnabled(cap : GLenum): GLboolean;
+    function isFramebuffer(framebuffer : TJSWebGLFramebuffer): GLboolean;
+    function isProgram(program_ : TJSWebGLProgram): GLboolean;
+    function isRenderbuffer(renderbuffer : TJSWebGLRenderbuffer): GLboolean;
+    function isShader(shader : TJSWebGLShader): GLboolean;
+    function isTexture(texture : TJSWebGLTexture): GLboolean;
+    Procedure lineWidth(width : GLfloat);
+    Procedure linkProgram(program_ : TJSWebGLProgram);
+    Procedure pixelStorei(pname : GLenum; param : GLint);
+    Procedure polygonOffset(factor : GLfloat; units : GLfloat);
+    Procedure readPixels(x : GLint; y : GLint; width : GLsizei; height : GLsizei; format : GLenum; type_ : GLenum; pixels : TJSTypedArray);
+    Procedure renderbufferStorage(target : GLenum; internalformat : GLenum; width : GLsizei; height : GLsizei);
+    Procedure sampleCoverage(value : GLclampf; invert : GLboolean);
+    Procedure scissor(x : GLint; y : GLint; width : GLsizei; height : GLsizei);
+    Procedure shaderSource(shader : TJSWebGLShader; source : String);
+    Procedure stencilFunc(func : GLenum; ref : GLint; mask : GLuint);
+    Procedure stencilFuncSeparate(face : GLenum; func : GLenum; ref : GLint; mask : GLuint);
+    Procedure stencilMask(mask : GLuint);
+    Procedure stencilMaskSeparate(face : GLenum; mask : GLuint);
+    Procedure stencilOp(fail : GLenum; zfail : GLenum; zpass : GLenum);
+    Procedure stencilOpSeparate(face : GLenum; fail : GLenum; zfail : GLenum; zpass : GLenum);
+    Procedure texImage2D(target : GLenum; level : GLint; internalformat : GLint; width : GLsizei; height : GLsizei; border : GLint; format : GLenum; type_ : GLenum; pixels : TJSTypedArray);
+    Procedure texImage2D(target : GLenum; level : GLint; internalformat : GLint; format : GLenum; type_ : GLenum; source : TexImageSource);
+    Procedure texParameterf(target : GLenum; pname : GLenum; param : GLfloat);
+    Procedure texParameteri(target : GLenum; pname : GLenum; param : GLint);
+    Procedure texSubImage2D(target : GLenum; level : GLint; xoffset : GLint; yoffset : GLint; width : GLsizei; height : GLsizei; format : GLenum; type_ : GLenum; pixels : TJSTypedArray);
+    Procedure texSubImage2D(target : GLenum; level : GLint; xoffset : GLint; yoffset : GLint; format : GLenum; type_ : GLenum; source : TexImageSource);
+    Procedure uniform1f(location : TJSWebGLUniformLocation; x : GLfloat);
+    Procedure uniform2f(location : TJSWebGLUniformLocation; x : GLfloat; y : GLfloat);
+    Procedure uniform3f(location : TJSWebGLUniformLocation; x : GLfloat; y : GLfloat; z : GLfloat);
+    Procedure uniform4f(location : TJSWebGLUniformLocation; x : GLfloat; y : GLfloat; z : GLfloat; w : GLfloat);
+    Procedure uniform1i(location : TJSWebGLUniformLocation; x : GLint);
+    Procedure uniform2i(location : TJSWebGLUniformLocation; x : GLint; y : GLint);
+    Procedure uniform3i(location : TJSWebGLUniformLocation; x : GLint; y : GLint; z : GLint);
+    Procedure uniform4i(location : TJSWebGLUniformLocation; x : GLint; y : GLint; z : GLint; w : GLint);
+    Procedure uniform1fv(location : TJSWebGLUniformLocation; v : Float32List);
+    Procedure uniform2fv(location : TJSWebGLUniformLocation; v : Float32List);
+    Procedure uniform3fv(location : TJSWebGLUniformLocation; v : Float32List);
+    Procedure uniform4fv(location : TJSWebGLUniformLocation; v : Float32List);
+    Procedure uniform1iv(location : TJSWebGLUniformLocation; v : Int32List);
+    Procedure uniform2iv(location : TJSWebGLUniformLocation; v : Int32List);
+    Procedure uniform3iv(location : TJSWebGLUniformLocation; v : Int32List);
+    Procedure uniform4iv(location : TJSWebGLUniformLocation; v : Int32List);
+    Procedure uniformMatrix2fv(location : TJSWebGLUniformLocation; transpose : GLboolean; value : Float32List);
+    Procedure uniformMatrix3fv(location : TJSWebGLUniformLocation; transpose : GLboolean; value : Float32List);
+    Procedure uniformMatrix4fv(location : TJSWebGLUniformLocation; transpose : GLboolean; value : Float32List);
+    Procedure useProgram(program_ : TJSWebGLProgram);
+    Procedure validateProgram(program_ : TJSWebGLProgram);
+    Procedure vertexAttrib1f(index : GLuint; x : GLfloat);
+    Procedure vertexAttrib2f(index : GLuint; x : GLfloat; y : GLfloat);
+    Procedure vertexAttrib3f(index : GLuint; x : GLfloat; y : GLfloat; z : GLfloat);
+    Procedure vertexAttrib4f(index : GLuint; x : GLfloat; y : GLfloat; z : GLfloat; w : GLfloat);
+    Procedure vertexAttrib1fv(index : GLuint; values : Float32List);
+    Procedure vertexAttrib2fv(index : GLuint; values : Float32List);
+    Procedure vertexAttrib3fv(index : GLuint; values : Float32List);
+    Procedure vertexAttrib4fv(index : GLuint; values : Float32List);
+    Procedure vertexAttribPointer(index : GLuint; size : GLint; type_ : GLenum; normalized : GLboolean; stride : GLsizei; offset : GLintptr);
+    Procedure viewport(x : GLint; y : GLint; width : GLsizei; height : GLsizei);
+    Property canvas : TJSHTMLCanvasElement Read Fcanvas; 
+    Property drawingBufferWidth : GLsizei Read FdrawingBufferWidth; 
+    Property drawingBufferHeight : GLsizei Read FdrawingBufferHeight; 
+  end;
+  
+  { --------------------------------------------------------------------
+    TJSWebGLRenderingContext
+    --------------------------------------------------------------------}
+  
+  TJSWebGLRenderingContext = class external name 'WebGLRenderingContext'  (TJSWebGLRenderingContextBase)
+  Private
+  Public
+  end;
+  
+  { --------------------------------------------------------------------
+    TJSWebGLContextEvent
+    --------------------------------------------------------------------}
+  
+  TJSWebGLContextEvent = class external name 'WebGLContextEvent'  (TJSEvent)
+  Private
+    FstatusMessage : String; external name 'statusMessage'; 
+  Public
+    Property statusMessage : String Read FstatusMessage; 
   end;
 
 implementation
 
+
 end.