void Render(double time) { static const Mat4f reflection( Vec4f( 1.0, 0.0, 0.0, 0.0), Vec4f( 0.0,-1.0, 0.0, 0.0), Vec4f( 0.0, 0.0, 1.0, 0.0), Vec4f( 0.0, 0.0, 0.0, 1.0) ); auto camera = CamMatrixf::Orbiting( Vec3f(), GLfloat(7.0 + SineWave(time / 12.0)*2.5), FullCircles(time / 10.0), Degrees(45.0 - SineWave(time / 7.0)*35.0) ); shape_prog.Use(); shape.Bind(); gl.Enable(Capability::CullFace); gl.FrontFace(make_shape.FaceWinding()); // render into the off-screen framebuffer fbo.Bind(Framebuffer::Target::Draw); gl.Viewport( (width - refl_tex_side) / 2, (height - refl_tex_side) / 2, refl_tex_side, refl_tex_side ); gl.Clear().ColorBuffer().DepthBuffer(); shape_camera_matrix.Set( camera * ModelMatrixf::Translation(0.0f, -1.0f, 0.0f) * reflection ); gl.CullFace(Face::Front); shape_instr.Draw(shape_indices); gl.Bind(Framebuffer::Target::Draw, DefaultFramebuffer()); gl.Viewport(width, height); gl.Clear().ColorBuffer().DepthBuffer(); shape_camera_matrix.Set(camera); gl.CullFace(Face::Back); shape_instr.Draw(shape_indices); gl.Disable(Capability::CullFace); // Render the plane plane_prog.Use(); plane.Bind(); plane_camera_matrix.Set(camera); plane_camera_position.Set(camera.Position()); plane_instr.Draw(plane_indices); }
void Use(void) { vao.Bind(); }