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


C++ ShaderProgram::getGlProgram方法代码示例

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


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

示例1: enable

void VertexLayout::enable(ShaderProgram& _program, size_t _byteOffset, void* _ptr) {

    GLuint glProgram = _program.getGlProgram();

    // Enable all attributes for this layout
    for (auto& attrib : m_attribs) {

        GLint location = _program.getAttribLocation(attrib.name);

        if (location != -1) {
            auto& loc = s_enabledAttribs[location];
            // Track currently enabled attribs by the program to which they are bound
            if (loc != glProgram) {
                glEnableVertexAttribArray(location);
                loc = glProgram;
            }

            void* data = _ptr ? _ptr : ((unsigned char*) attrib.offset) + _byteOffset;
            glVertexAttribPointer(location, attrib.size, attrib.type, attrib.normalized, m_stride, data);
        }
    }

    // Disable previously bound and now-unneeded attributes
    for (auto& locationProgramPair : s_enabledAttribs) {

        const GLint& location = locationProgramPair.first;
        GLuint& boundProgram = locationProgramPair.second;

        if (boundProgram != glProgram && boundProgram != 0) {
            glDisableVertexAttribArray(location);
            boundProgram = 0;
        }
    }
}
开发者ID:fangjianming,项目名称:tangram-es,代码行数:34,代码来源:vertexLayout.cpp

示例2: enable

void VertexLayout::enable(RenderState& rs, ShaderProgram& _program, size_t _byteOffset, void* _ptr) {

    GLuint glProgram = _program.getGlProgram();

    // Enable all attributes for this layout
    for (auto& attrib : m_attribs) {

        GLint location = _program.getAttribLocation(attrib.name);

        if (location != -1) {
            auto& loc = rs.attributeBindings[location];
            // Track currently enabled attribs by the program to which they are bound
            if (loc != glProgram) {
                GL::enableVertexAttribArray(location);
                loc = glProgram;
            }

            void* data = (unsigned char*)_ptr + attrib.offset + _byteOffset;
            GL::vertexAttribPointer(location, attrib.size, attrib.type, attrib.normalized, m_stride, data);
        }
    }

    // Disable previously bound and now-unneeded attributes
    for (size_t i = 0; i < RenderState::MAX_ATTRIBUTES; ++i) {

        GLuint& boundProgram = rs.attributeBindings[i];

        if (boundProgram != glProgram && boundProgram != 0) {
            GL::disableVertexAttribArray(i);
            boundProgram = 0;
        }
    }
}
开发者ID:enterstudio,项目名称:tangram-es,代码行数:33,代码来源:vertexLayout.cpp


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