本文整理汇总了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);
}
示例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);
}