anchor.diff:  
   procedure TLocalState.StartDrawingSprites;
   begin
  -  //glBindVertexArray(0);
  -  //glEnableVertexAttribArray(COORDS_ATTRIB_LOCATION);
  -  //glEnableVertexAttribArray(UV_ATTRIB_LOCATION);
  +  glBindVertexArray(SpriteVAO);
  +  glEnableVertexAttribArray(COORDS_ATTRIB_LOCATION);
  +  glEnableVertexAttribArray(UV_ATTRIB_LOCATION);
   end;
   
   procedure TLocalState.RenderSprite(ASprite: TGLSprite; dim: integer; mir: UInt8);
  
positive.code:   glBindTexture(GL_TEXTURE_1D,ASprite.PaletteID);
  
    glBindBuffer(GL_ARRAY_BUFFER,GlobalContextState.CoordsBuffer);
    glBufferSubData(GL_ARRAY_BUFFER,0,  sizeof(vertex_data),@vertex_data);
    glBindBuffer(GL_ARRAY_BUFFER,0);
  
    Assert(glIsVertexArray(SpriteVAO[mir]) = GL_TRUE, 'invalid SpriteVAO');
  
    glBindVertexArray(SpriteVAO[mir]);
  
    glUniformMatrix4fv(GlobalContextState.DefaultTranslateMatrixUniform,1,GL_TRUE,@FTranslateMaxrix.data);
  
    glEnableVertexAttribArray(COORDS_ATTRIB_LOCATION);
    glEnableVertexAttribArray(UV_ATTRIB_LOCATION);
    glDrawArrays(GL_TRIANGLES,0,6);  //todo: use triangle strip
    glDisableVertexAttribArray(UV_ATTRIB_LOCATION);
    glDisableVertexAttribArray(COORDS_ATTRIB_LOCATION);
  
  
  
    glBindVertexArray(0);
  
   // CheckGLErrors('render sprite mir='+IntToStr(mir)+ ' xy='+IntToStr(ASprite.X)+' '+ IntToStr(ASprite.Y));
  
  
negative.code: 
  procedure TGlobalState.SetupUVBuffer;
  var
    uv_data: packed array of GLfloat;
    u: GLfloat;
    v: GLfloat;
    mir: Integer;
  
    ofc: integer;
  
    function next_ofc(): integer;
    begin
      Result := ofc;
      inc(ofc);
    end;
  begin
    SetLength(uv_data, UV_BUFFER_SIZE);
  
    u:=1;
    v:=1;
  
    for mir := 0 to 3 do
    begin
      ofc := mir * 12;
  
      case mir of
        0:begin
            uv_data[next_ofc()] := 0;   uv_data[next_ofc()] := 0;
            uv_data[next_ofc()] := u;   uv_data[next_ofc()] := 0;
            uv_data[next_ofc()] := u;   uv_data[next_ofc()] := v;
  
            uv_data[next_ofc()] := u;   uv_data[next_ofc()] := v;
            uv_data[next_ofc()] := 0;   uv_data[next_ofc()] := v;
            uv_data[next_ofc()] := 0;   uv_data[next_ofc()] := 0;
        end;
        1: begin
              uv_data[next_ofc()] := u;   uv_data[next_ofc()] := 0;
              uv_data[next_ofc()] := 0;   uv_data[next_ofc()] := 0;
              uv_data[next_ofc()] := 0;   uv_data[next_ofc()] := v;
  
              uv_data[next_ofc()] := 0;   uv_data[next_ofc()] := v;
              uv_data[next_ofc()] := u;   uv_data[next_ofc()] := v;
              uv_data[next_ofc()] := u;   uv_data[next_ofc()] := 0;
          end;
        2: begin
              uv_data[next_ofc()] := 0;   uv_data[next_ofc()] := v;
              uv_data[next_ofc()] := u;   uv_data[next_ofc()] := v;
              uv_data[next_ofc()] := u;   uv_data[next_ofc()] := 0;
  
              uv_data[next_ofc()] := u;   uv_data[next_ofc()] := 0;
              uv_data[next_ofc()] := 0;   uv_data[next_ofc()] := 0;
              uv_data[next_ofc()] := 0;   uv_data[next_ofc()] := v;
          end;
        3:begin
            uv_data[next_ofc()] := u;   uv_data[next_ofc()] := v;
            uv_data[next_ofc()] := 0;   uv_data[next_ofc()] := v;
            uv_data[next_ofc()] := 0;   uv_data[next_ofc()] := 0;
  
            uv_data[next_ofc()] := 0;   uv_data[next_ofc()] := 0;
            uv_data[next_ofc()] := u;   uv_data[next_ofc()] := 0;
            uv_data[next_ofc()] := u;   uv_data[next_ofc()] := v;
          end;
       end;
  
    end;
  
    glGenBuffers(1, @MirroredUVBuffer);
    glBindBuffer(GL_ARRAY_BUFFER,MirroredUVBuffer);
    glBufferData(GL_ARRAY_BUFFER,UV_BUFFER_SIZE * SizeOf(GLfloat),@uv_data[0],GL_STATIC_DRAW);
  end;
  
  procedure TGlobalState.SetupCoordsBuffer;
  begin
    glGenBuffers(1,@CoordsBuffer);
    glBindBuffer(GL_ARRAY_BUFFER,GlobalContextState.CoordsBuffer);
    glBufferData(GL_ARRAY_BUFFER, VERTEX_BUFFER_SIZE * SizeOf(GLfloat), @EmptyBufferData[0], GL_STREAM_DRAW);
  end;
  
  constructor TGlobalState.Create;
  begin
    SetLength(EmptyBufferData, VERTEX_BUFFER_SIZE); //do not care even if it will contain junk
  end;
  
  destructor TGlobalState.Destroy;
  