本文整理汇总了C++中Graphics::BindVertexArray方法的典型用法代码示例。如果您正苦于以下问题:C++ Graphics::BindVertexArray方法的具体用法?C++ Graphics::BindVertexArray怎么用?C++ Graphics::BindVertexArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Graphics
的用法示例。
在下文中一共展示了Graphics::BindVertexArray方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Draw
void Polygon::Draw()
{
//Safety check the shader
if(m_Shader == nullptr)
{
return;
}
//If the model matrix is dirty, reset it
if(IsModelMatrixDirty() == true)
{
ResetModelMatrix();
}
//Use the shader
m_Shader->Use();
//Set the point size attribute
int pointSizeIndex = m_Shader->GetAttribute("a_pointSize");
glEnable(GL_VERTEX_PROGRAM_POINT_SIZE);
glVertexAttrib1f(pointSizeIndex, m_PointSize);
//Cache the graphics service
Graphics* graphics = ServiceLocator::GetGraphics();
//Bind the vertex array object
graphics->BindVertexArray(m_VertexArrayObject);
//Set the model view projection matrix
mat4 mvp = graphics->GetProjectionMatrix() * graphics->GetViewMatrix() * m_ModelMatrix;
glUniformMatrix4fv(m_Shader->GetModelViewProjectionUniform(), 1, 0, &mvp[0][0]);
//Validate the shader
if(m_Shader->Validate() == false)
{
Error(false, "Can't draw Polygon, shader failed to validate");
return;
}
//Disable blending, if we did in fact have it enabled
if(m_Color.Alpha() != 1.0f)
{
graphics->EnableBlending();
}
//Render the polygon
glDrawArrays(m_RenderMode, 0, (GLsizei)m_Vertices.size());
//Disable blending, if we did in fact have it enabled
if(m_Color.Alpha() != 1.0f)
{
graphics->DisableBlending();
}
//Unbind the vertex array
ServiceLocator::GetGraphics()->BindVertexArray(0);
//Draw the debug anchor point
#if DRAW_POLYGON_ANCHOR_POINT
if(GetType() != "Point" && GetType() != "Line")
{
Line lineA(m_AnchorLocation, vec2(m_AnchorLocation.x, m_AnchorLocation.y + DRAW_POLYGON_ANCHOR_POINT_SIZE));
lineA.SetLocalAngle(GetWorldAngle());
lineA.SetColor(Color::RedColor());
lineA.Draw();
Line lineB(m_AnchorLocation, vec2(m_AnchorLocation.x + DRAW_POLYGON_ANCHOR_POINT_SIZE, m_AnchorLocation.y));
lineB.SetLocalAngle(GetWorldAngle());
lineB.SetColor(Color::GreenColor());
lineB.Draw();
}
#endif
//Call the GameObject's Draw() method, this will ensure that any children will also get drawn
GameObject::Draw();
}