text:
.class final Lcom/htc/protobuf/AbstractMessageLite$Builder$LimitedInputStream;
.super Ljava/io/FilterInputStream;
.source "AbstractMessageLite.java"

# annotations
.annotation system Ldalvik/annotation/EnclosingClass;
    value = Lcom/htc/protobuf/AbstractMessageLite$Builder;
.end annotation

.annotation system Ldalvik/annotation/InnerClass;
    accessFlags = 0x18
    name = "LimitedInputStream"
.end annotation

# instance fields
.field private limit:I

# direct methods
.method constructor <init>(Ljava/io/InputStream;I)V
    .locals 0
    .parameter "in"
    .parameter "limit"

    .prologue
    .line 262
    invoke-direct {p0, p1}, Ljava/io/FilterInputStream;-><init>(Ljava/io/InputStream;)V

    .line 263
    iput p2, p0, Lcom/htc/protobuf/AbstractMessageLite$Builder$LimitedInputStream;->limit:I

    .line 264
    return-void
.end method

# virtual methods
.method public available()I
    .locals 2
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/io/IOException;
        }
    .end annotation

    .prologue
    .line 272
    invoke-super {p0}, Ljava/io/FilterInputStream;->available()I

    move-result v0

    iget v1, p0, Lcom/htc/protobuf/AbstractMessageLite$Builder$LimitedInputStream;->limit:I

    invoke-static {v0, v1}, Ljava/lang/Math;->min(II)I

    move-result v0

    return v0
.end method

.method public read()I
    .locals 2
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/io/IOException;
        }
    .end annotation

    .prologue
    .line 281
    iget v1, p0, Lcom/htc/protobuf/AbstractMessageLite$Builder$LimitedInputStream;->limit:I

    if-gtz v1, :cond_1

    .line 282
    const/4 v0, -0x1

    .line 288
    :cond_0
    :goto_0
    return v0

    .line 284
    :cond_1
    invoke-super {p0}, Ljava/io/FilterInputStream;->read()I

    move-result v0

    .line 285
    .local v0, result:I
    if-ltz v0, :cond_0

    .line 286
    iget v1, p0, Lcom/htc/protobuf/AbstractMessageLite$Builder$LimitedInputStream;->limit:I

    add-int/lit8 v1, v1, -0x1

    iput v1, p0, Lcom/htc/protobuf/AbstractMessageLite$Builder$LimitedInputStream;->limit:I

    goto :goto_0
.end method

.method public read([BII)I
    .locals 2
    .parameter "b"
    .parameter "off"
    .parameter "len"
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/io/IOException;
        }
    .end annotation

    .prologue
    .line 294
    iget v1, p0, Lcom/htc/protobuf/AbstractMessageLite$Builder$LimitedInputStream;->limit:I

    if-gtz v1, :cond_1

    .line 295
    const/4 v0, -0x1

    .line 302
    :cond_0
    :goto_0
    return v0

    .line 297
    :cond_1
    iget v1, p0, Lcom/htc/protobuf/AbstractMessageLite$Builder$LimitedInputStream;->limit:I

    invoke-static {p3, v1}, Ljava/lang/Math;->min(II)I

    move-result p3

    .line 298
    invoke-super {p0, p1, p2, p3}, Ljava/io/FilterInputStream;->read([BII)I

    move-result v0

    .line 299
    .local v0, result:I
    if-ltz v0, :cond_0

    .line 300
    iget v1, p0, Lcom/htc/protobuf/AbstractMessageLite$Builder$LimitedInputStream;->limit:I

    sub-int/2addr v1, v0

    iput v1, p0, Lcom/htc/protobuf/AbstractMessageLite$Builder$LimitedInputStream;->limit:I

    goto :goto_0
.end method

.method public skip(J)J
    .locals 4
    .parameter "n"
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/io/IOException;
        }
    .end annotation

    .prologue
    .line 311
    iget v2, p0, Lcom/htc/protobuf/AbstractMessageLite$Builder$LimitedInputStream;->limit:I

    int-to-long v2, v2

    invoke-static {p1, p2, v2, v3}, Ljava/lang/Math;->min(JJ)J

    move-result-wide v2

    invoke-super {p0, v2, v3}, Ljava/io/FilterInputStream;->skip(J)J

    move-result-wide v0

    .line 312
    .local v0, result:J
    const-wide/16 v2, 0x0

    cmp-long v2, v0, v2

    if-ltz v2, :cond_0

    .line 313
    iget v2, p0, Lcom/htc/protobuf/AbstractMessageLite$Builder$LimitedInputStream;->limit:I

    int-to-long v2, v2

    sub-long/2addr v2, v0

    long-to-int v2, v2

    iput v2, p0, Lcom/htc/protobuf/AbstractMessageLite$Builder$LimitedInputStream;->limit:I

    .line 315
    :cond_0
    return-wide v0
.end method


text:
#include "nanaccum.h"

/* Helper function to find linearized distance between elements on a given
 * dimension of a multidimensional array. Lower indices are close in memory
 * (column-major or FORTRAN/MATLAB order: */
mwSize stride(int dim, int shape_len, const mwSize *shape)
{
  int i, s = 1;
  for (i = 0; i < dim; i++) {
    s *= shape[i];
  }
  return s;
}

/* Convert a offset in a linearized array to a n-dimensional array index using
 * stride(). */
void offset_to_index(mwSize offset, int ndim, const mwSize *shape,
  mwSize *index)
{
  int i, s;
  for (i = ndim; i-- > 0;) {
    s = stride(i, ndim, shape);
    index[i] = offset / s;
    offset -= index[i] * s;
  }
}

/* Convert an n-dimensional index for an multi-dimensional array to a
 * linearized offset using stride(). */
mwSize index_to_offset(int ndim, mwSize *index, const mwSize *shape)
{
  int i = 0;
  mwSize offset = 0;
  for (i = 0; i < ndim; ++i)
    offset += stride(i, ndim, shape) * index[i];
  return offset;
}

void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
  const mxArray *X = prhs[0], *Y = plhs[0];
  mwSize *index, *size_X, *size_Y, stride_x;
  mwIndex j;
  int i, n, squash_dim, squash_len;
  mxClassID classid;

  /* Check and handle input. */
  switch(nrhs) {
    case 0:
      mexErrMsgTxt("Too few input arguments!");
      break;

    case 1: /* No dimension is given. Find first non-singleton dimension: */
      squash_dim = ndim(X);
      for(i = ndim(X); i-- > 0;) {
        if(size(X)[i] > 1)
          squash_dim = i;
      }
      break;

    case 2:
      squash_dim = (int) mxGetScalar(prhs[1]);
      if(squash_dim <= 0) {
        /* Note that squash_dim > ndim(X) is allowed! */
        mexErrMsgTxt("Invalid value for dimension (argument 2)!");
      }
      squash_dim -= 1; /* convert from MATLAB to C indexing */
      break;

    default:
      mexErrMsgTxt("Too many input arguments!");
  }

  /* Create output array Y: */
  size_Y = mxMalloc(ndim(X) * sizeof(size_Y));
  memcpy(size_Y, size(X), ndim(X) * sizeof(size_Y));
  size_Y[squash_dim] = 1;

  classid = mxGetClassID(X);  /* Copy class ID from X. */

  if (classid == mxSINGLE_CLASS) {
    /* Return single-precision if input is single precision. */
    Y = plhs[0] = mxCreateNumericArray(
      ndim(X), size_Y, mxSINGLE_CLASS, mxGetImagData(X) != NULL);
  }
  else {
    /* By default, use double precision. */
    Y = plhs[0] = mxCreateNumericArray(
      ndim(X), size_Y, mxDOUBLE_CLASS, mxGetImagData(X) != NULL);
  }

  /* Prepare variables for linear indexing: */
  index = (mwSize *) mxMalloc(ndim(X) * sizeof(mwSize));
  stride_x = stride(squash_dim, ndim(X), size(X));

  /* MATLAB's nansum supports out-of-range dims to operate on. */
  /* Find the number of elements in our squashed dimension: */
  if(squash_dim >= ndim(X))
    squash_len = 1;
  else
    squash_len = size(X)[squash_dim];

  {
    void *src = mxGetData(X), *src_imag = mxGetImagData(X);
    double *dest = mxGetData(Y), *dest_imag = mxGetImagData(Y);

    for (i = 0; i < mxGetNumberOfElements(Y); ++i) {
      /* For each element in the output array, do: */

      /* Transform the element number in an index in Y. Please not that size()
       * uses mxGetNumberOfDimensions(), which *ignores trailing singleton
       * dimensions*. In that case, this elegant conversion does not work
       * anymore. But, since we know that ndim(Y) == ndim(X), we use that
       * instead:*/
      offset_to_index(i, ndim(X), size(Y), index);

      /* And map this index back to an offset in X: */
      j = index_to_offset(ndim(X), index, size(X));

      switch (classid) {
        /* Oh, the fucking horror of dumb, statically typed languages... */
        case mxINT8_CLASS:
          dest[i] = nanstat_int8_T(squash_len, (int8_T *) src + j, stride_x);
          break;

        case mxUINT8_CLASS:
          dest[i] = nanstat_uint8_T(squash_len, (uint8_T *) src + j, stride_x);
          break;

        case mxINT16_CLASS:
          dest[i] = nanstat_int16_T(squash_len, (int16_T *) src + j, stride_x);
          break;

        case mxUINT16_CLASS:
          dest[i] = nanstat_uint16_T(squash_len, (uint16_T *) src + j,
            stride_x);
          break;

        case mxINT32_CLASS:
          dest[i] = nanstat_int32_T(squash_len, (int32_T *) src + j, stride_x);
          break;

        case mxUINT32_CLASS:
          dest[i] = nanstat_uint32_T(squash_len, (uint32_T *) src + j,
            stride_x);
          break;

        case mxINT64_CLASS:
          dest[i] = nanstat_int64_T(squash_len, (int64_T *) src + j, stride_x);
          break;

        case mxUINT64_CLASS:
          dest[i] = nanstat_uint64_T(squash_len, (uint64_T *) src + j,
            stride_x);
          break;

        case mxSINGLE_CLASS:
          ((float *) dest)[i] = (float) nanstat_float(
            squash_len, (float *) src + j, stride_x);
          if (src_imag) {
            ((float *) dest_imag)[i] = (float) nanstat_float(
              squash_len, (float *) src_imag + j, stride_x);
          }
          break;

        case mxDOUBLE_CLASS:
          dest[i] = nanstat_double(squash_len, (double *) src + j, stride_x);
          if (src_imag) {
            dest_imag[i] = nanstat_double(squash_len, (double *) src_imag + j,                 stride_x);
          }
          break;

        case mxLOGICAL_CLASS:
          mexWarnMsgTxt(
            "The byte layout of logical arrays is not documented. Guessing.");
          dest[i] = nanstat_uint8_T(squash_len, (uint8_T *) src + j, stride_x);
          break;

        case mxCHAR_CLASS:
          mexWarnMsgTxt(
            "The byte layout of char arrays is not documented. Guessing.");
          dest[i] = nanstat_uint16_T(squash_len, (uint16_T *) src + j,
            stride_x);
          break;

        default:
          mexErrMsgTxt("Unsupported type!");
      }
    }
  }

  if(index) mxFree(index);
  if(size_Y) mxFree(size_Y);
}

redpajama_set_name: RedPajamaGithub


text:
<?php
header("Content-type: application/json; charset=utf-8");
require_once '../ajax/Endereco.dao.php';

$cep = $_POST['cep'];

$enderecoDAO = new EnderecoDAO();

$logradouro = $enderecoDAO->getEnderecoCompletoPorCep($cep);

if($logradouro != null){
$dados['result'] = "true";
$dados['logradouro'] = (string) $logradouro->nomeLogradouro;
$dados['idLogradouro'] = (string) $logradouro->idLogradouro;
$dados['bairro']  = (string) $logradouro->bairro->nomeBairro;
$dados['cidade']  = (string) $logradouro->bairro->cidade->nomeCidade;
$dados['uf']  = (string) $logradouro->bairro->cidade->uf->nomeEstado;
$dados['cep'] = $cep;
}else{
    $dados['result'] = "false";
}

echo json_encode($dados, JSON_UNESCAPED_UNICODE );


text:
class ArcadeLearningEnvironment < Formula
  include Language::Python::Virtualenv

  desc "Platform for AI research"
  homepage "https://github.com/mgbellemare/Arcade-Learning-Environment"
  url "https://github.com/mgbellemare/Arcade-Learning-Environment.git",
      tag:      "v0.8.0",
      revision: "d59d00688b58c5c14dff5fc79db5c22e86987f5d"
  license "GPL-2.0-only"
  head "https://github.com/mgbellemare/Arcade-Learning-Environment.git", branch: "master"

  bottle do
    rebuild 1
    sha256 cellar: :any_skip_relocation, arm64_ventura:  "1f33932e7707d642c4fdc38f5474d8ee82c6cd7c31491081e947d5df4445a8a4"
    sha256 cellar: :any_skip_relocation, arm64_monterey: "c26a068c64184f700b8b638e37c978b9e4b611e74fb5834016982706c7dd4009"
    sha256 cellar: :any_skip_relocation, arm64_big_sur:  "35debc9b99e3b5142b5f626a8fa370c8025ba2f09f8d64c7948e4387d84beb2a"
    sha256 cellar: :any_skip_relocation, monterey:       "efb722d0b171efa9869925d762361d301a98181d8dd053972cbff2b1dad80ef4"
    sha256 cellar: :any_skip_relocation, big_sur:        "cb7e5a9f35472e9b25499a5163cea73b27026908bee527aee9e521229676db00"
    sha256 cellar: :any_skip_relocation, catalina:       "6c9f67f4b5653089a35e6d50df593bd93ed60078cbce10ca815f2aca176a6f58"
    sha256 cellar: :any_skip_relocation, x86_64_linux:   "63248a068444838a906590b26dabe111465a225de384c50c7f89faac0be16c92"
  end

  depends_on "cmake" => :build
  depends_on macos: :catalina # requires std::filesystem
  depends_on "numpy"
  depends_on "python@3.11"
  depends_on "sdl2"

  uses_from_macos "zlib"

  fails_with gcc: "5"

  resource "importlib-resources" do
    url "https://files.pythonhosted.org/packages/06/72/6bf0df4fe7a139147f5d6b473f16d5aefb7bc5b719ba5dd33f230d35760f/importlib_resources-5.10.0.tar.gz"
    sha256 "c01b1b94210d9849f286b86bb51bcea7cd56dde0600d8db721d7b81330711668"
  end

  def python3
    "python3.11"
  end

  def install
    system "cmake", "-S", ".", "-B", "build",
                    "-DSDL_SUPPORT=ON",
                    "-DSDL_DYNLOAD=ON",
                    *std_cmake_args
    system "cmake", "--build", "build"
    system "cmake", "--install", "build"
    pkgshare.install "tests/resources/tetris.bin"

    venv = virtualenv_create(libexec, python3)
    venv.pip_install resources

    # error: no member named 'signbit' in the global namespace
    inreplace "setup.py", "cmake_args = [", "\\0\"-DCMAKE_OSX_SYSROOT=#{MacOS.sdk_path}\"," if OS.mac?

    # `venv.pip_install_and_link buildpath` fails to install scripts, so manually run setup.py instead
    bin_before = (libexec/"bin").children.to_set
    venv_python = libexec/"bin/python"
    system venv_python, *Language::Python.setup_install_args(libexec, venv_python)
    bin.install_symlink ((libexec/"bin").children.to_set - bin_before).to_a

    site_packages = Language::Python.site_packages(python3)
    pth_contents = "import site; site.addsitedir('#{libexec/site_packages}')\n"
    (prefix/site_packages/"homebrew-ale-py.pth").write pth_contents

    # Replace vendored `libSDL2` with a symlink to our own.
    libsdl2 = Formula["sdl2"].opt_lib/shared_library("libSDL2")
    vendored_libsdl2_dir = libexec/site_packages/"ale_py"
    (vendored_libsdl2_dir/shared_library("libSDL2")).unlink

    # Use `ln_s` to avoid referencing a Cellar path.
    ln_s libsdl2.relative_path_from(vendored_libsdl2_dir), vendored_libsdl2_dir
  end

  test do
    output = shell_output("#{bin}/ale-import-roms 2>&1", 2)
    assert_match "one of the arguments --import-from-pkg romdir is required", output
    output = shell_output("#{bin}/ale-import-roms .").lines.last.chomp
    assert_equal "Imported 0 / 0 ROMs", output

    cp pkgshare/"tetris.bin", testpath
    output = shell_output("#{bin}/ale-import-roms --dry-run .").lines.first.chomp
    assert_match(/\[SUPPORTED\].*tetris\.bin/, output)

    (testpath/"test.py").write <<~EOS
      from ale_py import ALEInterface, SDL_SUPPORT
      assert SDL_SUPPORT

      ale = ALEInterface()
      ale.setInt("random_seed", 123)
      ale.loadROM("tetris.bin")
      assert len(ale.getLegalActionSet()) == 18
    EOS

    output = shell_output("#{python3} test.py 2>&1")
    assert_match <<~EOS, output
      Game console created:
        ROM file:  tetris.bin
        Cart Name: Tetris 2600 (Colin Hughes)
        Cart MD5:  b0e1ee07fbc73493eac5651a52f90f00
    EOS
    assert_match <<~EOS, output
      Running ROM file...
      Random seed is 123
    EOS
  end
end


text:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<meta http-equiv="Content-Type" content="text/html" charset="UTF-8">
<title>org.apache.giraph.master 类分层结构 (Apache Giraph Core 1.0.0 API)</title>
<meta name="date" content="2013-11-04">
<link rel="stylesheet" type="text/css" href="../../../../stylesheet.css" title="Style">

您的浏览器已禁用 JavaScript。

概览

程序包

类

使用

树

已过时

索引

帮助

上一个

下一个

框架

无框架

所有类

程序包org.apache.giraph.master的分层结构

程序包分层结构:

所有程序包

类分层结构

java.lang.Object

org.apache.giraph.bsp.BspService<I,V,E,M> (implements org.apache.giraph.bsp.CentralizedService<I,V,E,M>, org.apache.zookeeper.Watcher)

org.apache.giraph.master.BspServiceMaster<I,V,E,M> (implements org.apache.giraph.bsp.CentralizedServiceMaster<I,V,E,M>, org.apache.giraph.metrics.ResetSuperstepMetricsObserver)

org.apache.giraph.master.BspServiceMaster.FinalizedCheckpointPathFilter (implements org.apache.hadoop.fs.PathFilter)

org.apache.giraph.master.DefaultMasterObserver (implements org.apache.giraph.master.MasterObserver)

org.apache.giraph.master.MasterAggregatorHandler (implements org.apache.giraph.master.MasterAggregatorUsage, org.apache.hadoop.io.Writable)

org.apache.giraph.master.MasterCompute (implements org.apache.giraph.conf.ImmutableClassesGiraphConfigurable<I,V,E,M>, org.apache.giraph.master.MasterAggregatorUsage, org.apache.hadoop.io.Writable)

org.apache.giraph.master.DefaultMasterCompute

org.apache.giraph.graph.TaskInfo (implements org.apache.hadoop.io.Writable)

org.apache.giraph.master.MasterInfo

java.lang.Thread (implements java.lang.Runnable)

org.apache.giraph.master.MasterThread<I,V,E,M>

接口分层结构

org.apache.giraph.aggregators.AggregatorUsage

org.apache.giraph.master.MasterAggregatorUsage

org.apache.giraph.conf.ImmutableClassesGiraphConfigurable<I,V,E,M>

org.apache.giraph.master.MasterObserver

概览

程序包

类

使用

树

已过时

索引

帮助

上一个

下一个

框架

无框架

所有类

Copyright © 2011-2013 The Apache Software Foundation. All Rights Reserved.


text:
Newer version available at [aws-elasticsearch-js](https://github.com/gosquared/aws-elasticsearch-js) for more recent versions of Elasticsearch and elasticsearch-js.

---

# Connection handler for Amazon ES [<img title="Version" src="https://img.shields.io/npm/v/http-aws-es.svg?style=flat-square" />](https://www.npmjs.org/package/http-aws-es)
Makes [elasticsearch-js](https://github.com/elastic/elasticsearch-js) compatible with Amazon ES. It uses the aws-sdk to make signed requests to an Amazon ES endpoint.

## Installation
```bash
# Install the connector, elasticsearch client and aws-sdk
npm install --save http-aws-es aws-sdk elasticsearch
```

## Usage
```javascript
// create an elasticsearch client for your Amazon ES
let es = require('elasticsearch').Client({
  hosts: [ 'https://amazon-es-host.us-east-1.es.amazonaws.com' ],
  connectionClass: require('http-aws-es')
});
```

## Region + Credentials
The connector uses aws-sdk's default behaviour to obtain region + credentials from your environment. If you would like to set these manually, you can set them on aws-sdk:

```javascript
let AWS = require('aws-sdk');
AWS.config.update({
  credentials: new AWS.Credentials(accessKeyId, secretAccessKey),
  region: 'us-east-1'
});
```

## Options
```javascript
let options = {
  hosts: [], // array of amazon es hosts (required)
  connectionClass: require('http-aws-es'), // use this connector (required)
  awsConfig: new AWS.Config({ region }), // set an aws config e.g. for multiple clients to different regions
  httpOptions: {} // set httpOptions on aws-sdk's request. default to aws-sdk's config.httpOptions
};
let es = require('elasticsearch').Client(options);
```

## Test
```bash
npm test
# test against a real endpoint
AWS_PROFILE=your-profile npm run integration-test -- --endpoint https://amazon-es-host.us-east-1.es.amazonaws.com --region us-east-1
```


text:
package autopilotrpc

import (
	"github.com/lightningnetwork/lnd/autopilot"
)

// Config is the primary configuration struct for the autopilot RPC server. It
// contains all the items required for the rpc server to carry out its
// duties. The fields with struct tags are meant to be parsed as normal
// configuration options, while if able to be populated, the latter fields MUST
// also be specified.
type Config struct {
	// Manager is the running autopilot manager.
	Manager *autopilot.Manager
}


text:
namespace glf
{
	//--------------------------------------------------------------------------
	ProbeLight::ProbeLight(int _resolution)
	{
		for(int i=0;i<9;++i)
			shCoeffs[i]=glm::vec3(0);

		cubeTex.Allocate(GL_RGBA32F, _resolution, true);
		cubeTex.SetWrapping(GL_CLAMP_TO_EDGE,GL_CLAMP_TO_EDGE,GL_CLAMP_TO_EDGE);
		cubeTex.SetFiltering(GL_LINEAR_MIPMAP_LINEAR,GL_LINEAR);
	}
	//--------------------------------------------------------------------------
	ProbeBuilder::ProbeBuilder(int _resolution):
	program("ProbeBuiler"),
	resolution(_resolution)
	{
		CreateScreenTriangle(vbo);
		vao.Add(vbo,semantic::Position,2,GL_FLOAT);

		const int outCoeffs0 = 0;
		const int outCoeffs1 = 1;
		const int outCoeffs2 = 2;
		const int outCoeffs3 = 3;
		const int outCoeffs4 = 4;
		const int outCoeffs5 = 5;
		const int outCoeffs6 = 6;
		ProgramOptions options = ProgramOptions::CreateVSOptions();
		options.AddDefine<int>("BUILDER",1);
		options.AddDefine<int>("OUT_COEFF0",outCoeffs0);
		options.AddDefine<int>("OUT_COEFF1",outCoeffs1);
		options.AddDefine<int>("OUT_COEFF2",outCoeffs2);
		options.AddDefine<int>("OUT_COEFF3",outCoeffs3);
		options.AddDefine<int>("OUT_COEFF4",outCoeffs4);
		options.AddDefine<int>("OUT_COEFF5",outCoeffs5);
		options.AddDefine<int>("OUT_COEFF6",outCoeffs6);
		program.Compile(	options.Append(LoadFile(directory::ShaderDirectory + "probe.vs")),
							options.Append(LoadFile(directory::ShaderDirectory + "probe.fs")));

		glm::mat4 transformations[6];
		transformations[0] = glm::rotate(-90.f,0.f,0.f,1.f) * glm::rotate(90.f,1.f,0.f,0.f); 				// Positive X
		transformations[1] = glm::rotate( 90.f,0.f,0.f,1.f) * glm::rotate(90.f,1.f,0.f,0.f); 				// Negative X
		transformations[2] = glm::rotate( 90.f,1.f,0.f,0.f);												// Positive Y
		transformations[3] = glm::rotate(180.f,0.f,0.f,1.f) * glm::rotate(90.f,1.f,0.f,0.f); 				// Negative Y
		transformations[4] = glm::rotate(180.f,1.f,0.f,0.f);												// Positive Z
		transformations[5] = glm::mat4(1);																	// Negative Z
		glProgramUniformMatrix4fv(program.id, program["Transformations[0]"].location, 6, GL_FALSE, &transformations[0][0][0]);
		cubeTexUnit = program["CubeTex"].unit;
		glProgramUniform1i(program.id, program["CubeTex"].location, cubeTexUnit);

		// Would be 16FP enough precise ?
		shTex.Allocate(GL_RGBA32F,_resolution,_resolution,7,true);
		shTex.SetWrapping(GL_CLAMP_TO_EDGE,GL_CLAMP_TO_EDGE);
		shTex.SetFiltering(GL_LINEAR_MIPMAP_LINEAR,GL_LINEAR);

		glGenFramebuffers(1,&shFBO);
		glBindFramebuffer(GL_FRAMEBUFFER,shFBO);
		glFramebufferTextureLayer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + outCoeffs0, shTex.id, 0, 0);
		glFramebufferTextureLayer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + outCoeffs1, shTex.id, 0, 1);
		glFramebufferTextureLayer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + outCoeffs2, shTex.id, 0, 2);
		glFramebufferTextureLayer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + outCoeffs3, shTex.id, 0, 3);
		glFramebufferTextureLayer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + outCoeffs4, shTex.id, 0, 4);
		glFramebufferTextureLayer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + outCoeffs5, shTex.id, 0, 5);
		glFramebufferTextureLayer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + outCoeffs6, shTex.id, 0, 6);
		GLenum buffers[7] = {	GL_COLOR_ATTACHMENT0,
								GL_COLOR_ATTACHMENT1,
								GL_COLOR_ATTACHMENT2,
								GL_COLOR_ATTACHMENT3,
								GL_COLOR_ATTACHMENT4,
								GL_COLOR_ATTACHMENT5,
								GL_COLOR_ATTACHMENT6 };
		glDrawBuffers(7,buffers);
		glBindFramebuffer(GL_FRAMEBUFFER,0);
		glf::CheckFramebuffer(shFBO);

		glf::CheckError("ProbeBuilder::ProbeBuilder");
	}
	//--------------------------------------------------------------------------
	void ProbeBuilder::Filter(	ProbeLight& 				_probe,
								int 						_level)
	{
		assert(_probe.cubeTex.size.x == shTex.size.x);
		assert(_probe.cubeTex.size.y == shTex.size.y);
		assert(_probe.cubeTex.levels == shTex.levels);

		glViewport(0,0,shTex.size.x,shTex.size.y);
		glBindFramebuffer(GL_FRAMEBUFFER,shFBO);
		glClear(GL_COLOR_BUFFER_BIT);

		glUseProgram(program.id);
		_probe.cubeTex.Bind(cubeTexUnit);
		vao.Draw(GL_TRIANGLES,vbo.count,0);

		// Reduce/Sum SH Coeffs
		glBindTexture(GL_TEXTURE_2D_ARRAY,shTex.id);
		glGenerateMipmap(GL_TEXTURE_2D_ARRAY);

		// Retrieve coefficients
		// We multiple by the number of pixels in order to compensate the
		// average process of the mipmap (we want the sum, not the average)
		//
		// The last two Probe coeffs are stored into the first 6 w components
		int nMipmaps = glf::MipmapLevels(resolution);
		float factor = float(resolution*resolution);
		float coeffs[28];
		glGetTexImage(GL_TEXTURE_2D_ARRAY, nMipmaps-1, GL_RGBA, GL_FLOAT, coeffs);
		_probe.shCoeffs[0] = glm::vec3(coeffs[0], coeffs[1], coeffs[2])  * factor;
		_probe.shCoeffs[1] = glm::vec3(coeffs[4], coeffs[5], coeffs[6])  * factor;
		_probe.shCoeffs[2] = glm::vec3(coeffs[8], coeffs[9], coeffs[10]) * factor;
		_probe.shCoeffs[3] = glm::vec3(coeffs[12],coeffs[13],coeffs[14]) * factor;
		_probe.shCoeffs[4] = glm::vec3(coeffs[16],coeffs[17],coeffs[18]) * factor;
		_probe.shCoeffs[5] = glm::vec3(coeffs[20],coeffs[21],coeffs[22]) * factor;
		_probe.shCoeffs[6] = glm::vec3(coeffs[24],coeffs[25],coeffs[26]) * factor;
		_probe.shCoeffs[7] = glm::vec3(coeffs[3], coeffs[7], coeffs[11]) * factor;
		_probe.shCoeffs[8] = glm::vec3(coeffs[15],coeffs[19],coeffs[23]) * factor;

		#if DISPLAY_SH_COEFFICIENTS
		for(int i=0;i<9;++i)
			glf::Info("Coeffs %d : %f %f %f",i,_probe.coeffs[i].x,_probe.coeffs[i].y,_probe.coeffs[i].z);
		#endif

		glBindFramebuffer(GL_FRAMEBUFFER,0);
		glViewport(0,0,ctx::window.Size.x,ctx::window.Size.y);

		// Reduce/Filter cubemap
		glBindTexture(GL_TEXTURE_CUBE_MAP,_probe.cubeTex.id);
		glGenerateMipmap(GL_TEXTURE_CUBE_MAP);
		glBindTexture(GL_TEXTURE_CUBE_MAP,0);

		glf::CheckError("ProbeBuilder::Update");
	}
	//-------------------------------------------------------------------------
	ProbeRenderer::ProbeRenderer(int _w, int _h):
	program("ProbeRenderer")
	{
		ProgramOptions options = ProgramOptions::CreateVSOptions();
		options.AddDefine<int>("RENDERER",1);
		options.AddDefine<int>("DIFFUSE_REFLECTION",1);
		options.AddDefine<int>("LIGHTING_ONLY",ENABLE_LIGHTING_ONLY);
		options.Include(LoadFile(directory::ShaderDirectory + "brdf.fs"));
		program.Compile(options.Append(LoadFile(directory::ShaderDirectory + "probe.vs")),
						options.Append(LoadFile(directory::ShaderDirectory + "probe.fs")));

		shCoeffsVar			= program["SHCoeffs[0]"].location;
		normalTexUnit		= program["NormalTex"].unit;
		diffuseTexUnit		= program["DiffuseTex"].unit;
		glProgramUniform1i(program.id, program["NormalTex"].location, normalTexUnit);
		glProgramUniform1i(program.id, program["DiffuseTex"].location, diffuseTexUnit);

		// For all reflections
//		viewPosVar			= program["ViewPos"].location;
//		cubeTexUnit			= program["CubeTex"].unit;
//		positionTexUnit		= program["PositionTex"].unit;
//		glProgramUniform1i(program.id, program["CubeTex"].location, cubeTexUnit);
//		glProgramUniform1i(program.id, program["PositionTex"].location, positionTexUnit);

	}
	//-------------------------------------------------------------------------
	void ProbeRenderer::Draw(	const ProbeLight&	_probe,
								const GBuffer&		_gbuffer,
								const glm::vec3&	_viewPos,
								const RenderTarget& _renderTarget)
	{
		glUseProgram(program.id);

		// For all reflections
//		glProgramUniform3f(program.id, viewPosVar, _viewPos.x, _viewPos.y, _viewPos.z);
//		_probe.cubeTex.Bind(cubeTexUnit);
//		_gbuffer.positionTex.Bind(positionTexUnit);

		glProgramUniform3fv(program.id, shCoeffsVar, 9, (float*)(&_probe.shCoeffs[0]));
		_gbuffer.diffuseTex.Bind(diffuseTexUnit);
		_gbuffer.normalTex.Bind(normalTexUnit);
		_renderTarget.Draw();

		glf::CheckError("ProbeRenderer::Draw");
	}
}