void renderEye(StereoEye eye) {
        viewport(eye);
        gl::ProgramPtr distortProgram = GlUtils::getProgram(
                                            Resource::SHADERS_TEXTURED_VS,
                                            chroma ?
                                            Resource::SHADERS_RIFTCHROMAWARP_FS :
                                            Resource::SHADERS_RIFTWARP_FS);
        distortProgram->use();
        distortProgram->setUniform1i("Scene", 1);
        distortProgram->setUniform1i("OffsetMap", 0);

        glActiveTexture(GL_TEXTURE1);
        sceneTextures[eye]->bind();
        glActiveTexture(GL_TEXTURE0);
        lookupTextures[eye]->bind();

        quadGeometry->bindVertexArray();
#ifdef DISTORTION_TIMING
        query->begin();
#endif
        quadGeometry->draw();

#ifdef DISTORTION_TIMING
        query->end();
        static long accumulator = 0;
        static long count = 0;
        accumulator += query->getResult();
        count++;
        SAY("%d ns", accumulator / count);
#endif

        gl::VertexArray::unbind();
        gl::Texture2d::unbind();
        gl::Program::clear();
    }
コード例 #2
0
  void draw() {
    glClearColor(0, 1, 0, 1);
    glClear(GL_COLOR_BUFFER_BIT);
    GL_CHECK_ERROR;

    for (int i = 0; i < 2; ++i) {
      const EyeArg & eyeArg = eyeArgs[i];

      frameBuffer.activate();
      renderScene(eyeArg);
      frameBuffer.deactivate();

      glDisable(GL_DEPTH_TEST);
      glDisable(GL_BLEND);

      gl::viewport(eyeArg.viewportLocation, eyeSize);
      distortProgram->use();
      distortProgram->setUniform("LensOffset", eyeArg.lensOffset);
      frameBuffer.color->bind();
      quadGeometry->bindVertexArray();
      quadGeometry->draw();
      gl::Geometry::unbindVertexArray();
      gl::Program::clear();
    }
  }
コード例 #3
0
ファイル: GlUtils.cpp プロジェクト: Kittnz/OculusRiftInAction
void GlUtils::renderGeometry(
  const gl::GeometryPtr & geometry,
    gl::ProgramPtr program) {
  program->use();
  gl::Stacks::lights().apply(program);
  gl::Stacks::projection().apply(program);
  gl::Stacks::modelview().apply(program);
  geometry->bindVertexArray();
  geometry->draw();

  gl::VertexArray::unbind();
  gl::Program::clear();
}
コード例 #4
0
ファイル: GlUtils.cpp プロジェクト: Kittnz/OculusRiftInAction
void cubeRecurseDraw(gl::GeometryPtr & cubeGeometry, gl::ProgramPtr & renderProgram, int depth, float elapsed, int axisIndex) {
  if (0 == depth) {
    return;
  }

  static glm::vec3 translation(0, 0, 1.5);

  const glm::vec3 & axis = AXES[axisIndex % 3];

  float angle = elapsed * 0.2f * ((rand() % 10) - 5);

  float scale = 0.7f;
  gl::MatrixStack & mv = gl::Stacks::modelview();
  mv.with_push([&]{
    mv.rotate(angle, axis).translate(translation).scale(scale).apply(renderProgram);
    cubeGeometry->draw();
    cubeRecurseDraw(cubeGeometry, renderProgram, depth - 1, elapsed, axisIndex + 1);
  });
  mv.with_push([&]{
    mv.rotate(angle + PI, axis).translate(translation).scale(scale).apply(renderProgram);
    cubeGeometry->draw();
    cubeRecurseDraw(cubeGeometry, renderProgram, depth - 1, elapsed, axisIndex + 1);
  });
}