当前位置: 首页>>代码示例>>C++>>正文


C++ FrameBufferObject::bind方法代码示例

本文整理汇总了C++中FrameBufferObject::bind方法的典型用法代码示例。如果您正苦于以下问题:C++ FrameBufferObject::bind方法的具体用法?C++ FrameBufferObject::bind怎么用?C++ FrameBufferObject::bind使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FrameBufferObject的用法示例。


在下文中一共展示了FrameBufferObject::bind方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

void TextRenderer::
render_fps(RenderContext const& ctx, FrameBufferObject& target,
           float application_fps, float rendering_fps) const {

    target.bind(ctx);

    math::mat4 fs_projection = scm::math::make_ortho_matrix(
                                  0.0f, static_cast<float>(target.width()),
                                  0.0f, static_cast<float>(target.height()),
                                  -1.0f, 1.0f);

    text_renderer_->projection_matrix(fs_projection);

    frame_counter_text_->text_string("Application FPS: "
                            + string_utils::to_string(application_fps)
                            + "\nRendering FPS: "
                            + string_utils::to_string(rendering_fps));

    math::vec2i text_ur = math::vec2i(40, target.height()
                            - frame_counter_text_->text_bounding_box().y + 10);

    text_renderer_->draw_outlined(
                            ctx.render_context, text_ur, frame_counter_text_);

    target.unbind(ctx);
}
开发者ID:thelaui,项目名称:guacamole-attic,代码行数:26,代码来源:TextRenderer.cpp

示例2: drawModelTransforms

void DrawShader::drawModelTransforms(
      Shader& shader,
      const Drawable& drawable,
      const glm::mat4& view,
      const FrameBufferObject& deferred_diffuse_fbo,
      const FrameBufferObject& deferred_position_fbo,
      const FrameBufferObject& deferred_normal_fbo,
      bool needsModel,
      const UniformLocationMap& uniforms) {
   for(const auto& instance : drawable.draw_instances) {
      if (instance.material) {
         instance.material->sendMaterial(shader, uniforms);
      }

      const auto model_view = view * instance.model_transform;
      shader.sendUniform(Uniform::MODEL_VIEW_PROJECTION, uniforms, gProjectionMatrix * model_view);
      SendModelAndNormal(shader, uniforms, model_view, instance.model_transform, needsModel);
      for (int i = 0; i < LAST_DEFERRED; ++i) {
         const auto deferred_type(static_cast<DeferredType>(i));
         switch (deferred_type) {
            case DEFERRED_DIFFUSE:
               deferred_diffuse_fbo.bind();
               break;
            case DEFERRED_POSITION:
               deferred_position_fbo.bind();
               break;
            case DEFERRED_NORMAL:
               deferred_normal_fbo.bind();
               break;
            default: break;
         }
         shader.sendUniform(Uniform::OUTPUT_SHADER_TYPE, uniforms, i);
         shader.drawMesh(drawable.draw_template.mesh);
      }
   }
}
开发者ID:Ethanmn,项目名称:CPE476Final,代码行数:36,代码来源:draw_shaders.cpp

示例3:

FrameBufferObject::Binder::Binder( const FrameBufferObject& fbo ) :
    m_fbo( fbo )
{
    KVS_ASSERT( fbo.isCreated() );
    fbo.bind();
}
开发者ID:naohisas,项目名称:KVS,代码行数:6,代码来源:FrameBufferObject.cpp

示例4: Draw

void DrawShader::Draw(glm::vec3 flowerFade,
      const FrameBufferObject& shadow_map_fbo_,
      const FrameBufferObject& reflection_fbo,
      const FrameBufferObject& deferred_diffuse_fbo_,
      const FrameBufferObject& deferred_position_fbo_,
      const FrameBufferObject& deferred_normal_fbo_,
      const vector<CulledDrawable>& culledDrawables,
      const glm::mat4& viewMatrix,
      int useBlinnPhong,
      const glm::vec3& deerPos,
      const glm::vec3& sunDir,
      float sunIntensity,
      int lightning) {

   glm::mat4 curView; //For deferred shading.

   for(auto& shader_pair : shaders.getMap()) {
      Shader& shader = shader_pair.second;
      shader.use();
      switch (shader_pair.first) {
         case ShaderType::SHADOW:
            if(printCurrentShaderName)
               printf("Shadow\n");
            {
               const auto shadow_view = glm::lookAt(sunDir + deerPos, deerPos, glm::vec3(0.0, 1.0, 0.0));
               const auto view_projection = kShadowProjection * shadow_view;
               // Shadow Culling.
               Frustum frustum(view_projection);
               const auto shadow_drawables = frustum.cullShadowDrawables(culledDrawables);
               if(!debug) {
                  shadow_map_fbo_.bind();
                  glClear(GL_DEPTH_BUFFER_BIT);
               }
               {
                  glPolygonMode(GL_FRONT, GL_FILL);
                  const auto drawables = Drawable::fromCulledDrawables(shadow_drawables, CullType::VIEW_CULLING);
                  for (auto& drawable : drawables) {
                     SendBones(shader, drawable);
                     if (drawable.draw_template.effects.count(EffectType::CASTS_SHADOW)) {
                        SendTexture(shader, drawable);
                        for(auto& instance : drawable.draw_instances) {
                           shader.sendUniform(Uniform::MODEL_VIEW_PROJECTION, uniforms,
                                 view_projection * instance.model_transform);
                           shader.sendUniform(Uniform::MODEL, uniforms, instance.model_transform);
                           shader.drawMesh(drawable.draw_template.mesh);
                        }
                     }
                  }
               }

               if(!debug) {
                  glBindFramebuffer(GL_FRAMEBUFFER, 0);
                  shadow_map_fbo_.texture().enable(texture_cache_);
               }
            }
            break;

         case ShaderType::REFLECTION:
            if (!gReflections) break;
            {
               reflection_fbo.bind();
               glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
               // Cheap hack: just use view culling.
               auto drawables = Drawable::fromCulledDrawables(culledDrawables, CullType::VIEW_CULLING);
               // scale everything across the ground.
               const auto scale = glm::scale(glm::mat4(), glm::vec3(1, -1, 1));
               for (std::vector<Drawable>::iterator iter = drawables.begin(); iter != drawables.end();) {
                  // Cheap hack to get rid of the ground plane. DEADLINE
                  // APPROACHES.
                  if (iter->draw_template.height_map) {
                     iter = drawables.erase(iter);
                  } else {
                     for (auto& instance : iter->draw_instances) {
                        instance.model_transform = scale * instance.model_transform;
                     }
                     ++iter;
                  }
               }
               const auto reflectSunDir = glm::vec3(scale * glm::vec4(sunDir, 0));

               shader.sendUniform(Uniform::HAS_SHADOWS, uniforms, 0);
               shader.sendUniform(Uniform::USE_BLINN_PHONG, uniforms, useBlinnPhong);

               glFrontFace(GL_CW);
               drawTextureShader(true, shader, drawables, viewMatrix, reflectSunDir, sunIntensity,
                     lightning, reflection_fbo);
               glFrontFace(GL_CCW);
            }
            break;

         case ShaderType::TEXTURE:
            if (!useTextureShader) break;
            if(printCurrentShaderName)
               printf("Texture\n");

            glBindFramebuffer(GL_FRAMEBUFFER, 0);

            {
               const auto drawables = Drawable::fromCulledDrawables(culledDrawables, CullType::VIEW_CULLING);
               shader.sendUniform(Uniform::USE_BLINN_PHONG, uniforms, useBlinnPhong);
//.........这里部分代码省略.........
开发者ID:Ethanmn,项目名称:CPE476Final,代码行数:101,代码来源:draw_shaders.cpp


注:本文中的FrameBufferObject::bind方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。