unit CompiledVertexArray;

interface

uses Windows, SysUtils, Math3D, GL, GLu, GLext, WGLext, GLtools, VertexArray;

type
  TCompiledVertexArray = class(TVertexArray)
  protected
    FLocked             : boolean;
  public
    constructor Create; override;
    destructor Destroy; override;
    procedure Lock; override;
    procedure Unlock; override;
  end;

implementation

constructor TCompiledVertexArray.Create;
begin
  if not Load_GL_EXT_compiled_vertex_array then
    raise Exception.Create('GL_EXT_compiled_vertex_array required!');
  FLocked := false;

  inherited Create;
end;

destructor TCompiledVertexArray.Destroy;
begin
  if FLocked then Unlock;

  inherited Destroy;
end;

procedure TCompiledVertexArray.Lock;
begin
  glLockArraysEXT(0, VertexSize div 16);
  FLocked := true;
end;

procedure TCompiledVertexArray.Unlock;
begin
  glUnlockArraysEXT;
  FLocked := false;
end;

end.
