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


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

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


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

示例1: drawTextureShader

void DrawShader::drawTextureShader(bool isReflection, Shader& shader, const std::vector<Drawable>& drawables,
      const glm::mat4& viewMatrix, const glm::vec3& sunDir, float sunIntensity, 
      int lightning, const FrameBufferObject& reflection_fbo) {

   shader.sendUniform(Uniform::PROJECTION, uniforms, gProjectionMatrix);
   shader.sendUniform(Uniform::VIEW, uniforms, viewMatrix);

   shader.sendUniform(Uniform::LIGHTNING, uniforms, lightning);
   SendSun(shader, uniforms, sunIntensity, sunDir);

   for (auto& drawable : drawables) {
      if (drawable.draw_template.shader_type == ShaderType::TEXTURE ||
          drawable.draw_template.shader_type == ShaderType::DEFERRED) { 
         {
         // Per-Drawable Texture Shader Setup
            //SendHeightMap(shader, drawable);
            SendBones(shader, drawable);
            SendTexture(shader, drawable);

            if (!isReflection && drawable.draw_template.effects.count(EffectType::IS_WATER)) {
               shader.sendUniform(Uniform::IS_WATER, uniforms, 1);
               shader.sendUniform(Uniform::REFLECTION_TEXTURE, uniforms, reflection_fbo.texture_slot());  
               reflection_fbo.texture().enable(texture_cache_);
            }
            else
               shader.sendUniform(Uniform::IS_WATER, uniforms, 0);

            drawable.draw_template.material.sendMaterial(shader, uniforms);
         }
         if (!drawable.draw_template.effects.count(EffectType::IS_WATER) || !isReflection)
            drawModelTransforms(shader, drawable, viewMatrix, true, uniforms);
      }
   }
}
开发者ID:Ethanmn,项目名称:CPE476Final,代码行数:34,代码来源:draw_shaders.cpp

示例2: SendShadow

void DrawShader::SendShadow(Shader& shader, const UniformLocationMap& uniforms,
         const FrameBufferObject& shadow_map_fbo_,
         const glm::vec3& deerPos, const glm::vec3& sunDir) {
      shadow_map_fbo_.texture().enable(texture_cache_);
      shader.sendUniform(Uniform::HAS_SHADOWS, uniforms, 1);
      shader.sendUniform(Uniform::SHADOW_MAP_TEXTURE, uniforms, shadow_map_fbo_.texture_slot());
      SendInverseShadow(shader, uniforms, sunDir, deerPos);
}
开发者ID:Ethanmn,项目名称:CPE476Final,代码行数:8,代码来源:draw_shaders.cpp

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