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


C++ ref_ptr::GetAttributeLocation方法代码示例

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


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

示例1: CalculateTransform

void Arrow3d::RenderArrow(ScreenBase const & screen, ref_ptr<dp::GpuProgram> program,
                          dp::Color const & color, float dz, bool hasNormals)
{
    program->Bind();

    GLFunctions::glBindBuffer(m_bufferId, gl_const::GLArrayBuffer);
    uint32_t const attributePosition = program->GetAttributeLocation("a_pos");
    ASSERT_NOT_EQUAL(attributePosition, -1, ());
    GLFunctions::glEnableVertexAttribute(attributePosition);
    GLFunctions::glVertexAttributePointer(attributePosition, kComponentsInVertex,
                                          gl_const::GLFloatType, false, 0, 0);

    if (hasNormals)
    {
        GLFunctions::glBindBuffer(m_bufferNormalsId, gl_const::GLArrayBuffer);
        uint32_t const attributeNormal = program->GetAttributeLocation("a_normal");
        ASSERT_NOT_EQUAL(attributeNormal, -1, ());
        GLFunctions::glEnableVertexAttribute(attributeNormal);
        GLFunctions::glVertexAttributePointer(attributeNormal, 3, gl_const::GLFloatType, false, 0, 0);
    }

    dp::UniformValuesStorage uniforms;
    math::Matrix<float, 4, 4> const modelTransform = CalculateTransform(screen, dz);
    uniforms.SetMatrix4x4Value("u_transform", modelTransform.m_data);
    glsl::vec4 const c = glsl::ToVec4(color);
    uniforms.SetFloatValue("u_color", c.r, c.g, c.b, c.a);
    dp::ApplyState(m_state, program);
    dp::ApplyUniforms(uniforms, program);
    GLFunctions::glDrawArrays(gl_const::GLTriangles, 0, m_vertices.size() / kComponentsInVertex);
}
开发者ID:trashkalmar,项目名称:omim,代码行数:30,代码来源:arrow3d.cpp

示例2: sizeof

void Arrow3d::Build(ref_ptr<dp::GpuProgram> prg)
{
  m_bufferId = GLFunctions::glGenBuffer();
  GLFunctions::glBindBuffer(m_bufferId, gl_const::GLArrayBuffer);

  m_attributePosition = prg->GetAttributeLocation("a_pos");
  ASSERT_NOT_EQUAL(m_attributePosition, -1, ());

  GLFunctions::glBufferData(gl_const::GLArrayBuffer, m_vertices.size() * sizeof(m_vertices[0]),
                            m_vertices.data(), gl_const::GLStaticDraw);

  m_bufferNormalsId = GLFunctions::glGenBuffer();
  GLFunctions::glBindBuffer(m_bufferNormalsId, gl_const::GLArrayBuffer);

  m_attributeNormal = prg->GetAttributeLocation("a_normal");
  ASSERT_NOT_EQUAL(m_attributeNormal, -1, ());

  GLFunctions::glBufferData(gl_const::GLArrayBuffer, m_normals.size() * sizeof(m_normals[0]),
                            m_normals.data(), gl_const::GLStaticDraw);

  GLFunctions::glBindBuffer(0, gl_const::GLArrayBuffer);
}
开发者ID:ipaddr,项目名称:omim,代码行数:22,代码来源:arrow3d.cpp


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