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


C++ Graphics::BindVertexArray方法代码示例

本文整理汇总了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();
    }
开发者ID:Epidilius,项目名称:ZeldaStyleAdventureGame,代码行数:76,代码来源:Polygon.cpp


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