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(); }
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(); } }
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(); }